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

Serde testing infrastructure for the Enso compiler #6062

Merged
merged 28 commits into from
Mar 28, 2023
Merged

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Mar 23, 2023

Pull Request Description

The primary delivery of this PR is a design of SerdeCompilerTest - a testing suite that allows us to write sample projects, parse them with and without caches and verify they still produce the same IR. This is a similar idea to #3723 which compared the old and new parser IRs.

With infrastructure like this we can start addressing #5567 without any (significant) fear of breaking something essential.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • All code follows the
    Scala,
    Java,
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.

@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Mar 23, 2023
@JaroslavTulach JaroslavTulach self-assigned this Mar 23, 2023
Copy link
Contributor

@hubertp hubertp left a comment

Choose a reason for hiding this comment

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

I like the approach. Mostly minor nits

if (!ir1.equals(ir2)) {
String name = findTestMethodName();
Path home = new File(System.getProperty("user.home")).toPath();
Files.writeString(home.resolve(name + ".1"), ir1, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try and not write those to a user's home directory? A directory inside a checked out repo that is simply ignored would be much better

Copy link
Member Author

Choose a reason for hiding this comment

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

The files are written only in case of failure and are really helpful when one needs to diff them. I was rewriting the old parser to new one without the files being dump and it was plain horrible - e.g. ignoring the files isn't an option. Feel free to suggest better location instead of home. Anyway, this is not code introduced by this PR - I have just refactored it to another class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, it can write to the tmp directory

Copy link
Contributor

@hubertp hubertp Mar 28, 2023

Choose a reason for hiding this comment

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

@JaroslavTulach I know. I didn't like it then, I don't like it now. I understand the sentiment that with hundreds of failures you really want to have something nearby but I also don't like things polluting my home directory.

@JaroslavTulach
Copy link
Member Author

There were some suspicious test failures probably related not to the Serde testing infrastructure, but the previous changes I did. Removed in 143e4f9 with the hope to narrow the PR down and keep it focus only on the testing infrastructure.

@JaroslavTulach JaroslavTulach added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Mar 27, 2023
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Mar 27, 2023

There is a failure in SerdeCompilerTest which can be reproduced as:

enso$ rm -rf ./target/fake_dir/cache/ir/local/Fib_Test
enso$ sbt runtime/testOnly *SerdeCompilerTest
[error] Test org.enso.compiler.SerdeCompilerTest.testFibTest failed: org.graalvm.polyglot.PolyglotException: Compile error: The name `Arith` could not be found., took 3.903 sec
[error]     at <enso>.Main.main(Main.enso:4)
[error]     at org.graalvm.polyglot.Value.execute(Value.java:878)
[error]     at org.enso.compiler.SerdeCompilerTest.parseSerializedModule(SerdeCompilerTest.java:90)
[error]     at org.enso.compiler.SerdeCompilerTest.testFibTest(SerdeCompilerTest.java:34)
[error]     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]     at java.lang.reflect.Method.invoke(Method.java:566)
[error]     ...
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0
[error] Failed tests:
[error]         org.enso.compiler.SerdeCompilerTest

@JaroslavTulach JaroslavTulach removed the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Mar 27, 2023
@JaroslavTulach JaroslavTulach added the CI: Ready to merge This PR is eligible for automatic merge label Mar 28, 2023
if (!ir1.equals(ir2)) {
String name = findTestMethodName();
Path home = new File(System.getProperty("user.home")).toPath();
Files.writeString(home.resolve(name + ".1"), ir1, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, it can write to the tmp directory

if (!ir1.equals(ir2)) {
String name = findTestMethodName();
Path home = new File(System.getProperty("user.home")).toPath();
Files.writeString(home.resolve(name + ".1"), ir1, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
Copy link
Contributor

@hubertp hubertp Mar 28, 2023

Choose a reason for hiding this comment

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

@JaroslavTulach I know. I didn't like it then, I don't like it now. I understand the sentiment that with hundreds of failures you really want to have something nearby but I also don't like things polluting my home directory.

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Mar 28, 2023

OK, let's improve our engineering practices a bit. With fc013a7 one gets:

[error] Test org.enso.compiler.SerdeCompilerTest.testFibTest failed: 
Serialized and deserialized IR for Fib_Test expected:
</tmp/testFibTest.1> but was:</tmp/testFibTest.2>, took 2.608 sec
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0

and one can diff the two files then.

@mergify mergify bot merged commit 46bd6f6 into develop Mar 28, 2023
@mergify mergify bot deleted the wip/jtulach/IR_5567 branch March 28, 2023 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants