Skip to content

Commit

Permalink
Ignore null output option (#510)
Browse files Browse the repository at this point in the history
Co-authored-by: Harry Sarson <[email protected]>
Co-authored-by: Simon Lydell <[email protected]>
  • Loading branch information
3 people authored May 14, 2021
1 parent c493674 commit 0b6fcb3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/elm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ function getPathToElmBinary(compiler /*: string | void */) /*: string */ {
}
}

function outputOptionError() {
return `
Only /dev/null is allowed.
NOTE: Including this option will not have any effect, as \`elm-test\` does not
produce any output files. It is meant to improve compatibility with editor
plugins explicitly setting the --output flag to /dev/null when using
\`elm-test make\` as a drop-in replacement for \`elm make\`.'
`.trim();
}

const examples = `
elm-test
Run tests in the tests/ folder
Expand Down Expand Up @@ -133,6 +144,17 @@ function main() {
'Use a custom path to an Elm executable (default: elm)',
undefined
)
// Ensure compatibility with editor plugins setting --output=/dev/null when
// running `make`. This has caused issues with Emacs' flycheck-elm package.
.addOption(
new Option('--output <output>')
.argParser((value) => {
if (value !== '/dev/null') {
throw new InvalidOptionArgumentError(outputOptionError());
}
})
.hideHelp()
)
.version(packageInfo.version, '--version', 'Print version and exit')
.helpOption('-h, --help', 'Show help')
.addHelpCommand('help [command]', 'Show help');
Expand Down
23 changes: 23 additions & 0 deletions tests/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,29 @@ describe('flags', () => {
assert.ok(Number.isInteger(runResult.status));
assert.notStrictEqual(runResult.status, 0);
}).timeout(60000);

describe('--output', () => {
it('should ignore --output flag when set to /dev/null', () => {
const runResult = execElmTest([
'make',
'--output=/dev/null',
'tests/Passing/One.elm',
]);

assert.strictEqual(runResult.status, 0);
}).timeout(60000);

it('should fail if setting --output to anything other than /dev/null', () => {
const runResult = execElmTest([
'make',
'--output=output_file',
'tests/Passing/One.elm',
]);

assert.ok(Number.isInteger(runResult.status));
assert.notStrictEqual(runResult.status, 0);
}).timeout(60000);
});
});

describe('--help', () => {
Expand Down

0 comments on commit 0b6fcb3

Please sign in to comment.