feat: Add --scan-dryrun-results flag for Maven test runner#1278
feat: Add --scan-dryrun-results flag for Maven test runner#1278psakthivel04 wants to merge 1 commit intov1from
Conversation
|
|
||
| if classname: | ||
| test_paths.append({"type": "class", "name": classname}) | ||
| click.echo(f" Discovered: {classname}", err=True) |
There was a problem hiding this comment.
It might be better to remove this, as having many classes could result in an excessive amount of logs.
There was a problem hiding this comment.
yes removed it
| @@ -0,0 +1,4 @@ | |||
| ------------------------------------------------------------------------------- | |||
There was a problem hiding this comment.
How did you create these test files??
Since others may need to make changes as well, could you please document how to create these files in the tests/data/mave/README.md or a similar place?
There was a problem hiding this comment.
yes create new README file
| ): | ||
|
|
||
| # Handle --scan-dryrun-results: parse Maven surefire reports | ||
| if is_scan_dryrun_results: |
There was a problem hiding this comment.
Currently the --scan-dryrun-results path is an early return block that bypasses the rest of the subset() function. This makes it a separate code path with its own client.run() call, while the other modes (--test-compile-created-file, --scan-test-compile-lst, source_roots) all converge into a single client.run() at the end.
This could be unified into the existing if / elif / else structure:
-
- # Handle --scan-dryrun-results: parse Maven surefire reports
- if is_scan_dryrun_results:
- click.echo("Scanning Maven dry-run results...", err=True)
- tests = parse_surefire_reports()
-
- if not tests:
- click.secho(
- "Warning: No surefire reports found. Did you run 'mvn test -DdryRun=true'?",
- fg='yellow',
- err=True
- )
- click.secho(
- "Please run: mvn test -DdryRun=true",
- fg='cyan',
- err=True
- )
- return
-
- # Add tests to client (each test path must be a list)
- for test in tests:
- client.test_paths.append([test])
-
- client.same_bin_formatter = lambda s: [{"type": "class", "name": s}]
- client.run()
- return
-
# Compile exclude rules
compiled_exclude_rules = []
...
- files_to_read = list(test_compile_created_file)
- if is_scan_test_compile_lst:
+ if is_scan_dryrun_results:
+ click.echo("Scanning Maven dry-run results...", err=True)
+ tests = parse_surefire_reports()
+
+ if not tests:
+ click.secho(
+ "Warning: No surefire reports found. Did you run 'mvn test -DdryRun=true'?",
+ fg='yellow',
+ err=True
+ )
+ click.secho(
+ "Please run: mvn test -DdryRun=true",
+ fg='cyan',
+ err=True
+ )
+ return
+
+ for test in tests:
+ client.test_paths.append([test])
+
+ elif is_scan_test_compile_lst:
+ files_to_read = list(test_compile_created_file)
if len(test_compile_created_file) > 0:
...
...
-
- if files_to_read:
+ elif files_to_read:
for file in files_to_read:
...
else:
for root in source_roots:
client.scan(root, '**/*', file2test)
client.run()WDYT??
There was a problem hiding this comment.
yes I have refactored it
This comment has been minimized.
This comment has been minimized.
eae7c2a to
8f78d8f
Compare
| @click.option( | ||
| '--scan-dryrun-results', | ||
| 'is_scan_dryrun_results', | ||
| required=False, |
There was a problem hiding this comment.
nits: required=False is a default. So you don't need to set it
There was a problem hiding this comment.
yes updated it
| "Warning: No .lst files. Please run after executing `mvn test-compile`", fg="yellow"), | ||
| err=True) | ||
| return | ||
| client.same_bin_formatter = lambda s: [{"type": "class", "name": s}] |
There was a problem hiding this comment.
Do we need to set this property here?
There was a problem hiding this comment.
yes updated it
| cd tests/data/maven/dryrun-test | ||
|
|
||
| # Run Maven dry-run to generate Surefire reports | ||
| mvn test -DdryRun=true |
There was a problem hiding this comment.
is it correct? pom.xml file and other files don't exist. And I've faced this error
$ mvn test -DdryRun=true
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.023 s
[INFO] Finished at: 2026-04-16T17:30:14+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/ryabuki/src/github.com/cloudbees-oss/smart-tests-cli-wt/review-1278/tests/data/maven/dryrun-test). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
There was a problem hiding this comment.
yes without pom.xml . will get this error. This is fine right.
…orkspace names from API response
8f78d8f to
2c3cf81
Compare
Why:
Add support for scanning Maven Surefire reports generated by mvn test -DdryRun=true. This allows users to leverage Maven's own test discovery and filtering logic for 100% accuracy.
Changes:
Fixes issue where CLI would include filtered tests that Maven excludes, leading to 'missing test report' warnings in the UI.
local testing: