forked from eriwen/gradle-js-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making ignoreExitCode a configurable parameter
- Loading branch information
Jeff Storey
committed
Dec 14, 2012
1 parent
3767683
commit 4fc9fd3
Showing
2 changed files
with
84 additions
and
1 deletion.
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
81 changes: 81 additions & 0 deletions
81
src/test/groovy/com/eriwen/gradle/js/JsHintTaskTest.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,81 @@ | ||
package com.eriwen.gradle.js | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.process.internal.ExecException | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import org.junit.Rule | ||
import org.junit.rules.TemporaryFolder | ||
import spock.lang.Specification | ||
|
||
class JsHintTaskTest extends Specification { | ||
|
||
@Rule TemporaryFolder dir = new TemporaryFolder(); | ||
|
||
Project project = ProjectBuilder.builder().build() | ||
def task | ||
def src | ||
|
||
def setup() { | ||
project.apply(plugin: JsPlugin) | ||
task = project.tasks.jshint | ||
src = dir.newFolder() | ||
task.source = src | ||
task.dest = dir.newFile() | ||
} | ||
|
||
def "build ignores result by default"() { | ||
given: | ||
addValidFile() | ||
addInvalidFile() | ||
|
||
when: | ||
task.run(); | ||
|
||
|
||
then: | ||
notThrown ExecException | ||
} | ||
|
||
def "build passes with only valid files"() { | ||
given: | ||
task.ignoreExitCode = false; | ||
addValidFile() | ||
|
||
when: | ||
task.run(); | ||
|
||
then: | ||
notThrown ExecException | ||
} | ||
|
||
def "build fails with invalid files"() { | ||
given: | ||
task.ignoreExitCode = false; | ||
addValidFile() | ||
addInvalidFile() | ||
|
||
when: | ||
task.run(); | ||
|
||
then: | ||
ExecException e = thrown() | ||
} | ||
|
||
|
||
def addValidFile() { | ||
addFile("valid.js", "var a = 5;") | ||
} | ||
|
||
def addInvalidFile() { | ||
// no semicolon, jshint should fail | ||
addFile("invalid.js", "var a = 5") | ||
} | ||
|
||
def addFile(name,contents) { | ||
def file = new File(src,name) | ||
file << contents | ||
} | ||
|
||
} | ||
|
||
|