Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix string literal span on import/export specifiers to only include string literal #540

Merged
merged 11 commits into from
Dec 29, 2019

Conversation

dsherret
Copy link
Contributor

@dsherret dsherret commented Dec 28, 2019

Expanding on fix for #535. Took a look at the PR for that to figure this out.

Currently there's definitely going to be a failing test here. I still can't figure out how to compile the tests locally so I'm going to use the CI to test... (and to help me fill in the missing info in the json file that I know I'll get wrong the first time).

@dsherret dsherret changed the title String literal span on import/export specifiers only includes string literal Fix string literal span on import/export specifiers to only include string literal Dec 28, 2019
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
I'll test it locally when I go home and merge it if the test successes

@@ -10,7 +10,7 @@
"type": "ImportDeclaration",
"span": {
"start": 0,
"end": 26,
"end": 27,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import declaration should include the last semi-colon. This test and some others seem to be failing on master.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently travis ci chokes on other tests for parser.
(It seems like a rustc version issue)

So I'll merge the pr after testing locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. By the way, feel free to make any edits to fix any mistakes I made. I am going a bit blind here because II'm not sure how to run the tests for this. (I tried cargo +nightly test --color always --all --all-features, but it doesn't seem to run the input.json-like tests)

Copy link
Member

@kdy1 kdy1 Dec 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo +nightly test --color always --all --all-features

invokes input.ts based reference testing, but it updates reference file when comparison failed. Note that this behavior was introduced to avoid updating test one by one.

@dsherret dsherret marked this pull request as ready for review December 28, 2019 05:48
@dsherret
Copy link
Contributor Author

dsherret commented Dec 28, 2019

@kdy1 thanks and no rush! I am building off the source anyway so this is not blocking me.

What's the best way to run only one of these tests? I found I can run cargo +nightly test --color always --all --all-features on the root directory ok (edit: Ah, I see I can just run that in the parser folder, but it doesn't seem to run the typescript folder). I do get a lot of failing tests specific to windows I bet:

---- issue_528 stdout ----
[/bar
a,foo
b/bar
];
thread 'issue_528' panicked at 'assertion failed: `(left == right)`
  left: `"//bar\r[\n//foo\ra,\n//baz\r//bar\rb\n];"`,
 right: `"//bar\n[\n//foo\na,\n//baz\n//bar\nb\n];"`', tests\projects.rs:247:5

@kdy1
Copy link
Member

kdy1 commented Dec 28, 2019

The test issue_528 is declared on top level crate (swc), so you can just remove --all.
Otherwise, you can append issue_528 to the last of cargo test invokation.

@kdy1
Copy link
Member

kdy1 commented Dec 28, 2019

I tested it locally, and got some failures.
Can you run cargo test --all-features in swc/ecmascript/paser directory? It will update related reference files.

Related tests:

/tests/jsx/basic/custom/unary-paren/input.js.json
/tests/jsx/basic/custom/unary/input.js.json
/tests/typescript/custom/issue-535/input.ts.json
/tests/typescript/custom/tsx-unary/input.tsx.json
/tests/typescript/import/not-top-level/input.ts.json

@dsherret
Copy link
Contributor Author

@kdy1 Oops... I accidentally looked at the 1-indexed "column" in my text editor instead of a 0-indexed value. I was correct originally then I changed it to be incorrect once I reviewed it.

I fixed the other span issues. It's helpful to be able to run the tests, but there are a lot of changed files on my machine after running that (it changes them to all go from \r\n to \n). The tests should probably be changed to bring in everything as \n newlines from the file system... or I think perhaps I have a setting in git that's changing them to \r\n on Windows.

@kdy1
Copy link
Member

kdy1 commented Dec 28, 2019

Oops... I accidentally looked at the 1-indexed "column" in my text editor instead of a 0-indexed value. I was correct originally then I changed it to be incorrect once I reviewed it.

Can you revert it?

I fixed the other span issues. It's helpful to be able to run the tests, but there are a lot of changed files on my machine after running that (it changes them to all go from \r\n to \n). The tests should probably be changed to bring in everything as \n newlines from the file system... or I think perhaps I have a setting in git that's changing them to \r\n on Windows.

Then I'll investigate.

@dsherret
Copy link
Contributor Author

dsherret commented Dec 28, 2019

I changed the code to get the Str, then parse the semi-colon, then return the declaration. Let me know if that makes sense or if I should revert that to what I had yesterday.

I think everything is good now! My "oops" was for a past mistake where I did it correctly, rechecked it in my editor and thought it was wrong (because the column value was 1-indexed), then made the numbers wrong based on that 1-index, then reverted it back to fix it.

@kdy1
Copy link
Member

kdy1 commented Dec 29, 2019

I think it makes sense and you don't need to revert it.

I'll merge pr soon.
(travis issue is bit annoying..)

@kdy1 kdy1 merged commit bde5341 into swc-project:master Dec 29, 2019
@kdy1
Copy link
Member

kdy1 commented Dec 29, 2019

Merged it. Thank you for the pr!!

@dsherret dsherret deleted the issue535 branch December 29, 2019 18:54
@kdy1 kdy1 added this to the v1.1.11 milestone Jan 2, 2020
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants