Smarter args parser and a few debug messages

This commit is contained in:
svartalf 2019-09-13 22:45:36 +03:00
parent de5e75cc84
commit 40cbaa365c
6 changed files with 27 additions and 15 deletions

32
__tests__/input.test.ts Normal file
View file

@ -0,0 +1,32 @@
import * as input from '../src/input'
const testEnvVars = {
INPUT_COMMAND: 'build',
// There are few unnecessary spaces here to check that args parser works properly
INPUT_ARGS: ' --release --target x86_64-unknown-linux-gnu --no-default-features --features unstable ',
'INPUT_USE-CROSS': 'true',
INPUT_TOOLCHAIN: '+nightly'
}
describe('actions-rs/check', () => {
beforeEach(() => {
for (const key in testEnvVars)
process.env[key] = testEnvVars[key as keyof typeof testEnvVars]
})
it('Parses action input into cargo input', async () => {
const result = input.parse();
expect(result.command).toBe('build');
expect(result.args).toStrictEqual([
'--release',
'--target',
'x86_64-unknown-linux-gnu',
'--no-default-features',
'--features',
'unstable'
]);
expect(result.useCross).toBe(true);
expect(result.toolchain).toBe('nightly');
});
});