Summary:
This makes it possible to execute Rust commands from the Python tests.
Test changes:
- test-command-template-t: non-utf8 command-line arguments are rejected at the
function signature level
- test-dispatch-debug-prefix-t: the error is now printed by Rust code, which
uses spaces instead of tabs.
- test-root-t: the test now passes
Reviewed By: xavierd
Differential Revision: D16866459
fbshipit-source-id: 386931c5497b04c53efc08fbb4de708812517ad9
Summary:
This gives the Rust code path hints to names of Python command names.
Ideally, the Rust command dispatch logic can just load the Python command table
and figure out it more accurately, and more parts of dispatch.py (ex. extension
loading, debugger, profiler, atexit, etc) are moved to Rust clidispatch or
hgcommands. But that would be a larger change.
Reviewed By: xavierd
Differential Revision: D16866462
fbshipit-source-id: eb993091d5644710686b8f720fd07258b9a5968c
Summary: Previously, `|` was treated as an argument of a command. Fix it.
Reviewed By: singhsrb
Differential Revision: D16473729
fbshipit-source-id: 0c9a76cd01fc3a22bd43cd0b7d96ce9c6e61ce37
Summary:
`util.shellquote` is platform-dependent. In case of the translator, it always
uses `shlex.split`. Therefore the posix shell quote should be used.
This makes the the test stable across multiple platforms. Namely, `"` is not
used on Windows.
Reviewed By: xavierd
Differential Revision: D16606904
fbshipit-source-id: 879e06b54fc427a6ad1aa959927a0df52f33269a
Summary:
`parsecmd` uses `for name in dictobj`, which can get different results due to
different random seed being used. Use an explicit list instead to avoid the issue.
Reviewed By: xavierd
Differential Revision: D16596261
fbshipit-source-id: c81665cb550a0ce76885aa7f3caee959d63f7b67
Summary:
This makes it possible to test the translate behavior without writing anything
to filesystem.
Reviewed By: xavierd
Differential Revision: D16473728
fbshipit-source-id: 3c07b2b5e41d40444b98e7f02de840d2105082fe
Summary:
The old code replaces `\foo (esc)` to `/foo (esc)`, and break the `(esc)`
decoding. Change the order so we decode `(esc)` first before normalizing
the path.
Reviewed By: sfilipco
Differential Revision: D16501047
fbshipit-source-id: ac49fa89fe0123436a994548b045edc0cef0a982
Summary:
Make `import edenscm` take care of `sys.path` so as long as `import edenscm`
works, 3rd party pure Python dependencies and edenscmnative should be
importable.
This reduces adhoc sys.path handling in testutil.dott, and fixes an issue where
testing on Windows where `testuitl.dott` fails to run hg commands due to
missing 3rd party dependencies (because `edenscm.mercurial.entrypoint.run` is
not called, and edenscmdeps.zip is not in sys.path).
Reviewed By: sfilipco
Differential Revision: D16499458
fbshipit-source-id: 17e6e5754614dfcf352127d471c649ded4189e1a
Summary:
The `output` API is the thing that stops infinite output from being used.
If endless output is needed, it can be expressed using something like Python
generator. Then the callsites using `stdin` needs update as well.
Reviewed By: xavierd
Differential Revision: D16464660
fbshipit-source-id: 1b81c44c5089f03687aa63ed3ffda9a5399c199b
Summary:
This makes it possible to write:
sh % 'command' | 'head -2'
in tests
Reviewed By: xavierd
Differential Revision: D16452932
fbshipit-source-id: 8af1355cebc40085fb7af67ceb24a4d54783d388
Summary:
In case the command is `hg --cwd ...`, the side effect of changing pwd should
be reverted at the end of the command.
Reviewed By: xavierd
Differential Revision: D16452924
fbshipit-source-id: 82f96b66ad3fed123cb2e906fc51d6627b16c1f0
Summary: The "succeed" code path was missing in the `test` command.
Reviewed By: xavierd
Differential Revision: D16452921
fbshipit-source-id: a276b774c528edaf60e0ecbbad00c15ddd8ba1d1
Summary:
The `_repr` implementation can generate docstrings with trailing spaces if
`indent` is > 0.
Fix it by special handling the blank line case.
Reviewed By: xavierd
Differential Revision: D16452935
fbshipit-source-id: 99704ba3fb30b93aa35ba4fb16c1d853c58c6635
Summary:
In case there are multiple commands in a line, and the first command uses
redirections:
foo > bar && baz
The `> bar` got lost after translation. This is because the same `opts` Python
object (including `> bar` information) was returned and it was mutated.
Solve it by returning a copy of `opts` per command.
Reviewed By: xavierd
Differential Revision: D16452936
fbshipit-source-id: a7ab55cc44ebe628817f821412576e17f6f68a6f
Summary:
Make it possible to change the internal state of HGENCODING so we can run hg
logic within a single process without shelling out in the new dott test
framework.
Update testutil/dott to use it.
Reviewed By: xavierd
Differential Revision: D16452925
fbshipit-source-id: d21329854eeee171cc5d02d4f42f11dd273f2150
Summary:
build_nupkg.py test will copy tests/ to build/embedded/tests/ before running
them. That breaks testutil.dott "edenscm" module discovery. Try to fix it by
making "edenscm" module discovery consider "build/embedded/python27.zip".
Reviewed By: xavierd
Differential Revision: D16383017
fbshipit-source-id: 52e19182d3e5e7267221244bd39d9a146928d8df
Summary:
Some linters or editers are unhappy with trailing spaces in heredoc.
Workaround it.
Reviewed By: xavierd
Differential Revision: D16344717
fbshipit-source-id: 63be8b992e2e4718faea1a55655c592f0e87b206
Summary: This allows FOO=bar to work in some tests.
Reviewed By: xavierd
Differential Revision: D16344718
fbshipit-source-id: b600d928a42e9e8e36a2ab9f5db97fd489878d02
Summary:
`.t` tests use `hghave` to test features, and can have `#testcases` for
multiple test cases. Implement them.
Reviewed By: xavierd
Differential Revision: D16209201
fbshipit-source-id: 1e8ea32d966f922efcf94e555cc9ab946cc85b27
Summary:
Tests use "source" to enable new features. One the main sources is
"library.sh", which includes remotefilelog utilties. Implement it.
Reviewed By: xavierd
Differential Revision: D16209209
fbshipit-source-id: 3bce4296861947e753e37bccf83c05129960dece
Summary:
Implement hg commands. This uses the dispatch code path to run hg commands
without startup overhead. It's possible that some side effects in the Python
world can cause unwanted behavior. Therefore a "reload" function was provided.
Once we have Rust as the entry point, we might still want to have some Python
binding to the Rust logic so the test code can use them.
Reviewed By: xavierd
Differential Revision: D16209204
fbshipit-source-id: e510f59629b46afd6b140c7bec9de07698b523b9
Summary: Implement a subset of coreutils so functions used by .t can run.
Reviewed By: xavierd
Differential Revision: D16209202
fbshipit-source-id: 953bebbfdc09cf191e8aa04c5ee1468c764b4360
Summary:
To make the code look better, indentation gets added to heredoc content.
Remove them. This replaces `inspect.cleandoc`. The difference is
`inspect.cleandoc` special handles the first line, which is undesirable.
Reviewed By: xavierd
Differential Revision: D16344716
fbshipit-source-id: c69c20607ddc5292bc6bcdd840587258276016ed
Summary:
TESTTMP was handled by run-tests.py. This diff extracts a subset of TESTTMP
logic so tests using testutil/dott can run via Python directly without using
run-tests.py
Reviewed By: xavierd
Differential Revision: D16209203
fbshipit-source-id: 7605505a725c30c9d07d83b7d3bfe92ec215cefc
Summary:
`run-tests.py` supports `(glob)`, `(re)`, `(esc)` for output matching.
Implement them.
Note: `(?)` is harder to implement. It is not implemented in this diff.
Reviewed By: xavierd
Differential Revision: D16209212
fbshipit-source-id: 52172158c41286a0673e6ae25bde2c774ac24c52
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
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
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
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