Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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