Trim arguments after splitting them (#791)

* Trim arguments after splitting them

* Test functionality

* Update buildExec.test.ts

* Use `toMatchObject` instead of `toEqual`

* Use `expect.arrayContaining`

* Update buildExec.test.ts

* Debug `execArgs`

* Build project

* Add `verbose` guard

* Build project
This commit is contained in:
Mitchell Borrego
2022-07-26 12:43:41 -04:00
committed by GitHub
parent 68d5f6d0be
commit 5c0da1b28f
4 changed files with 1475 additions and 313 deletions

1695
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -122,3 +122,84 @@ test('all arguments', () => {
delete process.env['INPUT_' + env.toUpperCase()];
}
});
describe('trim arguments after splitting them', () => {
const baseExpectation = [
'-n',
expect.stringContaining(''),
'-Q',
expect.stringContaining('github-action'),
];
test('files', () => {
const envs = {'files': './client-coverage.txt, ./lcov.info'};
for (const [name, value] of Object.entries(envs)) {
process.env['INPUT_' + name.toUpperCase()] = value;
}
const {execArgs} = buildExec();
expect(execArgs).toEqual(
expect.arrayContaining([
...baseExpectation,
'-f',
'./client-coverage.txt',
'-f',
'./lcov.info',
]),
);
for (const env of Object.keys(envs)) {
delete process.env['INPUT_' + env.toUpperCase()];
}
});
test('flags', () => {
const envs = {'flags': 'ios, mobile'};
for (const [name, value] of Object.entries(envs)) {
process.env['INPUT_' + name.toUpperCase()] = value;
}
const {execArgs} = buildExec();
expect(execArgs).toEqual(
expect.arrayContaining([
...baseExpectation,
'-F',
'ios',
'-F',
'mobile',
]),
);
for (const env of Object.keys(envs)) {
delete process.env['INPUT_' + env.toUpperCase()];
}
});
test('functionalities', () => {
const envs = {'functionalities': 'network, gcov'};
for (const [name, value] of Object.entries(envs)) {
process.env['INPUT_' + name.toUpperCase()] = value;
}
const {execArgs} = buildExec();
expect(execArgs).toEqual(
expect.arrayContaining([
...baseExpectation,
'-X',
'network',
'-X',
'gcov',
]),
);
for (const env of Object.keys(envs)) {
delete process.env['INPUT_' + env.toUpperCase()];
}
});
});

View File

@@ -91,7 +91,7 @@ const buildExec = () => {
execArgs.push('-e', envVarsArg.join(','));
}
if (functionalities) {
functionalities.split(',').forEach((f) => {
functionalities.split(',').map((f) => f.trim()).forEach((f) => {
execArgs.push('-X', `${f}`);
});
}
@@ -102,12 +102,12 @@ const buildExec = () => {
execArgs.push('-f', `${file}`);
}
if (files) {
files.split(',').forEach((f) => {
files.split(',').map((f) => f.trim()).forEach((f) => {
execArgs.push('-f', `${f}`);
});
}
if (flags) {
flags.split(',').forEach((f) => {
flags.split(',').map((f) => f.trim()).forEach((f) => {
execArgs.push('-F', `${f}`);
});
}
@@ -176,6 +176,10 @@ const buildExec = () => {
uploaderVersion = 'latest';
}
if (verbose) {
console.debug({execArgs});
}
return {execArgs, options, failCi, os, uploaderVersion, verbose};
};