##// END OF EJS Templates
fix: use a portable python script instead of sed in test...
Danny Hooper -
r37578:41ba336d default
parent child Browse files
Show More
@@ -1,3 +1,19 b''
1 A script that implements uppercasing all letters in a file.
2
3 $ UPPERCASEPY="$TESTTMP/uppercase.py"
4 $ cat > $UPPERCASEPY <<EOF
5 > import sys
6 > from mercurial.utils.procutil import setbinary
7 > setbinary(sys.stdin)
8 > setbinary(sys.stdout)
9 > sys.stdout.write(sys.stdin.read().upper())
10 > EOF
11 $ TESTLINES="foo\nbar\nbaz\n"
12 $ printf $TESTLINES | $PYTHON $UPPERCASEPY
13 FOO
14 BAR
15 BAZ
16
1 Tests for the fix extension's behavior around non-trivial history topologies.
17 Tests for the fix extension's behavior around non-trivial history topologies.
2 Looks for correct incremental fixing and reproduction of parent/child
18 Looks for correct incremental fixing and reproduction of parent/child
3 relationships. We indicate fixed file content by uppercasing it.
19 relationships. We indicate fixed file content by uppercasing it.
@@ -6,7 +22,7 b' relationships. We indicate fixed file co'
6 > [extensions]
22 > [extensions]
7 > fix =
23 > fix =
8 > [fix]
24 > [fix]
9 > uppercase-whole-file:command=sed -e 's/.*/\U&/'
25 > uppercase-whole-file:command=$PYTHON $UPPERCASEPY
10 > uppercase-whole-file:fileset=set:**
26 > uppercase-whole-file:fileset=set:**
11 > EOF
27 > EOF
12
28
@@ -1,3 +1,58 b''
1 A script that implements uppercasing of specific lines in a file. This
2 approximates the behavior of code formatters well enough for our tests.
3
4 $ UPPERCASEPY="$TESTTMP/uppercase.py"
5 $ cat > $UPPERCASEPY <<EOF
6 > import sys
7 > from mercurial.utils.procutil import setbinary
8 > setbinary(sys.stdin)
9 > setbinary(sys.stdout)
10 > lines = set()
11 > for arg in sys.argv[1:]:
12 > if arg == 'all':
13 > sys.stdout.write(sys.stdin.read().upper())
14 > sys.exit(0)
15 > else:
16 > first, last = arg.split('-')
17 > lines.update(range(int(first), int(last) + 1))
18 > for i, line in enumerate(sys.stdin.readlines()):
19 > if i + 1 in lines:
20 > sys.stdout.write(line.upper())
21 > else:
22 > sys.stdout.write(line)
23 > EOF
24 $ TESTLINES="foo\nbar\nbaz\nqux\n"
25 $ printf $TESTLINES | $PYTHON $UPPERCASEPY
26 foo
27 bar
28 baz
29 qux
30 $ printf $TESTLINES | $PYTHON $UPPERCASEPY all
31 FOO
32 BAR
33 BAZ
34 QUX
35 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 1-1
36 FOO
37 bar
38 baz
39 qux
40 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 1-2
41 FOO
42 BAR
43 baz
44 qux
45 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 2-3
46 foo
47 BAR
48 BAZ
49 qux
50 $ printf $TESTLINES | $PYTHON $UPPERCASEPY 2-2 4-4
51 foo
52 BAR
53 baz
54 QUX
55
1 Set up the config with two simple fixers: one that fixes specific line ranges,
56 Set up the config with two simple fixers: one that fixes specific line ranges,
2 and one that always fixes the whole file. They both "fix" files by converting
57 and one that always fixes the whole file. They both "fix" files by converting
3 letters to uppercase. They use different file extensions, so each test case can
58 letters to uppercase. They use different file extensions, so each test case can
@@ -10,10 +65,10 b' choose which behavior to use by naming f'
10 > evolution.createmarkers=True
65 > evolution.createmarkers=True
11 > evolution.allowunstable=True
66 > evolution.allowunstable=True
12 > [fix]
67 > [fix]
13 > uppercase-whole-file:command=sed -e 's/.*/\U&/'
68 > uppercase-whole-file:command=$PYTHON $UPPERCASEPY all
14 > uppercase-whole-file:fileset=set:**.whole
69 > uppercase-whole-file:fileset=set:**.whole
15 > uppercase-changed-lines:command=sed
70 > uppercase-changed-lines:command=$PYTHON $UPPERCASEPY
16 > uppercase-changed-lines:linerange=-e '{first},{last} s/.*/\U&/'
71 > uppercase-changed-lines:linerange={first}-{last}
17 > uppercase-changed-lines:fileset=set:**.changed
72 > uppercase-changed-lines:fileset=set:**.changed
18 > EOF
73 > EOF
19
74
@@ -878,7 +933,7 b' useful for anyone trying to set up a new'
878 $ hg commit -Aqm "foo"
933 $ hg commit -Aqm "foo"
879 $ printf "Foo\nbar\nBaz\n" > foo.changed
934 $ printf "Foo\nbar\nBaz\n" > foo.changed
880 $ hg --debug fix --working-dir
935 $ hg --debug fix --working-dir
881 subprocess: sed -e '1,1 s/.*/\U&/' -e '3,3 s/.*/\U&/'
936 subprocess: * $TESTTMP/uppercase.py 1-1 3-3 (glob)
882
937
883 $ cd ..
938 $ cd ..
884
939
General Comments 0
You need to be logged in to leave comments. Login now