-
Couldn't load subscription status.
- Fork 76
[#441] Delete temporary folders on agent after coloring source code files #444
Conversation
Codecov Report
@@ Coverage Diff @@
## master #444 +/- ##
============================================
+ Coverage 72.18% 72.27% +0.08%
- Complexity 992 997 +5
============================================
Files 86 86
Lines 3700 3715 +15
Branches 433 434 +1
============================================
+ Hits 2671 2685 +14
- Misses 883 884 +1
Partials 146 146
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
| File temporaryDirectory = Paths.get("target", "tmp").toFile(); | ||
| assertThat(temporaryDirectory.exists()).isTrue(); | ||
| assertThat(temporaryDirectory.isDirectory()).isTrue(); | ||
| File[] temporaryFiles = temporaryDirectory.listFiles(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this directory? Does a test case store results there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the directory which is used as temporary directory /tmp within unit tests.
I check this directory in order to verify that painting source code does not store unused files there.
In this case, Files.createTempDirectory(...) uses this.
Nonetheless, I changed this line of code to make it more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, did you check that the test fails before you applied the fix (the RED during TDD?)? From my understanding, the directories will be part of the Jenkins agent file structure that does use a different directory.
(I think it would be sufficient that the logging statement ist present)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I did. I made the tests fail, then I inserted the new code and it worked. Also, I debugged it and even checked the directories while doing this to make sure these temporary folders are created exacly there.
Also as I understand it, Files.createTempDirectory(...) points to System.getProperty("java.io.tmpdir") by default, if it is not overwritten using a unit test rule e.g. - also see here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. All tests use the controller to execute the builds. (Only the docker based tests would use a temporary folder in the docker container).
Fix for issue #441:
Folders and files which are temporary created while painting the source code are removed after usage now.
I also added an additional assertion to verify that the created temporary directories and only these are deleted.