-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugruntest: improve compatibility with extensions
Summary: debugruntest executes sl commands in-process to eliminate process startup overhead. This is incompatible with extensions changing during the test since the extensions are only loaded once, installing their function wrappers. If a later command disables the extension, the function wrappers (and other side effects) will still remain, probably messing things up. In this diff I attempt to fix the function wrappers to be compatible with debugruntest. Basically, when wrapping things we install another layer of wrapping that checks at runtime whether the extension is still enabled (and doesn't run the wrapper if the extension is disabled). Another approach would be to track all the wrappers and unwrap/rewrap them as we notice extensions have been disbled/enabled, but this way seemed simpler and maybe more reliable. Reviewed By: quark-zju Differential Revision: D54839559 fbshipit-source-id: 071bc0e832e48c7049f33c720007ab958a51e933
- Loading branch information
1 parent
cd14439
commit bdf4505
Showing
3 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#debugruntest-compatible | ||
|
||
$ cat > ex1.py <<EOS | ||
> from sapling import commands, extensions | ||
> def uisetup(ui): | ||
> def files(orig, ui, *args, **kwargs): | ||
> ui.status("ex1\n") | ||
> return orig(ui, *args, **kwargs) | ||
> extensions.wrapcommand(commands.table, "files", files) | ||
> EOS | ||
|
||
$ cat > ex2.py <<EOS | ||
> from sapling import commands, extensions | ||
> def uisetup(ui): | ||
> def files(orig, ui, *args, **kwargs): | ||
> ui.status("ex2\n") | ||
> return orig(ui, *args, **kwargs) | ||
> extensions.wrapcommand(commands.table, "files", files) | ||
> EOS | ||
|
||
$ newrepo | ||
$ echo foo > foo | ||
$ hg ci -Aqm foo | ||
$ hg files | ||
foo | ||
|
||
$ hg files --config extensions.ex1=~/ex1.py | ||
ex1 | ||
foo | ||
|
||
$ hg files --config extensions.ex2=~/ex2.py | ||
ex2 | ||
foo | ||
|
||
$ hg files --config extensions.ex2=~/ex2.py --config extensions.ex1=~/ex1.py | ||
ex2 | ||
ex1 | ||
foo | ||
|
||
$ hg files | ||
foo |