Further experimentation
This commit is contained in:
parent
9c6822a1ac
commit
bfb16874b1
7 changed files with 284 additions and 87 deletions
111
test/TestAll.ts
111
test/TestAll.ts
|
@ -17,59 +17,66 @@ import ReplaceGeometrySpec from "./ReplaceGeometry.spec";
|
|||
import LegacyThemeLoaderSpec from "./LegacyThemeLoader.spec";
|
||||
|
||||
|
||||
ScriptUtils.fixUtils()
|
||||
const allTests = [
|
||||
new OsmObjectSpec(),
|
||||
new TagSpec(),
|
||||
new ImageAttributionSpec(),
|
||||
new GeoOperationsSpec(),
|
||||
new ThemeSpec(),
|
||||
new UtilsSpec(),
|
||||
new UnitsSpec(),
|
||||
new RelationSplitHandlerSpec(),
|
||||
new SplitActionSpec(),
|
||||
new TileFreshnessCalculatorSpec(),
|
||||
new WikidataSpecTest(),
|
||||
new ImageProviderSpec(),
|
||||
new ActorsSpec(),
|
||||
new ReplaceGeometrySpec(),
|
||||
new LegacyThemeLoaderSpec()
|
||||
]
|
||||
async function main() {
|
||||
|
||||
Utils.externalDownloadFunction = async (url) => {
|
||||
console.error("Fetching ", url, "blocked in tests, use Utils.injectJsonDownloadForTests")
|
||||
const data = await ScriptUtils.DownloadJSON(url)
|
||||
console.log("\n\n ----------- \nBLOCKED DATA\n Utils.injectJsonDownloadForTests(\n" +
|
||||
" ", JSON.stringify(url), ", \n",
|
||||
" ", JSON.stringify(data), "\n )\n------------------\n\n")
|
||||
throw "Detected internet access for URL " + url + ", please inject it with Utils.injectJsonDownloadForTests"
|
||||
}
|
||||
ScriptUtils.fixUtils()
|
||||
const allTests = [
|
||||
new OsmObjectSpec(),
|
||||
new TagSpec(),
|
||||
new ImageAttributionSpec(),
|
||||
new GeoOperationsSpec(),
|
||||
new ThemeSpec(),
|
||||
new UtilsSpec(),
|
||||
new UnitsSpec(),
|
||||
new RelationSplitHandlerSpec(),
|
||||
new SplitActionSpec(),
|
||||
new TileFreshnessCalculatorSpec(),
|
||||
new WikidataSpecTest(),
|
||||
new ImageProviderSpec(),
|
||||
new ActorsSpec(),
|
||||
new ReplaceGeometrySpec(),
|
||||
new LegacyThemeLoaderSpec()
|
||||
]
|
||||
|
||||
let args = [...process.argv]
|
||||
args.splice(0, 2)
|
||||
args = args.map(a => a.toLowerCase())
|
||||
|
||||
const allFailures: { testsuite: string, name: string, msg: string } [] = []
|
||||
let testsToRun = allTests
|
||||
if (args.length > 0) {
|
||||
args = args.map(a => a.toLowerCase())
|
||||
testsToRun = allTests.filter(t => args.indexOf(t.name.toLowerCase()) >= 0)
|
||||
}
|
||||
|
||||
if (testsToRun.length == 0) {
|
||||
throw "No tests found. Try one of " + allTests.map(t => t.name).join(", ")
|
||||
}
|
||||
|
||||
for (let i = 0; i < testsToRun.length; i++) {
|
||||
const test = testsToRun[i];
|
||||
console.log(" Running test", i, "/", testsToRun.length, test.name)
|
||||
allFailures.push(...(test.Run() ?? []))
|
||||
console.log("OK!")
|
||||
}
|
||||
if (allFailures.length > 0) {
|
||||
for (const failure of allFailures) {
|
||||
console.error(" !! " + failure.testsuite + "." + failure.name + " failed due to: " + failure.msg)
|
||||
Utils.externalDownloadFunction = async (url) => {
|
||||
console.error("Fetching ", url, "blocked in tests, use Utils.injectJsonDownloadForTests")
|
||||
const data = await ScriptUtils.DownloadJSON(url)
|
||||
console.log("\n\n ----------- \nBLOCKED DATA\n Utils.injectJsonDownloadForTests(\n" +
|
||||
" ", JSON.stringify(url), ", \n",
|
||||
" ", JSON.stringify(data), "\n )\n------------------\n\n")
|
||||
throw "Detected internet access for URL " + url + ", please inject it with Utils.injectJsonDownloadForTests"
|
||||
}
|
||||
throw "Some test failed"
|
||||
|
||||
let args = [...process.argv]
|
||||
args.splice(0, 2)
|
||||
args = args.map(a => a.toLowerCase())
|
||||
|
||||
const allFailures: { testsuite: string, name: string, msg: string } [] = []
|
||||
let testsToRun = allTests
|
||||
if (args.length > 0) {
|
||||
args = args.map(a => a.toLowerCase())
|
||||
testsToRun = allTests.filter(t => args.indexOf(t.name.toLowerCase()) >= 0)
|
||||
}
|
||||
|
||||
if (testsToRun.length == 0) {
|
||||
throw "No tests found. Try one of " + allTests.map(t => t.name).join(", ")
|
||||
}
|
||||
|
||||
for (let i = 0; i < testsToRun.length; i++) {
|
||||
const test = testsToRun[i];
|
||||
console.log(" Running test", i, "/", testsToRun.length, test.name)
|
||||
|
||||
allFailures.push(...(await test.Run() ?? []))
|
||||
console.log("OK!")
|
||||
}
|
||||
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: ", testsToRun.map(t => t.name).join(", "))
|
||||
|
||||
}
|
||||
console.log("All tests successful: ", testsToRun.map(t => t.name).join(", "))
|
||||
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue