test: add test if stderror and stdout get logged if both are present
This commit is contained in:
parent
08a833f1cf
commit
4b42a5fbda
13 changed files with 91 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import { convert } from "../../src/converters/assimp.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -17,3 +18,7 @@ test("convert rejects when execFile fails", async () => {
|
||||||
test("convert logs stderr when present", async () => {
|
test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { convert } from "../../src/converters/calibre.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -17,3 +18,7 @@ test("convert rejects when execFile fails", async () => {
|
||||||
test("convert logs stderr when present", async () => {
|
test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { ExecFileFn } from "../../src/converters/types.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -26,6 +27,10 @@ test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
||||||
test("convert respects eps filetype", async () => {
|
test("convert respects eps filetype", async () => {
|
||||||
const originalConsoleLog = console.log;
|
const originalConsoleLog = console.log;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { convert } from "../../src/converters/graphicsmagick.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -17,3 +18,7 @@ test("convert rejects when execFile fails", async () => {
|
||||||
test("convert logs stderr when present", async () => {
|
test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -65,3 +65,34 @@ export async function runConvertLogsStderror(convertFn: ConvertFnWithExecFile) {
|
||||||
|
|
||||||
expect(loggedMessage).toBe("stderr: Fake stderr");
|
expect(loggedMessage).toBe("stderr: Fake stderr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function runConvertLogsStderrorAndStdout(convertFn: ConvertFnWithExecFile) {
|
||||||
|
const originalConsoleError = console.error;
|
||||||
|
const originalConsoleLog = console.log;
|
||||||
|
|
||||||
|
let loggedError = "";
|
||||||
|
let loggedMessage = "";
|
||||||
|
console.error = (msg) => {
|
||||||
|
loggedError = msg;
|
||||||
|
};
|
||||||
|
console.log = (msg) => {
|
||||||
|
loggedMessage = msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockExecFile = (
|
||||||
|
_cmd: string,
|
||||||
|
_args: string[],
|
||||||
|
options: unknown,
|
||||||
|
callback: (err: Error | null, stdout: string, stderr: string) => void,
|
||||||
|
) => {
|
||||||
|
callback(null, "Fake stdout", "Fake stderr");
|
||||||
|
};
|
||||||
|
|
||||||
|
await convertFn("file.obj", "obj", "stl", "out.stl", undefined, mockExecFile);
|
||||||
|
|
||||||
|
console.error = originalConsoleError;
|
||||||
|
console.log = originalConsoleLog;
|
||||||
|
|
||||||
|
expect(loggedError).toBe("stderr: Fake stderr");
|
||||||
|
expect(loggedMessage).toBe("stdout: Fake stdout");
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { ExecFileFn } from "../../src/converters/types.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -26,6 +27,10 @@ test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
||||||
test("convert respects ico conversion target type", async () => {
|
test("convert respects ico conversion target type", async () => {
|
||||||
const originalConsoleLog = console.log;
|
const originalConsoleLog = console.log;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { convert } from "../../src/converters/inkscape.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -17,3 +18,7 @@ test("convert rejects when execFile fails", async () => {
|
||||||
test("convert logs stderr when present", async () => {
|
test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { convert } from "../../src/converters/libheif.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -17,3 +18,7 @@ test("convert rejects when execFile fails", async () => {
|
||||||
test("convert logs stderr when present", async () => {
|
test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { ExecFileFn } from "../../src/converters/types.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -26,6 +27,10 @@ test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
||||||
test("convert uses djxl with input filetype being jxl", async () => {
|
test("convert uses djxl with input filetype being jxl", async () => {
|
||||||
const originalConsoleLog = console.log;
|
const originalConsoleLog = console.log;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { convert } from "../../src/converters/potrace.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -17,3 +18,7 @@ test("convert rejects when execFile fails", async () => {
|
||||||
test("convert logs stderr when present", async () => {
|
test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { convert } from "../../src/converters/resvg.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -17,3 +18,7 @@ test("convert rejects when execFile fails", async () => {
|
||||||
test("convert logs stderr when present", async () => {
|
test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { convert } from "../../src/converters/vips.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -26,6 +27,10 @@ test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
||||||
test("convert uses action pdfload with filetype being pdf", async () => {
|
test("convert uses action pdfload with filetype being pdf", async () => {
|
||||||
const originalConsoleLog = console.log;
|
const originalConsoleLog = console.log;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { convert } from "../../src/converters/xelatex.ts";
|
||||||
import {
|
import {
|
||||||
runConvertFailTest,
|
runConvertFailTest,
|
||||||
runConvertLogsStderror,
|
runConvertLogsStderror,
|
||||||
|
runConvertLogsStderrorAndStdout,
|
||||||
runConvertSuccessTest,
|
runConvertSuccessTest,
|
||||||
} from "./helpers/converters.ts";
|
} from "./helpers/converters.ts";
|
||||||
|
|
||||||
|
|
@ -17,3 +18,7 @@ test("convert rejects when execFile fails", async () => {
|
||||||
test("convert logs stderr when present", async () => {
|
test("convert logs stderr when present", async () => {
|
||||||
await runConvertLogsStderror(convert);
|
await runConvertLogsStderror(convert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("convert logs both stderr and stdout when present", async () => {
|
||||||
|
await runConvertLogsStderrorAndStdout(convert);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue