gradle-plugin, tests: Create directories in the 'createFile' method

This commit is contained in:
Ilya Matveev
2017-08-11 19:18:15 +07:00
committed by ilmat192
parent 50564803c2
commit 1d3e9a6ffa
2 changed files with 5 additions and 6 deletions
@@ -119,7 +119,6 @@ class IncrementalSpecification extends BaseKonanSpecification {
when:
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
it.generateSrcFile('main.kt')
it.createSubDir('src', 'foo', 'kotlin')
it.generateSrcFile(["src", "foo", "kotlin"], 'bar.kt', """
fun main(args: Array<String>) { println("Hello!") }
""".stripIndent())
@@ -137,7 +136,6 @@ class IncrementalSpecification extends BaseKonanSpecification {
when:
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
it.generateSrcFile('main.kt')
it.createSubDir('src', 'lib', 'kotlin')
it.generateSrcFile(["src", "lib", "kotlin"], "lib.kt", "fun bar() { println(\"Hello!\") }")
it.buildFile.append("""
konanArtifacts {
@@ -254,7 +252,6 @@ class IncrementalSpecification extends BaseKonanSpecification {
when:
def project = KonanInteropProject.createEmpty(projectDirectory) { KonanInteropProject it ->
it.generateSrcFile('main.kt')
it.createSubDir('src', 'lib', 'kotlin')
it.generateSrcFile(["src", "lib", "kotlin"], 'lib.kt', 'fun foo() { println(42) }')
it.buildFile.append("""
konanArtifacts {
@@ -59,7 +59,9 @@ class KonanProject {
/** Creates a file with the given content in project subdirectory specified by parentDirectory. */
File createFile(Path parentDirectory = projectPath, String fileName, String content) {
def result = projectPath.resolve(parentDirectory).resolve(fileName).toFile()
def parent = projectPath.resolve(parentDirectory)
Files.createDirectories(parent)
def result = parent.resolve(fileName).toFile()
result.createNewFile()
result.write(content)
return result
@@ -304,7 +306,7 @@ class KonanInteropProject extends KonanProject {
return result
}
/** Creates a project with the default build file and without any source or def files. */
/** Creates a project with the default build file, without any source and with an empty def file. */
static KonanInteropProject createEmpty(File projectDir) {
def result = new KonanInteropProject(projectDir)
result.with {
@@ -316,7 +318,7 @@ class KonanInteropProject extends KonanProject {
return result
}
/** Creates a project with the default build file and without any source or def files. */
/** Creates a project with the default build file, without any source and with an empty def file. */
static KonanInteropProject createEmpty(File projectDir, Closure config) {
def result = createEmpty(projectDir)
config(result)