Skip to content

Improve test suite#177

Open
cheestree wants to merge 9 commits intoliquid-java:mainfrom
cheestree:improve-test-suite
Open

Improve test suite#177
cheestree wants to merge 9 commits intoliquid-java:mainfrom
cheestree:improve-test-suite

Conversation

@cheestree
Copy link

Closes #174 . These changes allow for inline error tests via a comment similar to how some are currently done but with a separate .expected file.

The file (or files in a given directory) is read line-by-line and, if a line has at the end a comment with the Error string, it is considered an error that the code in question should report. By implementing a pair to track message and line number, we can make sure that both properties are fulfilled when checking a reported error, and not simply the title. Due to non-deterministic variable naming, entire error line checking was not implemented.

Incorrect error placement
Screenshot_20260314_122126

Passing test
Screenshot_20260314_121918

To reduce unnecessary noise in the suite, the maven-surefire-plugin has a configuration that cuts the stack-trace at the end of the tests, since we're not gonna use it to observe test behavior.

These changes WILL break the test suite, as every file and folder will need to be refactored to accommodate the new method of error reporting.

try {
List<Path> files = Files.list(dirPath).filter(Files::isRegularFile).toList();
for (Path file : files) {
getExpectedErrorsFromFile(file).forEach(expectedErrors::add);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice.

<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<trimStackTrace>true</trimStackTrace>
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@cheestree cheestree force-pushed the improve-test-suite branch 3 times, most recently from 1370c86 to 1b9d5ac Compare March 14, 2026 18:34
Should now print the line of code throwing the error, as well as the error type and description.
Instead of using separate files or stating at the top of a class file the error that it should report, now it is read and all correctly defined errors are added to a list. It is then checked against the first error that occurred and reports back. Still only works with a single error reported, however.
Errors are now gathered with their line number and compared based on the message and position. Added a Pair record to
@cheestree cheestree force-pushed the improve-test-suite branch from 1b9d5ac to 46c131a Compare March 14, 2026 20:17
@rcosta358
Copy link
Collaborator

Great! Now that we can have multiple failures, all that's left to do is merge some failing tests, e.g., ErrorArithmeticFP1.java, ErrorArithmeticFP2.java, ErrorArithmeticFP3.java, ErrorArithmeticFP4.java into ErrorArithmeticFP.java.

Due to multiple error check/annotation, some tests have been merged into single files to reduce testing workload. Math tests need to be reviewed due to weird behavior if the refinements aren't alone in the same folder as the test.
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.

Improve Test Suite

2 participants