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 backslashes missing (or blowing up) on Windows #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

3vilguy
Copy link

@3vilguy 3vilguy commented Mar 30, 2017

I was getting an error while trying to run unit tests for JS target.

Uncaught SyntaxError: Invalid Unicode escape sequence
    at massive_munit_client_ExternalPrintClientJS.queue (js_test.js:6799)
    at massive_munit_client_ExternalPrintClientJS.addTestClassCoverageItem (js_test.js:6768)
    at massive_munit_client_RichPrintClient.setCurrentTestClassCoverage (js_test.js:6948)
    at mcover_coverage_munit_client_MCoverPrintClient.updateTestClassCoverage (js_test.js:9429)
    at mcover_coverage_munit_client_MCoverPrintClient.setCurrentTestClass (js_test.js:9397)
    at massive_munit_TestRunner.execute (js_test.js:5730)
    at massive_munit_TestRunner.run (js_test.js:5695)
    at delayStartup (js_test.js:369)
    at TestMain [as __class__] (js_test.js:373)
    at Function.TestMain.main (js_test.js:378)

After bit of digging I found that it's blowing up in PrintClientBase.hx#L510.

Seems like my utils package was causing eval() issues because of \u.
After even more digging I finally found place where I can fix it, I came here to do a fork so i can PR and (surprise, surprise) I found THIS COMMIT.
I think it was accidentally removed in this commit while fixing split on windows, but looks like this replace line is still needed before using regex. And just "\\\\" are not enough, because eval() is called again in printclient.js#L51.

On top of that this PR should also fix #36

Regards :)

…here's any package starting with 'u' (because of \u being special case in JS....)
@elsassph
Copy link
Contributor

Would it work if we just replaced backslashes by forward slashes on Windows?

@3vilguy
Copy link
Author

3vilguy commented May 16, 2017

@elsassph Do you mean just replace it for alternateLocation variable in same place my fix is done (createCodeBlockReference function) ?
Or for the classFile, which currently is done by FileSystem.fullPath() and then it's calling createCodeBlockReference function?

@3vilguy
Copy link
Author

3vilguy commented May 16, 2017

Just tried:
if(IS_WINDOWS) alternateLocation = StringTools.replace(alternateLocation, "\\", "/");
and it seems to be working as well.

@elsassph
Copy link
Contributor

I'm not really familiar with this library honestly (trying to find someone who worked on it), but maybe the path should be sanitized before, in createCodeBlockReference when the alternateLocation is constructed.

@misprintt
Copy link
Contributor

Makes sense. It can be merged once someone has confirmed that it passes all the unit tests (on a windows machine)

@3vilguy
Copy link
Author

3vilguy commented May 17, 2017

"Works on My Machine" ™

worksonmymachine
worksonmymachine2

But you should double check it with someone else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backslashes missing in paths on Windows
3 participants