Show More
@@ -1,27 +1,36 b'' | |||||
1 | A simple testing framework |
|
1 | A simple testing framework | |
2 |
|
2 | |||
|
3 | To run the tests, do: | |||
|
4 | ||||
|
5 | cd tests/ | |||
|
6 | ./run-tests | |||
|
7 | ||||
3 | This finds all scripts in the test directory named test-* and executes |
|
8 | This finds all scripts in the test directory named test-* and executes | |
4 | them. The scripts can be either shell scripts or Python. Each test is |
|
9 | them. The scripts can be either shell scripts or Python. Each test is | |
5 | run in a temporary directory that is removed when the test is complete. |
|
10 | run in a temporary directory that is removed when the test is complete. | |
6 |
|
11 | |||
7 | A test-<x> succeeds if the script returns success and its output |
|
12 | A test-<x> succeeds if the script returns success and its output | |
8 | matches test-<x>.out. If the new output doesn't match, it is stored in |
|
13 | matches test-<x>.out. If the new output doesn't match, it is stored in | |
9 | test-<x>.err. |
|
14 | test-<x>.err. | |
10 |
|
15 | |||
11 | There are some tricky points here that you should be aware of when |
|
16 | There are some tricky points here that you should be aware of when | |
12 | writing tests: |
|
17 | writing tests: | |
13 |
|
18 | |||
14 | - hg commit and hg up -m want user interaction |
|
19 | - hg commit and hg up -m want user interaction | |
15 |
|
20 | |||
16 | for commit use -t "text" |
|
21 | for commit use -t "text" | |
17 | for hg up -m, set HGMERGE to something noninteractive (like true or merge) |
|
22 | for hg up -m, set HGMERGE to something noninteractive (like true or merge) | |
18 |
|
23 | |||
19 | - changeset hashes will change based on user and date which make |
|
24 | - changeset hashes will change based on user and date which make | |
20 | things like hg history output change |
|
25 | things like hg history output change | |
21 |
|
26 | |||
22 | use commit -t "test" -u test -d "0 0" |
|
27 | use commit -t "test" -u test -d "0 0" | |
23 |
|
28 | |||
24 | - diff will show the current time |
|
29 | - diff will show the current time | |
25 |
|
30 | |||
26 | use hg diff | sed "s/\(\(---\|+++\).*\)\t.*/\1/" to strip dates |
|
31 | use hg diff | sed "s/\(\(---\|+++\).*\)\t.*/\1/" to strip dates | |
27 |
|
32 | |||
|
33 | - set -x and pipelines don't generate stable output | |||
|
34 | ||||
|
35 | turn off set -x or break pipelines into pieces | |||
|
36 |
@@ -1,35 +1,37 b'' | |||||
1 | #!/bin/bash |
|
1 | #!/bin/bash | |
2 |
|
2 | |||
3 | export HGMERGE=true |
|
3 | export HGMERGE=true | |
4 |
|
4 | |||
5 | set -ex |
|
5 | set -ex | |
6 | mkdir r1 |
|
6 | mkdir r1 | |
7 | cd r1 |
|
7 | cd r1 | |
8 | hg init |
|
8 | hg init | |
9 | echo a > a |
|
9 | echo a > a | |
10 | hg addremove |
|
10 | hg addremove | |
11 | hg commit -t "1" -u test -d "0 0" |
|
11 | hg commit -t "1" -u test -d "0 0" | |
12 |
|
12 | |||
13 | cd .. |
|
13 | cd .. | |
14 | mkdir r2 |
|
14 | mkdir r2 | |
15 | cd r2 |
|
15 | cd r2 | |
16 | hg init ../r1 |
|
16 | hg init ../r1 | |
17 | hg up |
|
17 | hg up | |
18 | echo abc > a |
|
18 | echo abc > a | |
19 | hg diff | sed "s/\(\(---\|+++\).*\)\t.*/\1/" |
|
19 | hg diff > ../d | |
|
20 | sed "s/\(\(---\|+++\).*\)\t.*/\1/" < ../d | |||
20 |
|
21 | |||
21 | cd ../r1 |
|
22 | cd ../r1 | |
22 | echo b > b |
|
23 | echo b > b | |
23 | echo a2 > a |
|
24 | echo a2 > a | |
24 | hg addremove |
|
25 | hg addremove | |
25 | hg commit -t "2" -u test -d "0 0" |
|
26 | hg commit -t "2" -u test -d "0 0" | |
26 |
|
27 | |||
27 | cd ../r2 |
|
28 | cd ../r2 | |
28 | hg -q pull ../r1 |
|
29 | hg -q pull ../r1 | |
29 | hg status |
|
30 | hg status | |
30 | hg -d up |
|
31 | hg -d up | |
31 | hg -d up -m |
|
32 | hg -d up -m | |
32 | hg parents |
|
33 | hg parents | |
33 | hg -v history |
|
34 | hg -v history | |
34 | hg diff | sed "s/\(\(---\|+++\).*\)\t.*/\1/" |
|
35 | hg diff > ../d | |
|
36 | sed "s/\(\(---\|+++\).*\)\t.*/\1/" < ../d | |||
35 |
|
37 |
General Comments 0
You need to be logged in to leave comments.
Login now