diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-09-02 15:17:48 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-09-02 15:17:48 -0300 |
commit | 33d25b1669930f0ac6b3f402bd760685552af48f (patch) | |
tree | 68597282cc99f94da5f17594111102f1fc34c96d | |
parent | 078e42b295eb2d05cdd4a99a9c76a84a45292cb3 (diff) | |
download | luarocks-33d25b1669930f0ac6b3f402bd760685552af48f.tar.gz luarocks-33d25b1669930f0ac6b3f402bd760685552af48f.tar.bz2 luarocks-33d25b1669930f0ac6b3f402bd760685552af48f.zip |
add regression test utility
-rwxr-xr-x | test_regression.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/test_regression.sh b/test_regression.sh new file mode 100755 index 00000000..4780893f --- /dev/null +++ b/test_regression.sh | |||
@@ -0,0 +1,86 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | # ## Usage examples: | ||
4 | # | ||
5 | # Test current branch against master: | ||
6 | # test_regression.sh | ||
7 | # Test current branch against another branch: | ||
8 | # test_regression.sh another-branch | ||
9 | # Test current branch against master passing arguments to busted: | ||
10 | # test_regression.sh -- --exclude-tags=flaky | ||
11 | # Test current branch against next passing arguments to busted: | ||
12 | # test_regression.sh next -- --exclude-tags=flaky | ||
13 | |||
14 | if [ $(git status --untracked-files=no --porcelain | wc -l) != "0" ] | ||
15 | then | ||
16 | echo "==============================" | ||
17 | echo "Local tree is not clean, please commit or stash before running this." | ||
18 | echo "==============================" | ||
19 | exit 1 | ||
20 | fi | ||
21 | |||
22 | newbranch=$(git rev-parse --abbrev-ref HEAD) | ||
23 | if [ "$newbranch" = "master" ] || [ "$newbranch" = "next" ] | ||
24 | then | ||
25 | echo "==============================" | ||
26 | echo "Please run this from a topic branch, and not from 'next' or 'master'." | ||
27 | echo "==============================" | ||
28 | exit 1 | ||
29 | fi | ||
30 | |||
31 | basebranch="$1" | ||
32 | if [ "$1" == "" ] || [ "$1" == "--" ] | ||
33 | then | ||
34 | basebranch=master | ||
35 | else | ||
36 | basebranch="$1" | ||
37 | shift | ||
38 | fi | ||
39 | if [ "$1" == "--" ] | ||
40 | then | ||
41 | shift | ||
42 | fi | ||
43 | |||
44 | git checkout "$newbranch" | ||
45 | rm -rf .spec-new | ||
46 | rm -rf .spec-old | ||
47 | cp -a spec .spec-new | ||
48 | git checkout "$basebranch" | ||
49 | |||
50 | echo "----------------------------------------" | ||
51 | echo "Tests changed between $basebranch and $newbranch:" | ||
52 | echo "----------------------------------------" | ||
53 | specfiles=($(git diff-tree --no-commit-id --name-only -r "..$newbranch" | grep "^spec/")) | ||
54 | echo "${specfiles[@]}" | ||
55 | echo "----------------------------------------" | ||
56 | |||
57 | mv spec .spec-old | ||
58 | mv .spec-new spec | ||
59 | ./luarocks test -- "${specfiles[@]}" "$@" | ||
60 | if [ $? = 0 ] | ||
61 | then | ||
62 | git checkout . | ||
63 | git checkout $newbranch | ||
64 | echo "==============================" | ||
65 | echo "Regression test does not trigger the issue in base branch" | ||
66 | echo "==============================" | ||
67 | exit 1 | ||
68 | fi | ||
69 | mv spec .spec-new | ||
70 | mv .spec-old spec | ||
71 | git checkout $newbranch | ||
72 | ./luarocks test -- "${specfiles[@]}" "$@" | ||
73 | ret=$? | ||
74 | if [ "$ret" != "0" ] | ||
75 | then | ||
76 | echo "==============================" | ||
77 | echo "New branch does not fix issue (returned $ret)" | ||
78 | echo "==============================" | ||
79 | exit 1 | ||
80 | fi | ||
81 | |||
82 | echo "==============================" | ||
83 | echo "All good! New branch fixes regression!" | ||
84 | echo "==============================" | ||
85 | exit 0 | ||
86 | |||