mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Change presentation of test suites in headless chrome runner
This commit is contained in:
parent
80194f054e
commit
519cd71636
|
@ -54,7 +54,6 @@ async function runAll() {
|
||||||
const {Page, Runtime} = client;
|
const {Page, Runtime} = client;
|
||||||
await Promise.all([Runtime.enable(), Page.enable()]);
|
await Promise.all([Runtime.enable(), Page.enable()]);
|
||||||
await Page.navigate({url: "about:blank"});
|
await Page.navigate({url: "about:blank"});
|
||||||
//await Page.loadEventFired();
|
|
||||||
|
|
||||||
const runner = new TestRunner(Page, Runtime);
|
const runner = new TestRunner(Page, Runtime);
|
||||||
await runner.runTests(rootSuite, "", 0);
|
await runner.runTests(rootSuite, "", 0);
|
||||||
|
@ -73,7 +72,6 @@ async function runAll() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const endTime = new Date().getTime();
|
const endTime = new Date().getTime();
|
||||||
console.log();
|
|
||||||
for (let i = 0; i < stats.testsFailed.length; i++) {
|
for (let i = 0; i < stats.testsFailed.length; i++) {
|
||||||
const failedTest = stats.testsFailed[i];
|
const failedTest = stats.testsFailed[i];
|
||||||
console.log("(" + (i + 1) + ") " + failedTest.path +":");
|
console.log("(" + (i + 1) + ") " + failedTest.path +":");
|
||||||
|
@ -82,7 +80,7 @@ async function runAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Tests run: " + stats.testRun + ", failed: " + stats.testsFailed.length
|
console.log("Tests run: " + stats.testRun + ", failed: " + stats.testsFailed.length
|
||||||
+ ", took " + (endTime - startTime) + " millisecond(s)");
|
+ ", elapsed " + ((endTime - startTime) / 1000) + " seconds");
|
||||||
|
|
||||||
if (stats.testsFailed.length > 0) {
|
if (stats.testsFailed.length > 0) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -100,12 +98,12 @@ async function walkDir(path, name, suite) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (files) {
|
} else if (files) {
|
||||||
|
const childSuite = new TestSuite(name);
|
||||||
|
suite.testSuites.push(childSuite);
|
||||||
await Promise.all(files.map(async file => {
|
await Promise.all(files.map(async file => {
|
||||||
const filePath = path + "/" + file;
|
const filePath = path + "/" + file;
|
||||||
const stat = await fs.stat(filePath);
|
const stat = await fs.stat(filePath);
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
const childSuite = new TestSuite(file);
|
|
||||||
suite.testSuites.push(childSuite);
|
|
||||||
await walkDir(filePath, file, childSuite);
|
await walkDir(filePath, file, childSuite);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
@ -121,15 +119,12 @@ class TestRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
async runTests(suite, path, depth) {
|
async runTests(suite, path, depth) {
|
||||||
let prefix = "";
|
if (suite.testCases.length > 0) {
|
||||||
for (let i = 0; i < depth; i++) {
|
console.log("Running " + path);
|
||||||
prefix += " ";
|
let testsFailedInSuite = 0;
|
||||||
}
|
const startTime = new Date().getTime();
|
||||||
|
|
||||||
console.log(prefix + suite.name + "/");
|
|
||||||
for (const testCase of suite.testCases) {
|
for (const testCase of suite.testCases) {
|
||||||
this.testsRun++;
|
this.testsRun++;
|
||||||
process.stdout.write(prefix + " " + testCase.name + "... ");
|
|
||||||
try {
|
try {
|
||||||
const testRun = Promise.race([
|
const testRun = Promise.race([
|
||||||
this.runTeaVMTest(testCase),
|
this.runTeaVMTest(testCase),
|
||||||
|
@ -140,24 +135,30 @@ class TestRunner {
|
||||||
const result = await testRun;
|
const result = await testRun;
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
case "OK":
|
case "OK":
|
||||||
process.stdout.write("OK");
|
|
||||||
break;
|
break;
|
||||||
case "failed":
|
case "failed":
|
||||||
this.logFailure(path, testCase, result.errorMessage);
|
this.logFailure(path, testCase, result.errorMessage);
|
||||||
|
testsFailedInSuite++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logFailure(path, testCase, e.stack);
|
this.logFailure(path, testCase, e.stack);
|
||||||
|
testsFailedInSuite++;
|
||||||
}
|
}
|
||||||
process.stdout.write("\n");
|
|
||||||
}
|
}
|
||||||
|
const endTime = new Date().getTime();
|
||||||
|
console.log("Tests run: " + suite.testCases.length + ", failed: " + testsFailedInSuite
|
||||||
|
+ ", elapsed: " + ((endTime - startTime) / 1000) + " seconds");
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
|
||||||
for (const childSuite of suite.testSuites) {
|
for (const childSuite of suite.testSuites) {
|
||||||
await this.runTests(childSuite, path + "/" + suite.name, depth + 1);
|
await this.runTests(childSuite, path + "/" + childSuite.name, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logFailure(path, testCase, message) {
|
logFailure(path, testCase, message) {
|
||||||
process.stdout.write("failure (" + (this.testsFailed.length + 1) + ")");
|
console.log(" " + testCase.name + "failure (" + (this.testsFailed.length + 1) + ")");
|
||||||
this.testsFailed.push({
|
this.testsFailed.push({
|
||||||
path: path + "/" + testCase.name,
|
path: path + "/" + testCase.name,
|
||||||
message: message
|
message: message
|
||||||
|
@ -166,7 +167,6 @@ class TestRunner {
|
||||||
|
|
||||||
async runTeaVMTest(testCase) {
|
async runTeaVMTest(testCase) {
|
||||||
await this.page.reload();
|
await this.page.reload();
|
||||||
//await this.page.loadEventFired();
|
|
||||||
|
|
||||||
const fileContents = await Promise.all(testCase.files.map(async (file) => {
|
const fileContents = await Promise.all(testCase.files.map(async (file) => {
|
||||||
return fs.readFile(file, 'utf8');
|
return fs.readFile(file, 'utf8');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user