2019-12-10 02:24:31 +03:00
|
|
|
#chg-compatible
|
|
|
|
|
2019-07-18 06:59:57 +03:00
|
|
|
#require parso
|
|
|
|
|
|
|
|
$ cat > a.py << EOF
|
|
|
|
> from testutil.autofix import eq
|
2019-09-10 22:58:22 +03:00
|
|
|
> from testutil.dott import sh
|
2019-07-18 06:59:57 +03:00
|
|
|
> eq(1 + 2, 0)
|
|
|
|
> eq(list(range(3)), None)
|
|
|
|
> eq("\n".join(map(str,range(3))), None)
|
2019-09-10 22:58:22 +03:00
|
|
|
> sh % "printf foo"
|
|
|
|
> sh % "printf bar" == "baz"
|
2019-07-18 06:59:57 +03:00
|
|
|
> EOF
|
|
|
|
|
2019-09-21 03:43:59 +03:00
|
|
|
$ hg debugpython -- a.py 2>&1 | tail -1
|
testutil/dott: simplify error messages
Summary:
The current error message is a bit noisy. Let's just get to the point about the
filename and line number that is interesting without tracebacks. This only
affects functions using the `autofix.eq` API, other kinds of exceptions will
have tracebacks as usual.
Before, run-tests.py (19 lines):
--- test-empty-t.py.out
+++ test-empty-t.py.err
@@ -0,0 +1,14 @@
+Traceback (most recent call last):
+ File "hg/tests/test-empty-t.py", line 71, in <module>
+ """
+ File "hg/tests/testutil/dott/shobj.py", line 89, in __eq__
+ autofix.eq(out, rhs, nested=1, eqfunc=eqglob)
+ File "hg/tests/testutil/autofix.py", line 93, in eq
+ raise AssertionError("actual != expected\n%s" % diff)
+AssertionError: actual != expected
+--- expected
++++ actual
+@@ -1 +1 @@
+-someheads
++allheads
+
ERROR: test-empty-t.py output changed
Before, run directly via python (13 lines):
Traceback (most recent call last):
File "test-empty-t.py", line 71, in <module>
"""
File "hg/tests/testutil/dott/shobj.py", line 89, in __eq__
autofix.eq(out, rhs, nested=1, eqfunc=eqglob)
File "hg/tests/testutil/autofix.py", line 93, in eq
raise AssertionError("actual != expected\n%s" % diff)
AssertionError: actual != expected
--- expected
+++ actual
@@ -1 +1 @@
-someheads
+allheads
After, run-tests.py (8 lines):
--- test-empty-t.py:71 (expected)
+++ test-empty-t.py:71 (actual)
@@ -1 +1 @@
-someheads
+allheads
ERROR: test-empty-t.py output changed
After, run directly (5 lines):
% python test-empty-t.py
--- test-empty-t.py:71 (expected)
+++ test-empty-t.py:71 (actual)
@@ -1 +1 @@
-someheads
+allheads
Reviewed By: xavierd
Differential Revision: D17277286
fbshipit-source-id: a48d4d1e817f67e221a901977e0c0f8bdc1a62ab
2019-09-10 22:58:22 +03:00
|
|
|
a.py:3: 3 != 0
|
2019-07-18 06:59:57 +03:00
|
|
|
|
2019-09-21 03:43:59 +03:00
|
|
|
$ hg debugpython -- a.py --fix
|
2019-07-18 06:59:57 +03:00
|
|
|
$ cat a.py
|
|
|
|
from testutil.autofix import eq
|
2019-09-10 22:58:22 +03:00
|
|
|
from testutil.dott import sh
|
2019-07-18 06:59:57 +03:00
|
|
|
eq(1 + 2, 3)
|
|
|
|
eq(list(range(3)), [0, 1, 2])
|
|
|
|
eq("\n".join(map(str,range(3))), r"""
|
|
|
|
0
|
|
|
|
1
|
|
|
|
2""")
|
2019-09-10 22:58:22 +03:00
|
|
|
sh % "printf foo" == 'foo'
|
|
|
|
sh % "printf bar" == 'bar'
|