-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
173 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/groovy/nebula/test/functional/PreExecutionAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package nebula.test.functional; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* Executes actions before gradle is called. | ||
*/ | ||
public interface PreExecutionAction { | ||
void execute(File projectDir, List<String> arguments, List<String> jvmArguments); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package nebula.test | ||
|
||
|
||
import com.energizedwork.spock.extensions.TempDirectory | ||
|
||
class ChangingTestDirSpec extends IntegrationSpec { | ||
|
||
@TempDirectory(clean = false, baseDir = 'test/build1') File projectDir | ||
|
||
def 'can change name of project dir'() { | ||
expect: | ||
projectDir.absolutePath.contains('test/build1') | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/groovy/nebula/test/functional/internal/DefaultGradleRunnerSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package nebula.test.functional.internal | ||
|
||
|
||
import nebula.test.functional.PreExecutionAction | ||
import org.junit.Rule | ||
import org.junit.rules.TemporaryFolder | ||
import spock.lang.Specification | ||
|
||
class DefaultGradleRunnerSpec extends Specification { | ||
|
||
@Rule TemporaryFolder temporaryFolder | ||
|
||
def 'will execute actions before run is called'() { | ||
setup: | ||
def projectDir = temporaryFolder.newFolder() | ||
def handleFactory = Mock(GradleHandleFactory) | ||
def runner = new DefaultGradleRunner(handleFactory) | ||
|
||
when: | ||
runner.handle(projectDir, ['arg'], ['jvm'], [new WriteFileAction(projectDir)]) | ||
|
||
then: | ||
1 * handleFactory.start(projectDir, ['arg'], ['jvm']) | ||
} | ||
|
||
static class WriteFileAction implements PreExecutionAction { | ||
File expectedDir | ||
|
||
WriteFileAction(File expectedDir) { | ||
this.expectedDir = expectedDir | ||
} | ||
|
||
@Override | ||
void execute(File projectDir, List<String> arguments, List<String> jvmArguments) { | ||
assert expectedDir.absolutePath == projectDir.absolutePath | ||
|
||
assert arguments.size() == 1 | ||
assert arguments.first() == 'arg' | ||
|
||
assert jvmArguments.size() == 1 | ||
assert jvmArguments.first() == 'jvm' | ||
} | ||
} | ||
} |