Add --ram and --threads args
This commit is contained in:
parent
09fb3ec514
commit
4c00c68d14
18 changed files with 81 additions and 65 deletions
13
lib/util.test.js
generated
13
lib/util.test.js
generated
|
|
@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const ava_1 = __importDefault(require("ava"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const logging_1 = require("./logging");
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
const util = __importStar(require("./util"));
|
||||
testing_utils_1.setupTests(ava_1.default);
|
||||
|
|
@ -28,15 +29,13 @@ ava_1.default('getMemoryFlag() should return the correct --ram flag', t => {
|
|||
"512": "--ram=512",
|
||||
};
|
||||
for (const [input, expectedFlag] of Object.entries(tests)) {
|
||||
process.env['INPUT_RAM'] = input;
|
||||
const flag = util.getMemoryFlag();
|
||||
const flag = util.getMemoryFlag(input);
|
||||
t.deepEqual(flag, expectedFlag);
|
||||
}
|
||||
});
|
||||
ava_1.default('getMemoryFlag() throws if the ram input is < 0 or NaN', t => {
|
||||
for (const input of ["-1", "hello!"]) {
|
||||
process.env['INPUT_RAM'] = input;
|
||||
t.throws(util.getMemoryFlag);
|
||||
t.throws(() => util.getMemoryFlag(input));
|
||||
}
|
||||
});
|
||||
ava_1.default('getThreadsFlag() should return the correct --threads flag', t => {
|
||||
|
|
@ -48,14 +47,12 @@ ava_1.default('getThreadsFlag() should return the correct --threads flag', t =>
|
|||
[`${-numCpus - 1}`]: `--threads=${-numCpus}`
|
||||
};
|
||||
for (const [input, expectedFlag] of Object.entries(tests)) {
|
||||
process.env['INPUT_THREADS'] = input;
|
||||
const flag = util.getThreadsFlag();
|
||||
const flag = util.getThreadsFlag(input, logging_1.getRunnerLogger(true));
|
||||
t.deepEqual(flag, expectedFlag);
|
||||
}
|
||||
});
|
||||
ava_1.default('getThreadsFlag() throws if the threads input is not an integer', t => {
|
||||
process.env['INPUT_THREADS'] = "hello!";
|
||||
t.throws(util.getThreadsFlag);
|
||||
t.throws(() => util.getThreadsFlag("hello!", logging_1.getRunnerLogger(true)));
|
||||
});
|
||||
ava_1.default('getRef() throws on the empty string', t => {
|
||||
process.env["GITHUB_REF"] = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue