!7 !include once #1021761 // Gazelle Fakery set flag DynModule. concept Test { S name, contents; long lastRun, runtime; bool success, anySuccess; } cmodule GazelleTests > DynCRUD { transient bool running; transient O[] flags = litparams( debugSorting := true, useRepeat_v2 := true); start { dm_useLocalMechListCopies(); crud.multiLineFields = litset('contents); } visualize { JComponent c = super.visualize(); addSelectionDependentButton("Run", r { doIt(selected().name) }); ret jvsplit(c, centerAndSouthWithMargin(dm_printLogComponent(), withMargin(jbutton("Run Tests", r runAll)))); } void runAll() { doIt(""); } void doIt(S testName) q { _doIt(testName); } void _doIt(S testName) { temp dm_tempSetField(running := true); clearPrintLog(); gazelle_performMultipleTests(mL_raw("Gazelle Tests"), paramsPlus(flags, performOnly := testName, testStarting := voidfunc(S name, S contents) { cset(uniq_sync Test(+name), lastRun := now(), +contents) }, testDone := voidfunc(S name, ErrorCounter scorer) { Test test = conceptWhere Test(+name); cset(test, runtime := now()-test.lastRun); cset(test, success := scorer.allCorrect()); if (test.success) cset(test, anySuccess := true); } )); } // API void runTestAndWait(S testName) { dm_runInQAndWait(r { _doIt(testName) }); } Pair countAndSuccesses() { ret pair(countConcepts(Test), countConceptsWhere(Test, success := true)); } }