-
Use tree-sitter-elm to get all the exposed functions from every test modules.
-
Create a main module a bit like this:
module Main exposing (main) import Platform import XXX.YYY import AAA.BBB -- etc findTest : String -> a -> () findTest = Debug.todo "replace me" main = let () = findTest "XXX.YYY.zzz1" XXX.YYY.zzz1 () = findTest "XXX.YYY.zzz2" XXX.YYY.zzz2 () = findTest "AAA.BBB.ccc" AAA.BBB.ccc () = findTest "AAA.BBB.ddd" AAA.BBB.ddd -- etc in Platform.woker { ... }
-
Compile that main module as an elm application.
-
Replace the generated js for
findTest
with a function that prints the elm identifier if the second argument is aTest
. -
Run the elm app and inspect the stdout to see all the tests.
The test custom type is defined elm-explorations:Test.Internal.Test
as follows:
type Test
= UnitTest (() -> List Expectation)
| FuzzTest (Random.Seed -> Int -> List Expectation)
| Labeled String Test
| Skipped Test
| Only Test
| Batch (List Test)
or when we have generated javascript:
var $elm_explorations$test$Test$Internal$UnitTest = function (a) {
return {$: 'UnitTest', a: a};
};
var $elm_explorations$test$Test$Internal$FuzzTest = function (a) {
return {$: 'FuzzTest', a: a};
};
var $elm_explorations$test$Test$Internal$Labeled = F2(
function (a, b) {
return {$: 'Labeled', a: a, b: b};
});
/* snip */
var $elm_explorations$test$Test$Runner$Skipping = function (a) {
return {$: 'Skipping', a: a};
};
First we want to insert the following near the top of the file:
var testSymbol = Symbol('testSymbol');
We want to do a find and replace on this js to instead get:
var $elm_explorations$test$Test$Internal$UnitTest = function (a) {
return {[testSymbol]: true, $: 'UnitTest', a: a};
};
var $elm_explorations$test$Test$Internal$FuzzTest = function (a) {
return {[testSymbol]: true, $: 'FuzzTest', a: a};
};
var $elm_explorations$test$Test$Internal$Labeled = F2(
function (a, b) {
return {[testSymbol]: true, $: 'Labeled', a: a, b: b};
});
/* snip */
var $elm_explorations$test$Test$Runner$Skipping = function (a) {
return {[testSymbol]: true, $: 'Skipping', a: a};
};
Then the findTests function can be:
var $author$project$Main$findTests = F2(
function (elmIndentifier, value) {
if (value[testSymbol]) {
console.log(elmIndentifier);
}
});