2019-09-13 13:49:11 +02:00
|
|
|
import Promise from "bluebird"
|
|
|
|
|
import child_process, {spawn} from "child_process"
|
2021-06-04 16:25:42 +02:00
|
|
|
import {BuildServerClient} from "../buildSrc/BuildServerClient.js"
|
2019-09-13 13:49:11 +02:00
|
|
|
import flow from "flow-bin"
|
2021-06-04 16:25:42 +02:00
|
|
|
import path from "path"
|
2017-08-15 13:54:22 +02:00
|
|
|
|
2019-09-13 13:49:11 +02:00
|
|
|
let project
|
2017-08-15 13:54:22 +02:00
|
|
|
if (process.argv.indexOf("api") !== -1) {
|
|
|
|
|
project = "api"
|
|
|
|
|
} else if (process.argv.indexOf("client") !== -1) {
|
|
|
|
|
project = "client"
|
|
|
|
|
} else {
|
|
|
|
|
console.error("must provide 'api' or 'client' to run the tests")
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
2019-09-13 13:49:11 +02:00
|
|
|
const clean = process.argv.includes("-c")
|
|
|
|
|
|
|
|
|
|
spawn(flow, ["--quiet"], {stdio: "inherit"})
|
|
|
|
|
|
2021-06-04 16:25:42 +02:00
|
|
|
const buildServerClient = new BuildServerClient()
|
|
|
|
|
buildServerClient.buildWithServer({
|
2021-06-16 11:47:09 +02:00
|
|
|
forceRestart: clean,
|
2021-06-04 16:25:42 +02:00
|
|
|
builder: path.resolve("TestBuilder.js"),
|
|
|
|
|
watchFolders: [path.resolve("api"), path.resolve("client"), path.resolve("../src")],
|
2019-09-13 13:49:11 +02:00
|
|
|
buildOpts: {}
|
2021-06-04 16:25:42 +02:00
|
|
|
})
|
|
|
|
|
.then(
|
2019-09-13 13:49:11 +02:00
|
|
|
async () => {
|
|
|
|
|
console.log("build finished!")
|
|
|
|
|
const code = await runTest(project)
|
|
|
|
|
process.exit(code)
|
|
|
|
|
},
|
|
|
|
|
(e) => {
|
|
|
|
|
console.error("Build failed", e)
|
|
|
|
|
process.exit(1)
|
2017-08-15 13:54:22 +02:00
|
|
|
}
|
2019-09-13 13:49:11 +02:00
|
|
|
)
|
2017-08-15 13:54:22 +02:00
|
|
|
|
|
|
|
|
|
2019-09-13 13:49:11 +02:00
|
|
|
function runTest(project) {
|
|
|
|
|
return new Promise((resolve) => {
|
2021-01-25 12:50:28 +01:00
|
|
|
let testRunner = child_process.fork(`../build/test/bootstrapTests-${project}.js`)
|
2019-09-13 13:49:11 +02:00
|
|
|
testRunner.on('exit', (code) => {
|
|
|
|
|
resolve(code)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|