Extract CLI logic from TestNG core - #2612
Conversation
|
@juherr - Please give me some more time to go through this implementation (maybe this weekend). I liked this decoupling 👍 One thing. Do you think we can start preferring to use Streams and lambdas over regular for loops ? |
|
@juherr - I tried checking out your branch and then running the tests via Please let me know if I am doing anything incorrectly here. |
|
@krmahadevan Thanks for the feedback. I moved it to draft because I didn't check tests yet. If the move looks good enough for you, I will finish it asap. |
|
@juherr - Sure. I am fine with this change. Please help take it forward. |
testng-core depended on org.jcommander:jcommander in `api` scope, so every consumer got the parsing library whether or not it drove TestNG from a command line. The coupling ran deep: CommandLineArgs was a @Parameter-annotated POJO, TestNG held a static JCommander field, and TestNG.configure(CommandLineArgs) mixed applying configuration with CLI-only string-to-object conversion. The front end now lives in two new modules: testng-cli CliOptions, CliConfigurer, AbstractCliRunner - no parser testng-jcommander the JCommander implementation, plus Converter testng-core keeps a minimal ServiceLoader SPI, ITestNGCliRunner, so that "java -cp testng.jar org.testng.TestNG suite.xml" is unchanged: both modules are bundled into the merged jar. Implementations never terminate the JVM - an unusable command line comes back as a TestNGException, and only TestNG.main turns it into a message, a usage banner and exit code 1. Backward compatibility for 7.x is kept through frozen @deprecated shims: CommandLineArgs (annotations stripped), TestNG.configure(CommandLineArgs), TestNG.validateCommandLineParameters, TestNG.main and TestNG.privateMain. TestNG.configure(Map), the method Maven Surefire calls, still builds a CommandLineArgs, so removing that class depends on Surefire moving first. CliConfigurerParityTest compares the state both paths produce, field by field, because nothing else keeps the frozen copy in sync with the live one. testng-test-kit becomes the shared test-fixture library, so the 22 tests whose subject is the command line could move to testng-jcommander. The 243 classes extending SimpleBaseTest are unaffected. The two modules are deliberately not published on their own, and are kept out of the BOM for the same reason: that would ship org.testng.cli.* and its service registration in two artifacts at once. It is a packaging change for the next major, tracked in testng-team#3301. Supersedes testng-team#2612.
testng-core depended on org.jcommander:jcommander in `api` scope, so every consumer got the parsing library whether or not it drove TestNG from a command line. The coupling ran deep: CommandLineArgs was a @Parameter-annotated POJO, TestNG held a static JCommander field, and TestNG.configure(CommandLineArgs) mixed applying configuration with CLI-only string-to-object conversion. The front end now lives in two new modules: testng-cli CliOptions, CliConfigurer, AbstractCliRunner - no parser testng-jcommander the JCommander implementation, plus Converter testng-core keeps a minimal ServiceLoader SPI, ITestNGCliRunner, so that "java -cp testng.jar org.testng.TestNG suite.xml" is unchanged: both modules are bundled into the merged jar. Implementations never terminate the JVM - an unusable command line comes back as a TestNGException, and only TestNG.main turns it into a message, a usage banner and exit code 1. Backward compatibility for 7.x is kept through frozen @deprecated shims: CommandLineArgs (annotations stripped), TestNG.configure(CommandLineArgs), TestNG.validateCommandLineParameters, TestNG.main and TestNG.privateMain. TestNG.configure(Map), the method Maven Surefire calls, still builds a CommandLineArgs, so removing that class depends on Surefire moving first. CliConfigurerParityTest compares the state both paths produce, field by field, because nothing else keeps the frozen copy in sync with the live one. testng-test-kit becomes the shared test-fixture library, so the 22 tests whose subject is the command line could move to testng-jcommander. The 243 classes extending SimpleBaseTest are unaffected. The two modules are deliberately not published on their own, and are kept out of the BOM for the same reason: that would ship org.testng.cli.* and its service registration in two artifacts at once. It is a packaging change for the next major, tracked in testng-team#3301. Supersedes testng-team#2612.
testng-core depended on org.jcommander:jcommander in `api` scope, so every consumer got the parsing library whether or not it drove TestNG from a command line. The coupling ran deep: CommandLineArgs was a @Parameter-annotated POJO, TestNG held a static JCommander field, and TestNG.configure(CommandLineArgs) mixed applying configuration with CLI-only string-to-object conversion. The front end now lives in two new modules: testng-cli CliOptions, CliConfigurer, AbstractCliRunner - no parser testng-jcommander the JCommander implementation, plus Converter testng-core keeps a minimal ServiceLoader SPI, ITestNGCliRunner, so that "java -cp testng.jar org.testng.TestNG suite.xml" is unchanged: both modules are bundled into the merged jar. Implementations never terminate the JVM - an unusable command line comes back as a TestNGException, and only TestNG.main turns it into a message, a usage banner and exit code 1. TestNG.setThreadCount now raises a TestNGException below 1 instead of printing the usage banner and calling System.exit(1), so that no library setter can kill an embedder's JVM. The command line output is unchanged: TestNG.main turns that exception into the same message and the same exit code. Backward compatibility for 7.x is kept through frozen @deprecated shims: CommandLineArgs (annotations stripped), TestNG.configure(CommandLineArgs), TestNG.validateCommandLineParameters, TestNG.main and TestNG.privateMain. TestNG.configure(Map), the method Maven Surefire calls, still builds a CommandLineArgs, so removing that class depends on Surefire moving first. CliConfigurerParityTest compares the state both paths produce, field by field, because nothing else keeps the frozen copy in sync with the live one. testng-test-kit becomes the shared test-fixture library, so the 22 tests whose subject is the command line could move to testng-jcommander. The 243 classes extending SimpleBaseTest are unaffected. The two modules are deliberately not published on their own, and are kept out of the BOM for the same reason: that would ship org.testng.cli.* and its service registration in two artifacts at once. It is a packaging change for the next major, tracked in testng-team#3301. Supersedes testng-team#2612.
|
superseed by #3307 |
testng-core depended on org.jcommander:jcommander in `api` scope, so every consumer got the parsing library whether or not it drove TestNG from a command line. The coupling ran deep: CommandLineArgs was a @Parameter-annotated POJO, TestNG held a static JCommander field, and TestNG.configure(CommandLineArgs) mixed applying configuration with CLI-only string-to-object conversion. The front end now lives in two new modules: testng-cli CliOptions, CliConfigurer, AbstractCliRunner - no parser testng-jcommander the JCommander implementation, plus Converter testng-core keeps a minimal ServiceLoader SPI, ITestNGCliRunner, so that "java -cp testng.jar org.testng.TestNG suite.xml" is unchanged: both modules are bundled into the merged jar. Implementations never terminate the JVM - an unusable command line comes back as a TestNGException, and only TestNG.main turns it into a message, a usage banner and exit code 1. TestNG.setThreadCount now raises a TestNGException below 1 instead of printing the usage banner and calling System.exit(1), so that no library setter can kill an embedder's JVM. The command line output is unchanged: TestNG.main turns that exception into the same message and the same exit code. Backward compatibility for 7.x is kept through frozen @deprecated shims: CommandLineArgs (annotations stripped), TestNG.configure(CommandLineArgs), TestNG.validateCommandLineParameters, TestNG.main and TestNG.privateMain. TestNG.configure(Map), the method Maven Surefire calls, still builds a CommandLineArgs, so removing that class depends on Surefire moving first. CliConfigurerParityTest compares the state both paths produce, field by field, because nothing else keeps the frozen copy in sync with the live one. testng-test-kit becomes the shared test-fixture library, so the 22 tests whose subject is the command line could move to testng-jcommander. The 243 classes extending SimpleBaseTest are unaffected. The two modules are deliberately not published on their own, and are kept out of the BOM for the same reason: that would ship org.testng.cli.* and its service registration in two artifacts at once. It is a packaging change for the next major, tracked in testng-team#3301. Supersedes testng-team#2612.
testng-core depended on org.jcommander:jcommander in `api` scope, so every consumer got the parsing library whether or not it drove TestNG from a command line. The coupling ran deep: CommandLineArgs was a @Parameter-annotated POJO, TestNG held a static JCommander field, and TestNG.configure(CommandLineArgs) mixed applying configuration with CLI-only string-to-object conversion. The front end now lives in two new modules: testng-cli CliOptions, CliConfigurer, AbstractCliRunner - no parser testng-jcommander the JCommander implementation, plus Converter testng-core keeps a minimal ServiceLoader SPI, ITestNGCliRunner, so that "java -cp testng.jar org.testng.TestNG suite.xml" is unchanged: both modules are bundled into the merged jar. Implementations never terminate the JVM - an unusable command line comes back as a TestNGException, and only TestNG.main turns it into a message, a usage banner and exit code 1. TestNG.setThreadCount now raises a TestNGException below 1 instead of printing the usage banner and calling System.exit(1), so that no library setter can kill an embedder's JVM. The command line output is unchanged: TestNG.main turns that exception into the same message and the same exit code. Backward compatibility for 7.x is kept through frozen @deprecated shims: CommandLineArgs (annotations stripped), TestNG.configure(CommandLineArgs), TestNG.validateCommandLineParameters, TestNG.main and TestNG.privateMain. TestNG.configure(Map), the method Maven Surefire calls, still builds a CommandLineArgs, so removing that class depends on Surefire moving first. CliConfigurerParityTest compares the state both paths produce, field by field, because nothing else keeps the frozen copy in sync with the live one. testng-test-kit becomes the shared test-fixture library, so the 22 tests whose subject is the command line could move to testng-jcommander. The 243 classes extending SimpleBaseTest are unaffected. The two modules are deliberately not published on their own, and are kept out of the BOM for the same reason: that would ship org.testng.cli.* and its service registration in two artifacts at once. It is a packaging change for the next major, tracked in testng-team#3301. Supersedes testng-team#2612.
Did you remember to?
CHANGES.txthttps://github.com/remkop/picocli is the new defacto library for CLI.
Even if there is no plan to change the default implementation, JCommander was deeply linked.
The goal of this PR is to remove the strong dependency to JCommander.