Ticket #16567: 16567.11.patch

File 16567.11.patch, 12.9 KB (added by taylor.smock, 4 years ago)

Fix ant test-perf (failing since the jacoco agent was added, even when coverage was disabled)

  • .classpath

     
    2222                        <attribute name="test" value="true"/>
    2323                </attributes>
    2424        </classpathentry>
    25         <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4">
     25        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
    2626                <attributes>
    2727                        <attribute name="test" value="true"/>
    2828                </attributes>
    2929        </classpathentry>
    30         <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=JOSM&amp;ivyXmlPath=ivy.xml&amp;confs=*&amp;ivySettingsPath=ivysettings.xml&amp;loadSettingsOnDemand=false&amp;ivyUserDir=&amp;propertyFiles="/>
     30        <classpathentry exported="true" kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=JOSM&amp;ivyXmlPath=ivy.xml&amp;confs=*&amp;ivySettingsPath=ivysettings.xml&amp;loadSettingsOnDemand=false&amp;ivyUserDir=&amp;propertyFiles="/>
    3131        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
    3232                <attributes>
    3333                        <attribute name="module" value="true"/>
  • build.xml

     
    447447        <attribute name="excludes" default="${default-junit@{testITsuffix}-excludes}"/>
    448448        <sequential>
    449449            <echo message="Running @{testfamily}@{testITsuffix} tests with JUnit"/>
    450             <jacoco:coverage destfile="${test.dir}/jacoco@{testITsuffix}.exec" enabled="@{coverage}" includes="${jacoco.includes}"
    451                 inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}">
    452                 <junit printsummary="${junit.printsummary}" fork="true" forkmode="once" failureproperty="test.@{testfamily}@{testITsuffix}.failed">
    453                     <jvmarg value="-Dfile.encoding=UTF-8"/>
    454                     <jvmarg value="-javaagent:${test.dir}/lib/jmockit.jar"/>
    455                     <jvmarg value="--add-modules" if:set="isJava9" unless:set="isJava11" />
    456                     <jvmarg value="java.activation,java.se.ee" if:set="isJava9" unless:set="isJava11" />
    457                     <jvmarg value="--add-exports" if:set="isJava9" unless:set="noJavaFX" />
    458                     <jvmarg value="javafx.graphics/com.sun.javafx.application=ALL-UNNAMED" if:set="isJava9" unless:set="noJavaFX" />
    459                     <jvmarg value="--add-exports" if:set="isJava9" unless:set="isJava11" />
    460                     <jvmarg value="jdk.deploy/com.sun.deploy.config=ALL-UNNAMED" if:set="isJava9" unless:set="isJava11" />
    461                     <jvmarg value="--add-opens" if:set="isJava9" />
    462                     <jvmarg value="java.base/java.io=ALL-UNNAMED" if:set="isJava9" />
    463                     <jvmarg value="--add-opens" if:set="isJava9" />
    464                     <jvmarg value="java.base/java.lang=ALL-UNNAMED" if:set="isJava9" />
    465                     <jvmarg value="--add-opens" if:set="isJava9" />
    466                     <jvmarg value="java.base/java.nio=ALL-UNNAMED" if:set="isJava9" />
    467                     <jvmarg value="--add-opens" if:set="isJava9" />
    468                     <jvmarg value="java.base/java.text=ALL-UNNAMED" if:set="isJava9" />
    469                     <jvmarg value="--add-opens" if:set="isJava9" />
    470                     <jvmarg value="java.base/java.util=ALL-UNNAMED" if:set="isJava9" />
    471                     <jvmarg value="--add-opens" if:set="isJava9" />
    472                     <jvmarg value="java.base/jdk.internal.loader=ALL-UNNAMED" if:set="isJava9" />
    473                     <jvmarg value="--add-opens" if:set="isJava9" />
    474                     <jvmarg value="java.desktop/java.awt=ALL-UNNAMED" if:set="isJava9" />
    475                     <sysproperty key="josm.home" value="${test.dir}/config/@{testfamily}-josm.home"/>
    476                     <sysproperty key="josm.test.data" value="${test.dir}/data"/>
    477                     <sysproperty key="java.awt.headless" value="${test.headless}"/>
    478                     <sysproperty key="glass.platform" value="Monocle"/>
    479                     <sysproperty key="monocle.platform" value="Headless"/>
    480                     <sysproperty key="prism.order" value="sw"/>
    481                     <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
    482                     <classpath>
    483                         <path refid="test.classpath"/>
    484                         <pathelement path="${test.dir}/build/unit"/>
    485                         <pathelement path="${test.dir}/build/@{testfamily}"/>
    486                         <pathelement path="${test.dir}/config"/>
    487                     </classpath>
    488                     <formatter type="plain"/>
    489                     <formatter type="xml"/>
    490                     <batchtest fork="yes" todir="${test.dir}/report">
    491                         <fileset dir="${test.dir}/build/@{testfamily}" includes="@{includes}" excludes="@{excludes}"/>
    492                     </batchtest>
    493                 </junit>
    494             </jacoco:coverage>
     450            <jacoco:agent destfile="${test.dir}/jacoco@{testITsuffix}.exec" enabled="@{coverage}" includes="${jacoco.includes}" dumponexit="true"
     451                    inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}" property="jacocoagent@{testfamily}@{testITsuffix}" if:true="@{coverage}"/>
     452            <junitlauncher printsummary="${junit.printsummary}" failureproperty="test.@{testfamily}@{testITsuffix}.failed">
     453                <classpath>
     454                    <path refid="test.classpath"/>
     455                    <pathelement path="${test.dir}/build/unit"/> <!-- required for functional/etc to have JOSMTestRules -->
     456                    <pathelement path="${test.dir}/build/@{testfamily}"/>
     457                </classpath>
     458                <testclasses outputDir="${test.dir}/report">
     459                    <fileset dir="${test.dir}/build/@{testfamily}" includes="@{includes}" excludes="@{excludes}"/>
     460                        <fork>
     461                            <jvmarg value="${jacocoagent@{testfamily}@{testITsuffix}}" if:set="jacocoagent@{testfamily}@{testITsuffix}" />
     462                            <jvmarg value="-Dfile.encoding=UTF-8"/>
     463                            <jvmarg value="-javaagent:${test.dir}/lib/jmockit.jar"/>
     464                            <jvmarg value="--add-modules" if:set="isJava9" unless:set="isJava11" />
     465                            <jvmarg value="java.activation,java.se.ee" if:set="isJava9" unless:set="isJava11" />
     466                            <jvmarg value="--add-exports" if:set="isJava9" unless:set="noJavaFX" />
     467                            <jvmarg value="javafx.graphics/com.sun.javafx.application=ALL-UNNAMED" if:set="isJava9" unless:set="noJavaFX" />
     468                            <jvmarg value="--add-exports" if:set="isJava9" unless:set="isJava11" />
     469                            <jvmarg value="jdk.deploy/com.sun.deploy.config=ALL-UNNAMED" if:set="isJava9" unless:set="isJava11" />
     470                            <jvmarg value="--add-opens" if:set="isJava9" />
     471                            <jvmarg value="java.base/java.io=ALL-UNNAMED" if:set="isJava9" />
     472                            <jvmarg value="--add-opens" if:set="isJava9" />
     473                            <jvmarg value="java.base/java.lang=ALL-UNNAMED" if:set="isJava9" />
     474                            <jvmarg value="--add-opens" if:set="isJava9" />
     475                            <jvmarg value="java.base/java.nio=ALL-UNNAMED" if:set="isJava9" />
     476                            <jvmarg value="--add-opens" if:set="isJava9" />
     477                            <jvmarg value="java.base/java.text=ALL-UNNAMED" if:set="isJava9" />
     478                            <jvmarg value="--add-opens" if:set="isJava9" />
     479                            <jvmarg value="java.base/java.util=ALL-UNNAMED" if:set="isJava9" />
     480                            <jvmarg value="--add-opens" if:set="isJava9" />
     481                            <jvmarg value="java.base/jdk.internal.loader=ALL-UNNAMED" if:set="isJava9" />
     482                            <jvmarg value="--add-opens" if:set="isJava9" />
     483                            <jvmarg value="java.desktop/java.awt=ALL-UNNAMED" if:set="isJava9" />
     484                            <sysproperty key="josm.home" value="${test.dir}/config/@{testfamily}-josm.home"/>
     485                            <sysproperty key="josm.test.data" value="${test.dir}/data"/>
     486                            <sysproperty key="java.awt.headless" value="${test.headless}"/>
     487                            <sysproperty key="glass.platform" value="Monocle"/>
     488                            <sysproperty key="monocle.platform" value="Headless"/>
     489                            <sysproperty key="prism.order" value="sw"/>
     490                            <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
     491                        </fork>
     492                    <listener type="legacy-plain" />
     493                    <listener type="legacy-xml" />
     494                </testclasses>
     495            </junitlauncher>
    495496        </sequential>
    496497    </macrodef>
    497498    <target name="test" depends="test-compile" unless="test.notRequired"
     
    603604
    604605        # Keep serialization code
    605606        -keepclassmembers class * implements java.io.Serializable {
    606             static final long serialVersionUID; 
     607            static final long serialVersionUID;
    607608            private static final java.io.ObjectStreamField[] serialPersistentFields;
    608609            private void writeObject(java.io.ObjectOutputStream);
    609610            private void readObject(java.io.ObjectInputStream);
    610             java.lang.Object writeReplace(); 
     611            java.lang.Object writeReplace();
    611612            java.lang.Object readResolve();
    612613        }
    613614
  • ivy.xml

     
    5858        </dependency>
    5959        <dependency conf="test->default" org="com.github.tomakehurst" name="wiremock" rev="2.26.3"/>
    6060        <dependency conf="test->default" org="io.github.classgraph" name="classgraph" rev="4.8.67"/>
    61         <dependency conf="test->default" org="junit" name="junit" rev="4.12"/>
     61        <dependency conf="test->default" org="org.junit.platform" name="junit-platform-launcher" rev="1.6.2"/>
     62        <dependency conf="test->default" org="org.junit.vintage" name="junit-vintage-engine" rev="5.6.2"/>
     63        <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-api" rev="5.6.2"/>
     64        <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-engine" rev="5.6.2"/>
     65        <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-migrationsupport" rev="5.6.2"/>
    6266        <dependency conf="test->default" org="net.trajano.commons" name="commons-testing" rev="2.1.0"/>
    6367        <dependency conf="test->default" org="nl.jqno.equalsverifier" name="equalsverifier" rev="3.1.13"/>
    6468        <dependency conf="test->default" org="org.apache.commons" name="commons-lang3" rev="3.10"/>
  • test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

     
    2323import java.util.logging.Handler;
    2424
    2525import org.awaitility.Awaitility;
     26import org.junit.jupiter.api.extension.AfterEachCallback;
     27import org.junit.jupiter.api.extension.BeforeEachCallback;
     28import org.junit.jupiter.api.extension.ExtensionContext;
    2629import org.junit.rules.TemporaryFolder;
    2730import org.junit.rules.TestRule;
    2831import org.junit.runner.Description;
     
    7881 *
    7982 * @author Michael Zangl
    8083 */
    81 public class JOSMTestRules implements TestRule {
     84public class JOSMTestRules implements TestRule, AfterEachCallback, BeforeEachCallback {
    8285    private int timeout = isDebugMode() ? -1 : 10 * 1000;
    8386    private TemporaryFolder josmHome;
    8487    private boolean usePreferences = false;
     
    432435        return statement;
    433436    }
    434437
     438    @Override
     439    public void beforeEach(ExtensionContext context) throws Exception {
     440        Statement temporaryStatement = new Statement() {
     441            @Override
     442            public void evaluate() throws Throwable {
     443                // do nothing
     444            }
     445        };
     446        try {
     447            this.apply(temporaryStatement,
     448                    Description.createTestDescription(this.getClass(), "JOSMTestRules JUnit5 Compatibility"))
     449                    .evaluate();
     450        } catch (Throwable e) {
     451            throw new Exception(e);
     452        }
     453    }
     454
     455    @Override
     456    public void afterEach(ExtensionContext context) throws Exception {
     457        // do nothing for now
     458    }
     459
    435460    /**
    436461     * Set up before running a test
    437462     * @throws InitializationError If an error occurred while creating the required environment.
     
    548573        }
    549574
    550575        if (territories) {
    551             Territories.initializeInternalData();
     576            Territories.initialize();
    552577        }
    553578
    554579        if (this.edtAssertionMockingRunnable != null) {