sapling/eden/scm/tests/test-fb-hgext-fbhistedit-json.t
Zeyi (Rice) Fan 92f6f35e7a mark all tests requiring Python 2
Summary:
This diff marks **ALL** mercurial tests requiring Python 2 feature.

After you fixes some tests, simply remove the `py2` feature requirement and that tests will be continuously run after your diff is landed.

To bypass this feature requirement, run the tests command with `HGTEST_FORCE_PY2=1`. For example:

```
HGTEST_FORCE_PY2=1 buck test //eden/scm/tests:hg_run_tests
```

or

```
HGTEST_FORCE_PY2=1 python run-tests.py
```

----

Basically this diff are created with the following commands:

```
$ sed -i 's/import feature\(.*\)$/import feature\1\n\nfeature.require(["py2"])/' test-*-t.py
$ sed -i '1s/^/#require py2\n/' test-*.t
$ ls | grep -P "^test.*(?<\!-t)\.py$" > list && vim -p $(cat list)
# manually adding feature requires for these Python tests.
```

(Note: this ignores all push blocking failures!)

ignore-conflict-markers

Reviewed By: singhsrb

Differential Revision: D19655148

fbshipit-source-id: 985e3ccb4010cc559049f1d89f8909bc2d9b5e20
2020-01-30 18:49:21 -08:00

220 lines
5.4 KiB
Perl

#require py2
#chg-compatible
Tests JSON Input support for histedit
$ . "$TESTDIR/histedit-helpers.sh"
$ configure evolution
$ enable fbhistedit histedit rebase
$ initrepo ()
> {
> hg init r
> cd r
> for x in a b c ; do
> echo $x > $x
> hg add $x
> hg ci -m $x
> done
> }
$ initrepo
log before edit
$ hg log --graph -T "{rev}:{node|short} {desc}"
@ 2:177f92b77385 c
|
o 1:d2ae7f538514 b
|
o 0:cb9a9f314b8b a
passing a json with invalid format
$ cat >> input <<EOF
> {
> "rebase": [
> {"action": "foo", "node": "cb9a9f314b8b"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands input
invalid JSON format, falling back to normal parsing
hg: parse error: malformed line "{"
[255]
$ cat >> input2 <<EOF
> {
> "histedit": [
> {"node": "cb9a9f314b8b"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands input2
invalid JSON format, falling back to normal parsing
hg: parse error: malformed line "{"
[255]
$ cat >> input3 <<EOF
> {
> "histedit": [
> {"action": "pick", "node": "cb9a9f314b8b"},
> {"action": "pick"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands input3
invalid JSON format, falling back to normal parsing
hg: parse error: malformed line "{"
[255]
passing a json with invalid action
$ cat >> foo <<EOF
> {
> "histedit": [
> {"action": "foo", "node": "cb9a9f314b8b"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands foo
hg: parse error: unknown action "foo"
[255]
passing a json with invalid node
$ cat >> bar <<EOF
> {
> "histedit": [
> {"action": "pick", "node": "123456abcdef"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "pick", "node": "177f92b77385"}
> ]
> }
> EOF
$ hg histedit --commands bar
hg: parse error: unknown changeset 123456abcdef listed
[255]
running histedit with a valid json file
$ cat >> a.json <<EOF
> {
> "histedit": [
> {"action": "pick", "node": "cb9a9f314b8b"},
> {"action": "exec", "command": "hg exp"},
> {"action": "pick", "node": "177f92b77385"},
> {"action": "exec", "command": "hg exp"},
> {"action": "pick", "node": "d2ae7f538514"},
> {"action": "exec", "command": "hg exp"}
> ]
> }
> EOF
$ hg histedit --commands a.json
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
# Parent 0000000000000000000000000000000000000000
a
diff -r 000000000000 -r cb9a9f314b8b a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/a Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+a
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID b346ab9a313db8537ecf96fca3ca3ca984ef3bd7
# Parent cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
c
diff -r cb9a9f314b8b -r b346ab9a313d c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/c Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+c
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 503d1c1b466881fd108c7d4d26e78b510df14350
# Parent b346ab9a313db8537ecf96fca3ca3ca984ef3bd7
b
diff -r b346ab9a313d -r 503d1c1b4668 b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/b Thu Jan 01 00:00:00 1970 +0000
@@ -0,0 +1,1 @@
+b
log after histedit
$ hg log --graph -T "{rev}:{node|short} {desc}"
@ 4:503d1c1b4668 b
|
o 3:b346ab9a313d c
|
o 0:cb9a9f314b8b a
testing with abbreviated/small verbs
$ cat >> small <<EOF
> {
> "histedit": [
> {"action": "p", "node": "cb9a9f314b8b"},
> {"action": "p", "node": "503d1c1b4668"},
> {"action": "p", "node": "b346ab9a313d"}
> ]
> }
> EOF
$ hg histedit --commands small
$ hg log --graph -T "{rev}:{node} {desc}"
@ 6:573a8c672aaf44d2cf3f9467e5463f51f7414084 c
|
o 5:85032a8e4f13e773c4075d7c006e0f1bc1c63967 b
|
o 0:cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b a
more testing with full hashes
$ cat >> b.json <<EOF
> {
> "histedit": [
> {"action": "pick", "node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"},
> {"action": "pick", "node": "85032a8e4f13e773c4075d7c006e0f1bc1c63967"},
> {"action": "roll", "node": "573a8c672aaf44d2cf3f9467e5463f51f7414084"}
> ]
> }
> EOF
$ hg histedit --commands b.json
$ hg log --graph -T "{rev}:{node|short} {desc}"
@ 8:04e1eac0d294 b
|
o 0:cb9a9f314b8b a