Skip to content

A cli rascal test runner for use from the maven plugin. #2755

Draft
jurgenvinju wants to merge 8 commits into
mainfrom
feat/test-cli
Draft

A cli rascal test runner for use from the maven plugin. #2755
jurgenvinju wants to merge 8 commits into
mainfrom
feat/test-cli

Conversation

@jurgenvinju

@jurgenvinju jurgenvinju commented Apr 13, 2026

Copy link
Copy Markdown
Member
  • This avoids having to write a Java class file with the JUnitTestRunner annotation, even in project that otherwise have no Java code. It also works for projects that do have Java dependencies.
  • This closes the abstraction for Rascal as a language (you don't have to understand anymore that it's an interpreted and/or compiled language or how the test runners have been organized (via JUnit or otherwise).
  • This makes sure that the generic surefire-report XML format is respected for integration with github actions and VScode reporting tools.

To use this add this to your pom.xml and make sure the <srcs> configuration for the rascal-maven-plugin matches what you want to test. You can also add a new <srcs> tag here with a different <configuration> under <execution>:

<execution>
     <id>yourproject-test</id>
     <phase>test</phase>
     <goals>
           <goal>test</goal>
     </goals>
</execution>
  • CLI command to call the test runner with the same parameters as calling the checker or the compiler or the exec runner
  • Optionally log in JUnit testsuite report format for picking up by CLI and CI tools
  • Add test runner statistics for each testsuite/module XML file
  • Documents the Surefire/JUnit test report XML format as a Rascal abstract grammar.

This does not (yet) work for compiled Rascal code, but the exact same interface could be implemented for generated test code (whether or not we use JUnit for that or not).

@codecov

codecov Bot commented Apr 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 140 lines in your changes missing coverage. Please review.
✅ Project coverage is 46%. Comparing base (db87bc1) to head (834276c).

Files with missing lines Patch % Lines
...pl/test/infrastructure/JUnitXMLReportListener.java 0% 83 Missing ⚠️
src/org/rascalmpl/shell/RascalTest.java 0% 53 Missing ⚠️
...g/rascalmpl/interpreter/env/GlobalEnvironment.java 0% 3 Missing ⚠️
src/org/rascalmpl/shell/CommandlineParser.java 0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##              main   #2755    +/-   ##
========================================
- Coverage       46%     46%    -1%     
- Complexity    6723    6727     +4     
========================================
  Files          839     841     +2     
  Lines        66766   66906   +140     
  Branches      9983    9998    +15     
========================================
+ Hits         30781   30796    +15     
- Misses       33598   33730   +132     
+ Partials      2387    2380     -7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jurgenvinju jurgenvinju changed the title first versions saved from old branch A cli rascal test runner for use from the maven plugin. Apr 14, 2026
@jurgenvinju jurgenvinju marked this pull request as ready for review April 14, 2026 08:24
@jurgenvinju jurgenvinju self-assigned this Apr 14, 2026
@jurgenvinju jurgenvinju marked this pull request as draft April 14, 2026 10:20
@sonarqubecloud

Copy link
Copy Markdown

@DavyLandman

DavyLandman commented Apr 17, 2026

Copy link
Copy Markdown
Member

I like this feature 👍 I'll try to allocate time for a review next week.

@sonarqubecloud

Copy link
Copy Markdown

public Map<String, ISourceLocation> moduleFiles() {
return moduleLocations.entrySet()
.stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> URIUtil.assumeCorrectLocation(e.getValue().toASCIIString())));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

side-quest: why are we using URIs in that moduleLocations map?

for (int i = 0; i < commandline.length; i++) {
if (List.of("-help", "--help", "/?", "?", "\\?", "-?", "--?").contains(commandline[i].trim())) {
printMainHelpMessage(kwTypes);
out.flush();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this flush should be moved to the printMainHelpMessage?

Comment on lines +34 to +39
RascalShell.setupJavaProcessForREPL();

var term = RascalShell.connectToTerminal();
var monitor = IRascalMonitor.buildConsoleMonitor(term);
var err = (monitor instanceof Writer) ? StreamUtil.generateErrorStream(term, (Writer)monitor) : new PrintWriter(System.err, true);
var out = (monitor instanceof PrintWriter) ? (PrintWriter) monitor : new PrintWriter(System.out, false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I remember surefire had issues jline capturing the output stream using native hooks. And that is why we had to avoid the progress bar feature inside the test.

If this has been tested on this PR, let's also test it on windows.

Can we add this RascalTest to the test suite we run on integration?

Comment on lines +45 to +46
PathConfig pcfg = pcfgCons != null ? new PathConfig(pcfgCons) : new PathConfig();
var projectRoot = pcfg.getProjectRoot().getScheme().equals("unknown") ? URIUtil.rootLocation("cwd") : pcfg.getProjectRoot();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should reuse more code from ShellEvaluatorFactory. Some calculate the path config in a more robust way Like for example based on the cwd as a fallback etc.

the test runs of your own DSL, such that they can be integrated
in Github CI run reports and other UX.
}
module lang::xml::\surefire-reports::TestSuites

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this module exists, but then we also have JUnitXMLReportListener.java that is again recreating this structure, can we not reuse rascal for the reporting an constructing of the XML?

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.

2 participants