Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
Change-Id: I7a0fa2582595f3f7aa8be1c52e757f47c9319892
  • Loading branch information
ngyukman committed Jun 10, 2019
1 parent 16ed7aa commit 6faf209
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/groovy/com/ullink/Ikvm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Ikvm extends DefaultTask {
}

File resolveIkvmHome() {
def home = getIkvmHome()
def home = ikvmHome.get()
URL url
if (home instanceof URL)
url = (URL)home
Expand Down
26 changes: 20 additions & 6 deletions src/test/groovy/com/ullink/IkvmPluginTest.groovy
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.ullink

import org.gradle.api.tasks.bundling.Jar

import static org.junit.Assert.*
import org.gradle.api.Project
import org.gradle.api.tasks.bundling.Jar
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder

import static org.junit.Assert.*

class IkvmPluginTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder()

@Test
void ikvmPluginAddsIkvmTasksToProject() {
Project project = ProjectBuilder.builder().build()
Expand All @@ -17,7 +22,7 @@ class IkvmPluginTest {
project.ikvm {
ikvmHome = 'abc'
}
assertEquals('abc', project.tasks.ikvm.ikvmHome)
assertEquals('abc', project.tasks.ikvm.ikvmHome.get())
}

@Test
Expand All @@ -36,7 +41,7 @@ class IkvmPluginTest {
baseName = 'foo'
}
project.ikvm {
jars = [ project.otherJar.archivePath ]
jars = [ project.otherJar.archiveFile.get() ]
}
project.evaluate()
assertFalse(project.ikvm.dependsOn.contains(project.jar))
Expand All @@ -45,9 +50,18 @@ class IkvmPluginTest {

@Test
void commandLineContainsJar() {
def home = temporaryFolder.newFolder()
new File(home, 'bin').mkdir()
new File(home, 'bin/ikvmc.exe').createNewFile()

Project project = ProjectBuilder.builder().build()
project.apply plugin: 'ikvm'
project.ikvm {
ikvmHome = home.path
}

def cmd = project.ikvm.commandLineArgs
assertTrue(cmd.contains(project.jar.archivePath))
def jarFile = project.jar.archiveFile.get().toString()
assertTrue(cmd.contains(jarFile))
}
}

0 comments on commit 6faf209

Please sign in to comment.