forked from MapComplete/MapComplete
More work on splitting roads, WIP; refactoring tests
This commit is contained in:
parent
e374bb355c
commit
1f93923820
62 changed files with 1163 additions and 823 deletions
|
@ -1,36 +1,16 @@
|
|||
import {Utils} from "../Utils";
|
||||
Utils.runningFromConsole = true;
|
||||
import TagSpec from "./Tag.spec";
|
||||
import ImageAttributionSpec from "./ImageAttribution.spec";
|
||||
import GeoOperationsSpec from "./GeoOperations.spec";
|
||||
import ImageSearcherSpec from "./ImageSearcher.spec";
|
||||
import ThemeSpec from "./Theme.spec";
|
||||
import UtilsSpec from "./Utils.spec";
|
||||
import OsmConnectionSpec from "./OsmConnection.spec";
|
||||
import T from "./TestHelper";
|
||||
import {FixedUiElement} from "../UI/Base/FixedUiElement";
|
||||
import Combine from "../UI/Base/Combine";
|
||||
import OsmObjectSpec from "./OsmObject.spec";
|
||||
import ScriptUtils from "../scripts/ScriptUtils";
|
||||
import UnitsSpec from "./Units.spec";
|
||||
import RelationSplitHandlerSpec from "./RelationSplitHandler.spec";
|
||||
|
||||
|
||||
|
||||
export default class TestAll {
|
||||
private needsBrowserTests: T[] = [new OsmConnectionSpec()]
|
||||
|
||||
public testAll(): void {
|
||||
Utils.runningFromConsole = false
|
||||
for (const test of this.needsBrowserTests.concat(allTests)) {
|
||||
if (test.failures.length > 0) {
|
||||
new Combine([new FixedUiElement("TEST FAILED: " + test.name).SetStyle("background: red"),
|
||||
...test.failures])
|
||||
.AttachTo("maindiv")
|
||||
throw "Some test failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ScriptUtils.fixUtils()
|
||||
const allTests = [
|
||||
new OsmObjectSpec(),
|
||||
|
@ -40,12 +20,34 @@ const allTests = [
|
|||
new ImageSearcherSpec(),
|
||||
new ThemeSpec(),
|
||||
new UtilsSpec(),
|
||||
new UnitsSpec()
|
||||
new UnitsSpec(),
|
||||
new RelationSplitHandlerSpec()
|
||||
]
|
||||
|
||||
let args = [...process.argv]
|
||||
args.splice(0, 2)
|
||||
args = args.map(a => a.toLowerCase())
|
||||
|
||||
for (const test of allTests) {
|
||||
if (test.failures.length > 0) {
|
||||
throw "Some test failed: " + test.failures.join(", ")
|
||||
const allFailures: { testsuite: string, name: string, msg: string } [] = []
|
||||
let testsToRun = allTests
|
||||
if (args.length > 0) {
|
||||
testsToRun = allTests.filter(t => args.indexOf(t.name) >= 0)
|
||||
}
|
||||
|
||||
if(testsToRun.length == 0){
|
||||
throw "No tests found"
|
||||
}
|
||||
|
||||
for (let i = 0; i < testsToRun.length; i++){
|
||||
const test = testsToRun[i];
|
||||
ScriptUtils.erasableLog(" Running test", i, "/", allTests.length)
|
||||
allFailures.push(...(test.Run() ?? []))
|
||||
|
||||
}
|
||||
if (allFailures.length > 0) {
|
||||
for (const failure of allFailures) {
|
||||
console.error(" !! " + failure.testsuite + "." + failure.name + " failed due to: " + failure.msg)
|
||||
}
|
||||
}
|
||||
throw "Some test failed"
|
||||
}
|
||||
console.log("All tests successful: ", allTests.map(t => t.name).join(", "))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue