aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2019-09-02 15:17:48 -0300
committerHisham Muhammad <hisham@gobolinux.org>2019-09-02 15:17:48 -0300
commit33d25b1669930f0ac6b3f402bd760685552af48f (patch)
tree68597282cc99f94da5f17594111102f1fc34c96d
parent078e42b295eb2d05cdd4a99a9c76a84a45292cb3 (diff)
downloadluarocks-33d25b1669930f0ac6b3f402bd760685552af48f.tar.gz
luarocks-33d25b1669930f0ac6b3f402bd760685552af48f.tar.bz2
luarocks-33d25b1669930f0ac6b3f402bd760685552af48f.zip
add regression test utility
-rwxr-xr-xtest_regression.sh86
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
14if [ $(git status --untracked-files=no --porcelain | wc -l) != "0" ]
15then
16 echo "=============================="
17 echo "Local tree is not clean, please commit or stash before running this."
18 echo "=============================="
19 exit 1
20fi
21
22newbranch=$(git rev-parse --abbrev-ref HEAD)
23if [ "$newbranch" = "master" ] || [ "$newbranch" = "next" ]
24then
25 echo "=============================="
26 echo "Please run this from a topic branch, and not from 'next' or 'master'."
27 echo "=============================="
28 exit 1
29fi
30
31basebranch="$1"
32if [ "$1" == "" ] || [ "$1" == "--" ]
33then
34 basebranch=master
35else
36 basebranch="$1"
37 shift
38fi
39if [ "$1" == "--" ]
40then
41 shift
42fi
43
44git checkout "$newbranch"
45rm -rf .spec-new
46rm -rf .spec-old
47cp -a spec .spec-new
48git checkout "$basebranch"
49
50echo "----------------------------------------"
51echo "Tests changed between $basebranch and $newbranch:"
52echo "----------------------------------------"
53specfiles=($(git diff-tree --no-commit-id --name-only -r "..$newbranch" | grep "^spec/"))
54echo "${specfiles[@]}"
55echo "----------------------------------------"
56
57mv spec .spec-old
58mv .spec-new spec
59./luarocks test -- "${specfiles[@]}" "$@"
60if [ $? = 0 ]
61then
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
68fi
69mv spec .spec-new
70mv .spec-old spec
71git checkout $newbranch
72./luarocks test -- "${specfiles[@]}" "$@"
73ret=$?
74if [ "$ret" != "0" ]
75then
76 echo "=============================="
77 echo "New branch does not fix issue (returned $ret)"
78 echo "=============================="
79 exit 1
80fi
81
82echo "=============================="
83echo "All good! New branch fixes regression!"
84echo "=============================="
85exit 0
86