Repository navigation
Conversation
|
@JakeWharton TestBalloon doesn't support JVM 8, and I raised an issue here: infix-de/testBalloon#97. In the interim, I am curious to know why we still support v8. |
|
There hasn't been a reason to drop it. We like compatibility. |
|
@JakeWharton The beta testballoon fixes the test. What are your thoughts on going with a beta version, though? |
|
Yep, that's fine. We can tolerate instability in test dependencies. |
| fun TestSuiteScope.testDirectory( | ||
| fileSystem: FileSystem, | ||
| temporaryDirectory: Path = FileSystem.SYSTEM_TEMPORARY_DIRECTORY, | ||
| ) = testFixture { fileSystem.createTestPath(temporaryDirectory) } |
There was a problem hiding this comment.
Does this get deleted after use? If not and if that makes sense, here is an example strategy.
There was a problem hiding this comment.
@OliverO2, thanks for the suggestion. I believe I tried that approach, but some tests were failing because of the recursive deletion, so I had to remove it. Or do you mean only deleting for non-CI builds?
There was a problem hiding this comment.
I was thinking of this as a general practice: I'd expect resources like temporary files/directories to have a lifetime tied to the scope (test suite) they are used in. A test fixture automatically takes care of this, closing its resource at the end of its TestSuiteScope.
This should work regardless of CI. The CI special case was just an example, where the contents of resources would only be examined locally (non-CI), and only for failing tests.
One thing I could imagine is: If you are using concurrent invocation and the same file path is used in concurrently executing suites, these could collide. Could this be the case?
There was a problem hiding this comment.
Seems like a bug in WasiFileSystem:
If I clean up the temporary directory like this:
fun TestSuiteScope.testDirectory(
fileSystem: FileSystem,
temporaryDirectory: Path = FileSystem.SYSTEM_TEMPORARY_DIRECTORY,
) = testFixture { fileSystem.createTestPath(temporaryDirectory) } closeWith {
fileSystem.deleteRecursively(this)
}the failing test is okio.WasiTest↘canonicalizeAbsolutePathWithSymlinkCycle.
This test creates a cycle of three symlinks. When trying to delete the parent directory via fileSystem.deleteRecursively(), the function WasiFileSystem.pathOpen gets called and tries to open one of the symlinks. This fails with errno 32 (loop).
Seems like there is no "follow symlinks" option in the functions that list directory entries. Maybe either pathOpen or the list function calling it should (conditionally) check for a symlink first before trying to open it. Otherwise, with a symlink cycle it is bound to fail as expected and fileSystem.deleteRecursively() can never succeed in this case.
Println debugging trace:
>>> commonDeleteRecursively on /tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4
>>> collectRecursively start: /tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4
>>> collectRecursively before children
>>> listOrNull(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4) start
>>> list(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4) start
>>> pathOpen(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4) start
>>> pathOpen(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4) path_open errno=0
>>> list(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4) after pathOpen
>>> list(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4) start
>>> list(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4): errno=0
>>> collectRecursively children: [/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/paper, /tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/rock, /tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/scissors]
>>> collectRecursively symlink: /tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4
>>> collectRecursively child: /tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/paper
>>> collectRecursively start: /tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/paper
>>> collectRecursively before children
>>> listOrNull(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/paper) start
>>> list(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/paper) start
>>> pathOpen(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/paper) start
>>> pathOpen(/tmp/test-f4e97d1653c0ae50da5d749cf8e8bcf4/paper) path_open errno=32
loop
ErrnoException: loop
There was a problem hiding this comment.
Interesting. I'd suggest we open a separate issue to investigate this. In the interim, I can bring back closeWith but disable folder deletion with a flag passed to testDirectory(). Then explicitly disable it for the failing test.
Thoughts? @JakeWharton @OliverO2
There was a problem hiding this comment.
Created #1874 and provided a fix in wilburx9#1.
Feel free to cherry-pick and/or change as required.
There was a problem hiding this comment.
A flag for now is fine, if only to get it landed sooner rather than later!
Fix lysine-dev#1874, use deleteRecursively to clean up TestSuiteScope.testDirectory
| val children = | ||
| (if (followSymlinks || fileSystem.metadataOrNull(path)?.symlinkTarget == null) { | ||
| fileSystem.listOrNull(path) | ||
| } else { | ||
| null | ||
| }) ?: listOf() |
There was a problem hiding this comment.
If we're going to fix this, which is fine, we should land it with its own test as a separate commit.
There was a problem hiding this comment.
Fair enough.
@OliverO2 Why don't I revert your fix, go with the flag I suggested earlier and you can raise the PR when this is merged? Thoughts?
There was a problem hiding this comment.
If you want to add a test and squash it all into two commits (first one with fix+test, second migrating the tests) that would be fine, too. I can do a merge without squash then.
There was a problem hiding this comment.
I agree that this bug deserves its own test. I can probably contribute one but need to familiarize myself with doing it at the common source set level first. Unfortunately, due to a packed schedule, that could happen no earlier than Oct 10.
There was a problem hiding this comment.
@wilburx9 I've created wilburx9#2 with a separate commit for the fix plus test to merge it here, along with thoughts on how to proceed. Let me know if you need anything else.
|
@wilburx9 Do you want to proceed with this? |
Migrated Burst to TestBalloon
Part 2 of #1846