Testing travis setup

This commit is contained in:
Alexey Andreev 2017-04-22 18:57:06 +03:00
parent 1fc4e85ae8
commit 6298e2c498
2 changed files with 14 additions and 18 deletions

View File

@ -86,6 +86,7 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version> <version>2.16</version>
<configuration> <configuration>
<skip>true</skip>
<argLine>-Xmx512m</argLine> <argLine>-Xmx512m</argLine>
<systemProperties> <systemProperties>
<teavm.junit.target>${project.build.directory}/js-tests</teavm.junit.target> <teavm.junit.target>${project.build.directory}/js-tests</teavm.junit.target>

View File

@ -48,14 +48,14 @@ async function runAll() {
await walkDir(process.argv[2], "root", rootSuite); await walkDir(process.argv[2], "root", rootSuite);
console.log("Running tests"); console.log("Running tests");
const stats = { testRun: 0, testsFailed: [] };
const server = http.createServer((request, response) => { const server = http.createServer((request, response) => {
response.writeHead(404); response.writeHead(404);
response.end(); response.end();
}); });
server.listen(9090, () => { server.listen(9090, () => {
console.log((new Date()) + ' Server is listening on port 8080'); console.log((new Date()) + ' Server is listening on port 9090');
}); });
const wsServer = new WebSocketServer({ const wsServer = new WebSocketServer({
@ -64,35 +64,30 @@ async function runAll() {
}); });
const startTime = new Date().getTime(); const startTime = new Date().getTime();
await new Promise((resolve, reject) => { const connectPromise = new Promise(resolve => wsServer.on("connect", resolve));
wsServer.on("connect", async (conn) => { const timeoutPromise = new Promise((_, reject) => {
try { setTimeout(() => reject(new Error("Connection time out")), 15000)
const runner = new TestRunner(conn);
await runner.runTests(rootSuite, "", 0);
stats.testRun = runner.testsRun;
stats.testsFailed = runner.testsFailed;
resolve();
} catch (e) {
reject(e);
}
})
}); });
const conn = await Promise.race([connectPromise, timeoutPromise]);
const runner = new TestRunner(conn);
await runner.runTests(rootSuite, "", 0);
wsServer.unmount(); wsServer.unmount();
server.close(); server.close();
const endTime = new Date().getTime(); const endTime = new Date().getTime();
for (let i = 0; i < stats.testsFailed.length; i++) { for (let i = 0; i < runner.testsFailed.length; i++) {
const failedTest = stats.testsFailed[i]; const failedTest = runner.testsFailed[i];
console.log("(" + (i + 1) + ") " + failedTest.path +":"); console.log("(" + (i + 1) + ") " + failedTest.path +":");
console.log(failedTest.message); console.log(failedTest.message);
console.log(); console.log();
} }
console.log("Tests run: " + stats.testRun + ", failed: " + stats.testsFailed.length console.log("Tests run: " + runner.testRun + ", failed: " + runner.testsFailed.length
+ ", elapsed " + ((endTime - startTime) / 1000) + " seconds"); + ", elapsed " + ((endTime - startTime) / 1000) + " seconds");
if (stats.testsFailed.length > 0) { if (runner.testsFailed.length > 0) {
process.exit(1); process.exit(1);
} else { } else {
process.exit(0); process.exit(0);