Code review comment for lp:~spiv/bzr-usertest/exit_codes

Revision history for this message
Martin Pool (mbp) wrote :

Putting this in a pseudo-comment seems a inconsistent with the general shell-like syntax used within usertest. If it was executed by an actual shell then we might want something like

  expectrc 1 bzr diff

where

  expectrc() {
    rc=$1
    shift
    "$@"
    [ $? -ne $rc ] || echo 'fail'
  }

Of course it's not actually run through the shell.

I see the concept of having labels in ## comments is already established in usertest so fair enough then.

+ def test_exit_codes(self):
+ task = userscript.ScriptTask()
+ task.compile_default("""
+ $python -c 'raise SystemExit(42)' ## mylabel
+ """, exit_codes={'mylabel': 42})
+ # No exception is raised, because the exit code matches the expected
+ # exit code given to compile_default.
+ (measurements,created_dirs) = task.run_script_for(usertool.TOOL_BZR,
+ {'python': sys.executable}, [], strict=True)

On Windows these would need to be doublequotes not single. I'm not sure how close the test suite is to working on Windows so it may not matter. At any rate it's easy to change later.

I would have expected to see a test for the case of a command that succeeds when it's expected to fail. It looks like that will pass though.

review: Approve

« Back to merge proposal