Show More
@@ -968,6 +968,13 b' class Test(unittest.TestCase):' | |||||
968 | ] |
|
968 | ] | |
969 | r.append((self._escapepath(self._testtmp), b'$TESTTMP')) |
|
969 | r.append((self._escapepath(self._testtmp), b'$TESTTMP')) | |
970 |
|
970 | |||
|
971 | testdir = os.path.dirname(self.path) | |||
|
972 | replacementfile = os.path.join(testdir, 'common-pattern.py') | |||
|
973 | ||||
|
974 | if os.path.exists(replacementfile): | |||
|
975 | data = {} | |||
|
976 | execfile(replacementfile, data) | |||
|
977 | r.extend(data.get('substitutions', ())) | |||
971 | return r |
|
978 | return r | |
972 |
|
979 | |||
973 | def _escapepath(self, p): |
|
980 | def _escapepath(self, p): |
@@ -1503,3 +1503,43 b' Test cases in .t files' | |||||
1503 | # Ran 2 tests, 0 skipped, 1 failed. |
|
1503 | # Ran 2 tests, 0 skipped, 1 failed. | |
1504 | python hash seed: * (glob) |
|
1504 | python hash seed: * (glob) | |
1505 | [1] |
|
1505 | [1] | |
|
1506 | ||||
|
1507 | Test automatic pattern replacement | |||
|
1508 | ||||
|
1509 | $ cat << EOF >> common-pattern.py | |||
|
1510 | > substitutions = [ | |||
|
1511 | > (br'foo-(.*)\\b', | |||
|
1512 | > br'\$XXX=\\1\$'), | |||
|
1513 | > (br'bar\\n', | |||
|
1514 | > br'\$YYY$\\n'), | |||
|
1515 | > ] | |||
|
1516 | > EOF | |||
|
1517 | ||||
|
1518 | $ cat << EOF >> test-substitution.t | |||
|
1519 | > $ echo foo-12 | |||
|
1520 | > \$XXX=12$ | |||
|
1521 | > $ echo foo-42 | |||
|
1522 | > \$XXX=42$ | |||
|
1523 | > $ echo bar prior | |||
|
1524 | > bar prior | |||
|
1525 | > $ echo lastbar | |||
|
1526 | > last\$YYY$ | |||
|
1527 | > $ echo foo-bar foo-baz | |||
|
1528 | > EOF | |||
|
1529 | ||||
|
1530 | $ rt test-substitution.t | |||
|
1531 | ||||
|
1532 | --- $TESTTMP/anothertests/cases/test-substitution.t | |||
|
1533 | +++ $TESTTMP/anothertests/cases/test-substitution.t.err | |||
|
1534 | @@ -7,3 +7,4 @@ | |||
|
1535 | $ echo lastbar | |||
|
1536 | last$YYY$ | |||
|
1537 | $ echo foo-bar foo-baz | |||
|
1538 | + $XXX=bar foo-baz$ | |||
|
1539 | ||||
|
1540 | ERROR: test-substitution.t output changed | |||
|
1541 | ! | |||
|
1542 | Failed test-substitution.t: output changed | |||
|
1543 | # Ran 1 tests, 0 skipped, 1 failed. | |||
|
1544 | python hash seed: * (glob) | |||
|
1545 | [1] |
General Comments 0
You need to be logged in to leave comments.
Login now