2015-04-18 15:21:34 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2020-10-02 13:05:50 +02:00
|
|
|
var lint = require("./lint");
|
2015-04-18 15:21:34 +02:00
|
|
|
|
2019-07-28 14:57:52 +02:00
|
|
|
var files = new (require('node-static').Server)();
|
2015-04-18 15:21:34 +02:00
|
|
|
|
|
|
|
var server = require('http').createServer(function (req, res) {
|
|
|
|
req.addListener('end', function () {
|
2019-07-28 14:57:52 +02:00
|
|
|
files.serve(req, res, function (err/*, result */) {
|
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}).resume();
|
2015-04-18 15:21:34 +02:00
|
|
|
}).addListener('error', function (err) {
|
|
|
|
throw err;
|
2020-10-02 13:05:50 +02:00
|
|
|
}).listen(3000,(async () => {
|
|
|
|
const puppeteer = require('puppeteer');
|
|
|
|
const browser = await puppeteer.launch({args: ["--no-sandbox", "--disable-setuid-sandbox"]})
|
|
|
|
const page = await browser.newPage()
|
|
|
|
page.on('console', msg => console.log("console:", msg.text()))
|
|
|
|
page.on('dialog', async dialog => {
|
|
|
|
console.log(dialog.message())
|
|
|
|
await dialog.dismiss()
|
|
|
|
})
|
|
|
|
page.evaluateOnNewDocument(() => window.automatedTests = true)
|
|
|
|
await page.goto('http://localhost:3000/test/index.html#' + (process.argv[2] || ""))
|
|
|
|
while(1) {
|
|
|
|
if (await page.evaluate(() => window.done)) break
|
|
|
|
await sleep(200)
|
|
|
|
}
|
|
|
|
let [failed, errors] = await page.evaluate(() => [window.failed, window.errored])
|
|
|
|
for (let error of errors) console.log(error)
|
|
|
|
console.log(await page.evaluate(() => document.getElementById('output').innerText + "\n" +
|
|
|
|
document.getElementById('status').innerText))
|
|
|
|
process.exit(failed > 0 || errors.length || !lint.ok ? 1 : 0)
|
|
|
|
await browser.close()
|
|
|
|
})())
|
|
|
|
|
|
|
|
function sleep(n) { return new Promise(acc => setTimeout(acc, n)) }
|