-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix timeout/slow string values and duplicate arguments #3831
Conversation
This is a completely valid cmdline argument usage -- last value wins. It's not an error. |
Agree. Sometimes it's even necessary to overwrite flags, i.e. ones set by IDE's. |
Hm, ok. Assuming the array yargs-parser gives us is in order, then I can just pop it. |
299a710
to
4601d00
Compare
@juergba @plroebuck I've changed this to use the last value instead of throwing an exception. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except the duplicate test already mentioned.
(there can still be duplicate arguments within one single config file)
}, | ||
{stdio: 'pipe'} | ||
); | ||
describe('when argument is missing required value', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Said this before and provided code for it.
This should be run for all arguments expecting a value, not just --ui
.
I haven't understood this "yargs" / "yargs-parser" thing completely, yet.
var parse = require('yargs-parser');
var args = parse(
['--timeout', '2s', '--timeout', '1s', '--timeout', '800'], {
string: ['timeout'],
configuration: {
'duplicate-arguments-array': false,
'camel-case-expansion': false
}
});
console.log(args); // { _: [], timeout: '800' } |
lib/cli/run.js
Outdated
.forEach(opt => { | ||
argv[opt] = argv[opt].pop(); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part does not work correctly:
- input per CLI:
--slow 5 --slow 10
- result after parsing:
s: ["5"], slow: "10"
bea695b
to
2936367
Compare
There is a bug in "yargs-parser" where the coerce function returns a value of type This affects the parsing of our Ready for review. |
2936367
to
c1a0269
Compare
I have chosen
|
Upstream fix for yargs-parser unnecessary then? |
For our purposes, yes unnecessary. |
I will merge these changes tomorrow. |
c1a0269
to
6c8b7e1
Compare
This fixes two problems:
Duplicate values are no longer allowed on the command line, and an error will be thrown (e.g.,--timeout 0 --timeout 0
)timeout
andslow
(e.g.,1s
,500ms
) are no longer evaluated toNaN
(because their type was set tonumber
). It appears that a value ofNaN
would cause timeouts to be disabled.Ref: #3817
UPDATE: Duplicate arguments are now allowed; the last value is chosen.