Skip to content

Instantly share code, notes, and snippets.

@aspiers
Created December 10, 2017 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspiers/48ee0b98a91dac9eff7324bc1045036b to your computer and use it in GitHub Desktop.
Save aspiers/48ee0b98a91dac9eff7324bc1045036b to your computer and use it in GitHub Desktop.
CLI test runner for SuperCollider UnitTest tests
// 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