Skip to content

[WIP] fix encoding issues #1494

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

Merged
merged 5 commits into from
Oct 6, 2016
Merged

Conversation

martijnhoekstra
Copy link
Contributor

the -encoding compiler flag wasn't honored at all.

Behind a WIP flag, because it depends on the earlier PR with the other test fixes for Windows, as it's very hard to build something isolated when the tests are still failing, and will need to get rabased and cleaned up at some point.

@@ -0,0 +1 @@
-encoding UTF16
Copy link
Member

Choose a reason for hiding this comment

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

.flags file are currently ignored by partest, and I'm not sure if there's any way to have a run test with a special set of flags currently.
/cc @DarkDimius : If we make a run-special folder like pos-special, will its content be treated as run-tests by partest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smarter That makes me realize this doesn't actually have to be a run test, as it won't compile anyway if it doesn't have the -encoding flag set to UTF-16. Should it be moved?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, you should move it to pos-special and add a line next to https://github.com/lampepfl/dotty/blob/d84805299a42cb8d2c756aff5a117af24dbeaaf4/test/dotc/tests.scala#L113 like:

@Test def pos_utf16encoded = compileFile(posSpecialDir, "utf16encoded", List("-encoding", "UTF16"))

@martijnhoekstra martijnhoekstra force-pushed the wintests branch 2 times, most recently from 8450ff0 to 663db29 Compare September 5, 2016 19:04
Martijn Hoekstra and others added 2 commits September 7, 2016 22:32
rename test/pos/valueclasses to pos_valueclasses

tests/pos/valueclasses generates a valueclasses.flags
file in /tests/partest-generated/pos that conflicts
with the valueClasses.flags file that
tests/neg/valueClasses.scala tries to create
@martijnhoekstra
Copy link
Contributor Author

And that's a passing test-suite.

I'm particularly uncertain about what I did at 32819e2

Should that be split up in the part where -encoding and default UTF8 encoding are honored, and the test renames? Should neg/valueClasses.scala be renamed rather than pos/valueclasses/?

I'm also not too happy with the manual bitwise copy, which seems out of place in 6bce106

@sjrd
Copy link
Member

sjrd commented Sep 8, 2016

I'll have a closer look at this during the week-end, on Windows at home.

@@ -49,7 +49,7 @@ class TestREPL(script: String) extends REPL {
out.close()
val printed = out.toString
val transcript = printed.drop(printed.indexOf(config.prompt))
if (transcript.toString != script) {
if (transcript.toString.lines.toList != script.lines.toList) {
Copy link
Member

Choose a reason for hiding this comment

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

You can avoid the reification as Lists with sameElements:

if (transcript.toString.lines.sameElements(script.lines))

@sjrd
Copy link
Member

sjrd commented Sep 11, 2016

Why renaming some pos tests with pos_test names? That seems like a workaround to a deeper issue. We should fix the original issue instead.

@@ -228,7 +228,7 @@ abstract class CompilerTest {

private def expectedErrors(filePath: String): List[ErrorsInFile] = expectedErrors(List(filePath))

private def isNegTest(testPath: String) = testPath.contains(JFile.separator + "neg" + JFile.separator)
private def isNegTest(testPath: String) = testPath.contains("/neg/")
Copy link
Member

Choose a reason for hiding this comment

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

Should this change have been part of another commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

32819e2 should probably be broken up in just the part that fixes dotty not honoring default and passed in -encoding arguments (which is an actual bug in dotty) and the parts that get the tests running on Windows (which is "just" a set of test-suite bugs). WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

That sounds good :)

out.close()
} else {
try {
SFile(dest)(scala.io.Codec.UTF8).writeAll((s"/* !!!!! WARNING: DO NOT MODIFY. Original is at: $file !!!!! */").replace("\\", "/"), file.slurp("UTF-8"))
Copy link
Member

Choose a reason for hiding this comment

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

Why the .replace("\\", "/")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

some path parts start with u. Then comment then contains \u(something), which gets interpreted as an invalid unicode escape, failing compilation.

Copy link
Member

Choose a reason for hiding this comment

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

Ah ah!
Well, that deserves to be written as a comment above this line, then, IMO.

@sjrd
Copy link
Member

sjrd commented Sep 11, 2016

That's all I have.

Note: on my Windows machine, sbt test still fails on your branch. Is that expected?

[error] Failed: Total 166, Failed 19, Errors 0, Passed 147
[error] Failed tests:
[error]         dotc.tests
[error] (dotty/test:test) sbt.TestsFailedException: Tests unsuccessful

@martijnhoekstra
Copy link
Contributor Author

No, on my Windows machine sbt test passes everything. I'll first get to work on your comments; that's plenty for now. Maybe after that we can see if there are failing tests in different environments?

@felixmulder
Copy link
Contributor

As this improves the current state - we're merging this. Thanks for your contribution @martijnhoekstra !

@felixmulder felixmulder merged commit a306462 into scala:master Oct 6, 2016
smarter added a commit to smarter/dotty that referenced this pull request Oct 6, 2016
The one-parameter constructor of SourceFile was removed in scala#1494
@martijnhoekstra
Copy link
Contributor Author

@felixmulder thank you for merging it, and my sincere apologies for not coming back to this in a timely manner. I'll investigate the remainder of the cleanup that's still to be done, and make sure it gets solved.

@felixmulder
Copy link
Contributor

No need to apologize, your contribution improved the project -- therefore we merged it, simple as that. We'd be very grateful for further improvements on the windows side, as nobody at the lab currently uses windows.

Cheers,
Felix

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

Successfully merging this pull request may close these issues.

5 participants