ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaikiran <...@git.apache.org>
Subject [GitHub] ant pull request #67: Support for fork mode in junitlauncher
Date Sun, 05 Aug 2018 13:43:20 GMT
GitHub user jaikiran opened a pull request:

    https://github.com/apache/ant/pull/67

    Support for fork mode in junitlauncher

    The commit here introduces support for launching the JUnit tests, through `junitlauncher`
task, in forked mode. 
    
    I decided to keep the fork aspects as a separate element instead of introducing multiple
attribtues that are only applicable in forked mode. As such, each `test` or `testclasses`
element of the `junitlauncher` task can now have a nested `fork` element indicating that those
tests need to be launced in a forked JVM. The characteristics of the forked JVM are determined
by the attribtues and nested elements of the `fork` element. 
    
    I have added support for most of the fork attribtues that are applicable for the legacy
junit task (I also checked the java task to make sure the JVM launching characteristics are
captured in the fork element's attributes). I am working on the manual updates to explain
this support so this PR doesn't include that part, but here's what it will end up looking
like:
    ```
    <junitlauncher>
            <classpath refid="test.classpath"/>
            <test name="org.example.junitlauncher.vintage.JUnit4SampleTest" outputdir="${output.dir}">
                
                <fork dir="${basedir}" timeout="..." 
                        includeJunitPlatformLibraries="..." 
                        includeAntRuntimeLibraries="...">
    
                	<sysproperty key="foo" value="bar"/>
                	...
                	<env key="hello" value="world"/>
                	...
                	<modulepath>
    		     <pathelement location="lib"/>
    		     <pathelement location="dist/foo.jar"/>
    		</modulepath>
    		...
                	<upgrademodulepath>
    		    <pathelement location="upgrades"/>
    		</upgrademodulepath>
                </fork>
                ...
                <listener type="legacy-xml" sendSysErr="true" sendSysOut="true"/>
                ...
            </test>
        </junitlauncher>
    ```
    From an implementation detail point of view, the core logic of launching the tests through
the JUnit platform remains intact (of course, the code itself has been moved into an internal
class to be shared in forked and non-forked mode). An internal contract `LaunchDefinition`
has been introduced so that the launching aspects can be captured in this interface. Non-forked
and forked mode execution will internally construct an instance of the `LaunchDefinition`.

    
    A `StandaloneLauncher` (an internal detail of this task) has been introduced to be the
entry point with a `main` method for forked mode execution. The responsibility of this class
is to parse the arguments and construct the `LaunchDefinition` and then just pass it over
to the `LauncherSupport` (interal impl detail). We pass around the launch definition to the
forked mode launcher in the form of an xml which captures the necessary details like what
tests to launch and what listeners to use. Note that this xml is an internal detail and can
change over releases. I decided to capture these details in a file and pass it to the `main`
method instead of passing mutliple different arguments for two reasons:
    
      - Reduce the command line length when executing these forked tests
      - Allow hierarchical representation of the launch definition details, like which listener
is for which test.
    
    I have tested the fork support manually, but this needs more automated tests. I'm in the
process of writing those tests and also updating the manual of this task. I wanted to get
any review comments on these changes in the meantime.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jaikiran/ant junit5-fork

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/ant/pull/67.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #67
    
----
commit bd6480fc6184da09546c441413038087b6df0ed3
Author: Jaikiran Pai <jaikiran@...>
Date:   2018-07-25T13:53:00Z

    Support for fork mode in junitlauncher

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message