Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
types:
- build-push
pull_request:
branches:
- main
- rc
workflow_dispatch:
inputs:
version:
Expand Down
16 changes: 2 additions & 14 deletions test/artifacts/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"input": ".",
"output": ".",
"recursive": true,
"logLevel": "debug",
"logLevel": "info",
"relativePathBase": "file",
"runTests": {
"input": ".",
Expand All @@ -17,19 +17,7 @@
"contexts": [
{
"app": { "name": "chrome", "options": { "headless": true } },
"platforms": ["mac", "linux"]
},
{
"app": { "name": "chrome", "options": { "headless": true } },
"platforms": ["windows"]
},
{
"app": { "name": "firefox", "options": { "headless": true } },
"platforms": ["mac", "linux"]
},
{
"app": { "name": "firefox", "options": { "headless": true } },
"platforms": ["windows"]
"platforms": ["mac", "linux", "windows"]
}
]
},
Expand Down
63 changes: 40 additions & 23 deletions test/runTests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,22 @@ if (process.platform === "win32") {
// });

// Run tests in Docker container
describe("Run tests sucessfully", async function () {
describe("Run tests successfully", async function () {
// Set indefinite timeout
this.timeout(0);
it("All specs pass", async () => { return new Promise((resolve, reject) => {
it("All specs pass", async () => {
return new Promise((resolve, reject) => {
let hasCompleted = false;

const handleCompletion = (callback) => {
if (hasCompleted) return;
hasCompleted = true;
callback();
};

const runTests = exec(
`docker run --rm -v "${artifactPath}:${internalPath}" docdetective/docdetective:${version}-${os} -c ./config.json -i . -o ./results.json`
`docker run --rm --memory=2g --cpus=2 -v "${artifactPath}:${internalPath}" docdetective/docdetective:${version}-${os} -c ./config.json -i . -o ./results.json`,
{ maxBuffer: 10 * 1024 * 1024 } // 10MB buffer for output
);

runTests.stdout.on("data", (data) => {
Expand All @@ -70,28 +80,35 @@ describe("Run tests sucessfully", async function () {

runTests.on("error", (error) => {
console.error(`Error: ${error.message}`);
reject(error);
});

runTests.on("close", (code) => {
console.log(`Child process exited with code ${code}`);
if (code !== null && code !== 0) {
reject(new Error(`Docker process exited with code ${code}`));
}
handleCompletion(() => reject(error));
});

runTests.on("exit", () => {
try {
const result = JSON.parse(
fs.readFileSync(outputFile, { encoding: "utf8" })
);
console.log(JSON.stringify(result, null, 2));
assert.equal(result.summary.specs.fail, 0);
fs.unlinkSync(outputFile);
resolve();
} catch (error) {
reject(error);
}
runTests.on("close", (code, signal) => {
handleCompletion(() => {
console.log(`Child process closed with code ${code} and signal ${signal}`);

if (signal != null) {
reject(new Error(`Docker process terminated by signal ${signal}`));
return;
}

if (code !== null && code !== 0) {
reject(new Error(`Docker process exited with code ${code}`));
return;
}

try {
const result = JSON.parse(
fs.readFileSync(outputFile, { encoding: "utf8" })
);
console.log(JSON.stringify(result, null, 2));
assert.equal(result.summary.specs.fail, 0);
fs.unlinkSync(outputFile);
resolve();
} catch (error) {
reject(error);
}
});
});
});
});
Expand Down