Skip to content

Commit c7aa4fe

Browse files
committed
fix: make returned paths absolute (#29)
1 parent 82db746 commit c7aa4fe

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/kotlin/de/joshuagleitze/test/spek/testfiles/DefaultTestFiles.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class DefaultTestFiles internal constructor(): LifecycleListener, TestFiles {
141141
isDirectory(Paths.get("target")) -> Paths.get("target/test-outputs")
142142
isDirectory(Paths.get("test-outputs")) -> Paths.get("test-outputs")
143143
else -> Paths.get(System.getProperty("java.io.tmpdir")).resolve("spek-test-outputs")
144-
}
144+
}.toAbsolutePath()
145145

146146
private fun checkFileName(name: String) {
147147
require(!name.matches(Regex("^\\[.*]$"))) { "A test file name must not start with '[' and end with ']'! was: '$name'" }

src/main/kotlin/de/joshuagleitze/test/spek/testfiles/TestFiles.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import java.nio.file.Path
66
/**
77
* Helper that creates test files and directories for use in tests. The helper manages a directory structures that reflects the structure of
88
* the Spek tests. Created files and directories will reside in the part of the directory structure that corresponds to the current Spek
9-
* group or test. The helper also manages when to delete the created files, see [DeletionMode].
9+
* group or test. The helper also manages when to delete the created files.
10+
*
11+
* @see DeletionMode
1012
*/
1113
interface TestFiles {
1214
/**
1315
* Creates a test directory in the directory of the current Spek group or test.
1416
*
1517
* @param name The name of the directory. If omitted or `null`, the name will be generated.
1618
* @param delete When to delete the created directory, see [DeletionMode].
19+
* @return The absolute [Path] to the created directory.
1720
*/
1821
fun createDirectory(name: String? = null, delete: DeletionMode = IF_SUCCESSFUL): Path
1922

@@ -22,6 +25,7 @@ interface TestFiles {
2225
*
2326
* @param name The name of the file. If omitted or `null`, the name will be generated.
2427
* @param delete When to delete the created file, see [DeletionMode].
28+
* @return The absolute [Path] to the created file.
2529
*/
2630
fun createFile(name: String? = null, delete: DeletionMode = IF_SUCCESSFUL): Path
2731
}

0 commit comments

Comments
 (0)