diff --git a/compiler/build.gradle b/compiler/build.gradle index 037f8515a..15093c8a8 100644 --- a/compiler/build.gradle +++ b/compiler/build.gradle @@ -70,7 +70,8 @@ sourceSets { } test { java { - srcDirs = ["${project.projectDir}/test"] + srcDir "${project.projectDir}/test" + srcDir "${project(':compilerAst').projectDir}/test/helpers" } } } diff --git a/compiler/test/Helpers.kt b/compiler/test/helpers/Helpers@compiler.kt similarity index 61% rename from compiler/test/Helpers.kt rename to compiler/test/helpers/Helpers@compiler.kt index 48f745b2d..85c1f5934 100644 --- a/compiler/test/Helpers.kt +++ b/compiler/test/helpers/Helpers@compiler.kt @@ -15,8 +15,6 @@ import prog8.compiler.CompilationResult import prog8.compiler.compileProgram import prog8.compiler.target.ICompilationTarget -// TODO: find a way to share with compilerAst/test/Helpers.kt, while still being able to amend it (-> compileFile(..)) - internal fun CompilationResult.assertSuccess(description: String = ""): CompilationResult { assertTrue(success, "expected successful compilation but failed $description") return this @@ -68,39 +66,6 @@ internal fun compileText( } - -val workingDir : Path = Path("").absolute() // Note: Path(".") does NOT work..! -val fixturesDir : Path = workingDir.resolve("test/fixtures") -val resourcesDir : Path = workingDir.resolve("res") -val outputDir : Path = workingDir.resolve("build/tmp/test") - -fun assumeReadable(path: Path) { - assertTrue(path.isReadable(), "sanity check: should be readable: ${path.absolute()}") -} - -fun assumeReadableFile(path: Path) { - assumeReadable(path) - assertTrue(path.isRegularFile(), "sanity check: should be normal file: ${path.absolute()}") -} - -fun assumeDirectory(path: Path) { - assertTrue(path.isDirectory(), "sanity check; should be directory: $path") -} - -fun assumeNotExists(path: Path) { - assertFalse(path.exists(), "sanity check: should not exist: ${path.absolute()}") -} - -fun sanityCheckDirectories(workingDirName: String? = null) { - if (workingDirName != null) - assertEquals(workingDirName, workingDir.fileName.toString(), "name of current working dir") - assumeDirectory(workingDir) - assumeDirectory(fixturesDir) - assumeDirectory(resourcesDir) - assumeDirectory(outputDir) -} - - fun mapCombinations(dim1: Iterable, dim2: Iterable, combine2: (A, B) -> R) = sequence { for (a in dim1) @@ -124,22 +89,3 @@ fun mapCombinations(dim1: Iterable, dim2: Iterable, dim3: for (d in dim4) yield(combine4(a, b, c, d)) }.toList() - - -val DummyFunctions = object : IBuiltinFunctions { - override val names: Set = emptySet() - override val purefunctionNames: Set = emptySet() - override fun constValue( - name: String, - args: List, - position: Position, - memsizer: IMemSizer - ): NumericLiteralValue? = null - - override fun returnType(name: String, args: MutableList) = InferredTypes.InferredType.unknown() -} - -val DummyMemsizer = object : IMemSizer { - override fun memorySize(dt: DataType): Int = 0 -} - diff --git a/compilerAst/test/Helpers.kt b/compilerAst/test/helpers/Helpers@compilerAst.kt similarity index 100% rename from compilerAst/test/Helpers.kt rename to compilerAst/test/helpers/Helpers@compilerAst.kt