-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show output from before System.exit(5) was called
- Loading branch information
Showing
7 changed files
with
275 additions
and
14 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
14 changes: 14 additions & 0 deletions
14
src/test-functional/resources/sample-spock-tests-system-exit/build.gradle
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,14 @@ | ||
plugins { | ||
id 'groovy' | ||
id 'com.adarshr.test-logger' | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testCompile 'org.codehaus.groovy:groovy-all:2.4.12' | ||
testCompile 'org.spockframework:spock-core:1.1-groovy-2.4' | ||
} |
73 changes: 73 additions & 0 deletions
73
...esources/sample-spock-tests-system-exit/src/test/groovy/com/adarshr/test/FirstSpec.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,73 @@ | ||
package com.adarshr.test | ||
|
||
import spock.lang.Ignore | ||
import spock.lang.Narrative | ||
import spock.lang.Specification | ||
import spock.lang.Stepwise | ||
|
||
import java.security.Permission | ||
|
||
@Stepwise | ||
@Narrative('Test that calls System.exit from setup method') | ||
class FirstSpec extends Specification { | ||
|
||
def setupSpec() { | ||
println "${getClass().simpleName} - stdout setupSpec" | ||
System.err.println "${getClass().simpleName} - stderr setupSpec" | ||
|
||
System.securityManager = new SecurityManager() { | ||
|
||
@Override | ||
void checkPermission(Permission perm) { | ||
} | ||
|
||
@Override | ||
void checkPermission(Permission perm, Object context) { | ||
} | ||
|
||
@Override | ||
void checkExit(int status) { | ||
// throw new IllegalStateException("System exit requested with error $status") | ||
} | ||
} | ||
} | ||
|
||
def cleanupSpec() { | ||
println "${getClass().simpleName} - stdout cleanupSpec" | ||
System.err.println "${getClass().simpleName} - stderr cleanupSpec" | ||
} | ||
|
||
def setup() { | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout setup" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr setup" | ||
|
||
System.exit(5) | ||
} | ||
|
||
def cleanup() { | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout cleanup" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr cleanup" | ||
} | ||
|
||
def "this test should pass"() { | ||
expect: | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout expect" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr expect" | ||
1 == 1 | ||
} | ||
|
||
def "this test should fail"() { | ||
expect: | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout expect" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr expect" | ||
1 == 2 | ||
} | ||
|
||
@Ignore | ||
def "this test should be skipped"() { | ||
expect: | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout expect" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr expect" | ||
1 == 2 | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...sources/sample-spock-tests-system-exit/src/test/groovy/com/adarshr/test/SecondSpec.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,73 @@ | ||
package com.adarshr.test | ||
|
||
import spock.lang.Ignore | ||
import spock.lang.Narrative | ||
import spock.lang.Specification | ||
import spock.lang.Stepwise | ||
|
||
import java.security.Permission | ||
|
||
@Stepwise | ||
@Narrative('Test that calls System.exit from setupSpec method') | ||
class SecondSpec extends Specification { | ||
|
||
def setupSpec() { | ||
println "${getClass().simpleName} - stdout setupSpec" | ||
System.err.println "${getClass().simpleName} - stderr setupSpec" | ||
|
||
System.securityManager = new SecurityManager() { | ||
|
||
@Override | ||
void checkPermission(Permission perm) { | ||
} | ||
|
||
@Override | ||
void checkPermission(Permission perm, Object context) { | ||
} | ||
|
||
@Override | ||
void checkExit(int status) { | ||
// throw new IllegalStateException("System exit requested with error $status") | ||
} | ||
} | ||
|
||
System.exit(5) | ||
} | ||
|
||
def cleanupSpec() { | ||
println "${getClass().simpleName} - stdout cleanupSpec" | ||
System.err.println "${getClass().simpleName} - stderr cleanupSpec" | ||
} | ||
|
||
def setup() { | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout setup" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr setup" | ||
} | ||
|
||
def cleanup() { | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout cleanup" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr cleanup" | ||
} | ||
|
||
def "this test should pass"() { | ||
expect: | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout expect" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr expect" | ||
1 == 1 | ||
} | ||
|
||
def "this test should fail"() { | ||
expect: | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout expect" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr expect" | ||
1 == 2 | ||
} | ||
|
||
@Ignore | ||
def "this test should be skipped"() { | ||
expect: | ||
println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stdout expect" | ||
System.err.println "${getClass().simpleName} - ${specificationContext.currentFeature.name} - stderr expect" | ||
1 == 2 | ||
} | ||
} |
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