mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-18 08:51:44 +00:00
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:
parent
68d5f6d0be
commit
5c0da1b28f
4 changed files with 1475 additions and 313 deletions
1695
dist/index.js
vendored
1695
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -122,3 +122,84 @@ test('all arguments', () => {
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
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()];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ const buildExec = () => {
|
||||||
execArgs.push('-e', envVarsArg.join(','));
|
execArgs.push('-e', envVarsArg.join(','));
|
||||||
}
|
}
|
||||||
if (functionalities) {
|
if (functionalities) {
|
||||||
functionalities.split(',').forEach((f) => {
|
functionalities.split(',').map((f) => f.trim()).forEach((f) => {
|
||||||
execArgs.push('-X', `${f}`);
|
execArgs.push('-X', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -102,12 +102,12 @@ const buildExec = () => {
|
||||||
execArgs.push('-f', `${file}`);
|
execArgs.push('-f', `${file}`);
|
||||||
}
|
}
|
||||||
if (files) {
|
if (files) {
|
||||||
files.split(',').forEach((f) => {
|
files.split(',').map((f) => f.trim()).forEach((f) => {
|
||||||
execArgs.push('-f', `${f}`);
|
execArgs.push('-f', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (flags) {
|
if (flags) {
|
||||||
flags.split(',').forEach((f) => {
|
flags.split(',').map((f) => f.trim()).forEach((f) => {
|
||||||
execArgs.push('-F', `${f}`);
|
execArgs.push('-F', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -176,6 +176,10 @@ const buildExec = () => {
|
||||||
uploaderVersion = 'latest';
|
uploaderVersion = 'latest';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
console.debug({execArgs});
|
||||||
|
}
|
||||||
|
|
||||||
return {execArgs, options, failCi, os, uploaderVersion, verbose};
|
return {execArgs, options, failCi, os, uploaderVersion, verbose};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue