Created
December 10, 2017 19:43
-
-
Save aspiers/48ee0b98a91dac9eff7324bc1045036b to your computer and use it in GitHub Desktop.
CLI test runner for SuperCollider UnitTest tests
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
// Allow running tests from CLI. Example invocations: | |
// | |
// sclang unit-test.sc // runs all tests | |
// sclang unit-test.sc MyClass | |
// sclang unit-test.sc TestMyClass | |
// sclang unit-test.sc TestMyClass:test_my_method | |
// | |
// Multiple arguments are supported. | |
var excludes = [ | |
"MixedBundleTester", | |
"UnitTest", | |
"TestScript" | |
]; | |
t = Task.new { | |
if (thisProcess.argv.isEmpty) { | |
UnitTest.allSubclasses.do { |testClass| | |
if (excludes.includes(testClass.asString).not) { | |
testClass.run(false, false); | |
0.1.wait; | |
}; | |
UnitTest.report; | |
}; | |
} { | |
thisProcess.argv.do { |name| | |
case | |
{ name.contains(":") } { | |
UnitTest.runTest(name); | |
} | |
{ name.beginsWith("Test") } { | |
name.asSymbol.asClass.run; | |
} { | |
name.asSymbol.asClass.test; | |
}; | |
}; | |
}; | |
"Finished running test(s): % passes, % failures\n".postf( | |
UnitTest.passes.size, | |
UnitTest.failures.size | |
); | |
UnitTest.failures.size.exit; | |
}; | |
t.start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment