[
https://issues.apache.org/jira/browse/RAT-594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148847#comment-18148847
]
ASF subversion and git services commented on RAT-594:
-----------------------------------------------------
Commit 11441a93fddbfa525e47272609a8e1f01e2914ee in creadur-rat's branch
refs/heads/feature/complexSPDXmatcherParsing from P. Ottlinger
[ https://gitbox.apache.org/repos/asf?p=creadur-rat.git;h=11441a93f ]
RAT-594: Change way Ant tests get their base directory managed (#778)
* RAT-594: Change way Ant tests get their base directory set during test runs
* RAT-594: Apply sonarcloud warning
> Ant-ReportTest failures an Jenkins/GHA actions - flaky directory setup?
> -----------------------------------------------------------------------
>
> Key: RAT-594
> URL: https://issues.apache.org/jira/browse/RAT-594
> Project: Apache RAT
> Issue Type: Bug
> Affects Versions: 0.18
> Reporter: Philipp Ottlinger
> Assignee: Philipp Ottlinger
> Priority: Major
> Fix For: 0.19
>
>
> We experience test failures on ASF Jenkins and sometimes on GH-nodes, that
> deal with missing /tmp/junit-something directories during test runs.
> *https://ci-builds.apache.org/job/Creadur/job/Creadur-Rat/lastBuild/testReport/junit/org.apache.rat.anttasks/ReportOptionTest/testOptionsUpdateConfig_String__OptionTest__10_/*
> *AntTask:edit-copyright: Unexpected exception thrown:
> org.apache.tools.ant.BuildException: Basedir /tmp/junit-1912989440169709496
> does not exist*
> h3. Likely cause
> In GeneratedReportTest.java:127
> (apache-rat-tasks/src/test/java/org/apache/rat/anttasks/GeneratedReportTest.java#L127),
> the test sets a JVM-wide Ant property:
> ```java
> System.setProperty(MagicNames.PROJECT_BASEDIR, documentName.getBaseName());
> ```
> Normally, that property is not restored afterward. Once JUnit deletes that
> test’s temporary directory, a later Ant project can inherit the stale basedir
> and fail exactly as shown.
> This also explains why the failure depends on the node or test execution
> order.
> h3. Small, preferable fix
> Configure the Ant project instance, not the JVM:
> ```java
> Project project = new Project();
> project.init();
> project.setBaseDir(antFile.getParentFile());
> ```
> In GeneratedReportTest.argumentTests(), this would replace the global
> System.setProperty(...) and make the conditional System.clearProperty(...)
> workaround unnecessary.
> There are similar global setters in:
> - HelpTest.setUp()
> - ReportTest.setUp()
> Those should also be changed to project-local configuration, or at least
> have their previous property values restored reliably.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)