tests/test-legacy-exit-code.t
author Martin von Zweigbergk <martinvonz@google.com>
Wed, 21 Oct 2020 19:00:16 -0700
changeset 45826 21733e8c924f
child 45906 95c4cca641f6
permissions -rw-r--r--
errors: add config that lets user get more detailed exit codes This adds an experimental config that lets the user get more detailed exit codes. For example, there will be a specific error code for input/user errors. This is part of https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan. I've made the config part of tweakdefaults. I've made the config enabled by default in tests. My reasoning is that we want to see that each specific error case gives the right exit code and we don't want to duplicate all error cases in the entire test suite. It also makes it easy to grep the `.t` files for `[255]` to find which cases we have left to fix. The logic for the current exit codes is quite simple, so I'm not too worried about regressions there. I've added a test case specifically for the "legacy" exit codes. I've set the detailed exit status only for the case of `InterventionRequired` and `SystemExit` for now (the cases where we currently return something other than 255), just to show that it works. Differential Revision: https://phab.mercurial-scm.org/D9238

Tests that the exit code is as expected when ui.detailed-exit-code is *not*
enabled.

  $ cat >> $HGRCPATH << EOF
  > [ui]
  > detailed-exit-code=no
  > EOF

  $ hg init
  $ echo a > a
Expect exit code 0 on success
  $ hg ci -Aqm initial

  $ hg co nonexistent
  abort: unknown revision 'nonexistent'!
  [255]

  $ hg co 'none()'
  abort: empty revision set
  [255]

  $ hg co 'invalid('
  hg: parse error at 8: not a prefix: end
  (invalid(
           ^ here)
  [255]

  $ hg co 'invalid('
  hg: parse error at 8: not a prefix: end
  (invalid(
           ^ here)
  [255]

  $ hg continue
  abort: no operation in progress
  [255]

  $ hg st --config a=b
  abort: malformed --config option: 'a=b' (use --config section.name=value)
  [255]

  $ echo b > a
  $ hg ci -m second
  $ echo c > a
  $ hg ci -m third
  $ hg --config extensions.rebase= rebase -r . -d 0 -q
  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
  unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
  [1]