[ 
https://issues.apache.org/jira/browse/RAT-594?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Philipp Ottlinger updated RAT-594:
----------------------------------
    Summary: Ant-ReporTest failures an Jenkins/GHA actions - flaky directory 
setup?  (was: Test failures an Jenkins/GHA actions - flaky directory setup?)

> Ant-ReporTest 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.
> 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)

Reply via email to