Prioritize command line option error and add ConfigValidationError for option error differentiation.

Review Request #3721 - Created April 19, 2016 and submitted

Information
Yi Cheng
pants
3217
Reviewers
pants-reviews
benjyw, patricklaw, stuhood, zundel

Currently OptionError is not differentiated between command line and config validation. This RB adds ConfigValidationError so they can be distinguished and ensures that command line option verification takes priority.

Removed --verify-config in some test cases because it is default now.

[tw-mbp-yic pants (invalid_flag_fix)]$ ./pants --config-override=bad.ini goals 
ERROR] Invalid scope [123] in bad.ini
Exception caught: (<class 'pants.option.config.ConfigValidationError'>)
  File "/Users/yic/workspace/pants/src/python/pants/bin/pants_exe.py", line 50, in <module>
    main()
  File "/Users/yic/workspace/pants/src/python/pants/bin/pants_exe.py", line 44, in main
    PantsRunner(exiter).run()
  File "/Users/yic/workspace/pants/src/python/pants/bin/pants_runner.py", line 53, in run
    options_bootstrapper=options_bootstrapper)
  File "/Users/yic/workspace/pants/src/python/pants/bin/pants_runner.py", line 43, in _run
    return LocalPantsRunner(exiter, args, env, options_bootstrapper=options_bootstrapper).run()
  File "/Users/yic/workspace/pants/src/python/pants/bin/local_pants_runner.py", line 49, in run
    self._maybe_profiled(self._run)
  File "/Users/yic/workspace/pants/src/python/pants/bin/local_pants_runner.py", line 46, in _maybe_profiled
    runner()
  File "/Users/yic/workspace/pants/src/python/pants/bin/local_pants_runner.py", line 67, in _run
    options_bootstrapper.verify_configs_against_options(options)
  File "/Users/yic/workspace/pants/src/python/pants/option/options_bootstrapper.py", line 185, in verify_configs_against_options
    raise Config.ConfigValidationError("Invalid config entries detected. "

Exception message: Invalid config entries detected. See log for details on which entries to update or remove.
(Specify --no-verify-config to disable this check.)


[tw-mbp-yic pants (invalid_flag_fix)]$ ./pants --config-override=bad.ini goals --test-junit-invalid=123
Exception caught: (<class 'pants.option.errors.ParseError'>)
  File "/Users/yic/workspace/pants/src/python/pants/bin/pants_exe.py", line 50, in <module>
    main()
  File "/Users/yic/workspace/pants/src/python/pants/bin/pants_exe.py", line 44, in main
    PantsRunner(exiter).run()
  File "/Users/yic/workspace/pants/src/python/pants/bin/pants_runner.py", line 53, in run
    options_bootstrapper=options_bootstrapper)
  File "/Users/yic/workspace/pants/src/python/pants/bin/pants_runner.py", line 43, in _run
    return LocalPantsRunner(exiter, args, env, options_bootstrapper=options_bootstrapper).run()
  File "/Users/yic/workspace/pants/src/python/pants/bin/local_pants_runner.py", line 49, in run
    self._maybe_profiled(self._run)
  File "/Users/yic/workspace/pants/src/python/pants/bin/local_pants_runner.py", line 46, in _maybe_profiled
    runner()
  File "/Users/yic/workspace/pants/src/python/pants/bin/local_pants_runner.py", line 63, in _run
    options.for_scope(scope)
  File "/Users/yic/workspace/pants/src/python/pants/option/options.py", line 275, in for_scope
    self._parser_hierarchy.get_parser_by_scope(scope).parse_args(flags_in_scope, values)
  File "/Users/yic/workspace/pants/src/python/pants/option/parser.py", line 211, in parse_args
    self._scope_str(), ', '.join(flag_value_map.keys())))

Exception message: Unrecognized command line flags on scope 'test.junit': --invalid

https://travis-ci.org/pantsbuild/pants/builds/124554036

Issues

  • 0
  • 1
  • 0
  • 1
Description From Last Updated
Stu Hood
Benjy Weinberger
Yi Cheng
Benjy Weinberger
Eric Ayers
Yi Cheng
Yi Cheng
Review request changed

Status: Closed (submitted)

Change Summary:

555b5fa408829623e68937e423416b1eb4dd03ca thanks Benjy, Eric, Stu!

Loading...