Commit Graph

4 Commits

Author SHA1 Message Date
Jun Wu
08c15a105a testutil/dott: normalize error messages
Summary:
run-tests.py uses common-pattern.py to normalize error messages to things
like `$ENOENT$`. Implement that behavior.

Reviewed By: xavierd

Differential Revision: D16209208

fbshipit-source-id: 3e609cc16442f80b844264f93dce9ea46517458d
2019-07-17 21:11:28 -07:00
Jun Wu
27908b883c testutil/dott: initial framework
Summary:
The testutil/dott module is to be "somehow" compatible with ".t" tests.
At its core, it emulates "bash" syntax using Python functions.

This diff adds the core "sh" syntax to call into Python functions.
The test code can be written as:

  from testutil.dott import sh

  sh % "echo foo" == "foo\n"
  sh % "echo remotefilelog" > ".hg/requires"
  sh % "cat" << "[extensions]\nrebase=" > ".hg/hgrc"

This is similar to ".t" test:

  $ echo foo
  foo
  $ echo remotefilelog > .hg/requires
  $ cat << EOF > .hg/hgrc
  > [extensions]
  > rebase=
  > EOF

And is compat even after black formatting.

Reviewed By: xavierd

Differential Revision: D16172901

fbshipit-source-id: 7bb666e7e1621536ffdd6516542a468ac419d80a
2019-07-17 21:11:28 -07:00
Jun Wu
2232a26c42 testutil: add "eq" assertion with autofix ability
Summary: The "eq" API is similar to `assert_eq!` in Rust, with the autofix ability.

Reviewed By: xavierd

Differential Revision: D16168821

fbshipit-source-id: bf7dcfd24c42dee30c54aeeaa71eccab78a8f0f6
2019-07-17 21:11:27 -07:00
Jun Wu
dd1b0586c0 testutil: add a utility to calculate argument positions
Summary:
The utility is used by a later change which provides the "autofix" feature for
Python code.

Reviewed By: xavierd

Differential Revision: D16168823

fbshipit-source-id: feb55a9e6ba5e78ad0f490cadeeafbcc1306e8ca
2019-07-17 21:11:27 -07:00