summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLukas Eipert <leipert@gitlab.com>2019-01-17 23:43:04 +0100
committerLukas Eipert <leipert@gitlab.com>2019-02-05 20:51:50 +0100
commitb8649698432652f4d198b47ccd7f6eed64a135ee (patch)
tree284efefd684805dfc79eefc1a47b863b8188d26f /test
parent50e15d06701014530e8a6379b3172edd85d011ed (diff)
Parallelize QA tests
Test projects are now given as a parameter to the test command
Diffstat (limited to 'test')
-rwxr-xr-xtest/test.sh58
1 files changed, 35 insertions, 23 deletions
diff --git a/test/test.sh b/test/test.sh
index 53c1805..bbf66f7 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -2,26 +2,38 @@
set -e
-for project in ruby-bundler-rails java-maven; do
- # Clone the test repository.
- echo "Cloning the test repository https://gitlab.com/gitlab-org/security-products/tests/$project.git"
- git clone "https://gitlab.com/gitlab-org/security-products/tests/$project.git" "/code/$project"
-
- # Run license management on it.
- echo "Running license management on the $project"
- cd "/code/$project"
- /run.sh analyze .
-
- # Compare results with expected results.
- set +e
- diff "/code/$project/gl-license-management-report.json" "/test/results/$project.json" > /diff.txt
- set -e
-
- if [ -s /diff.txt ] ; then
- echo "Unexpected result. Here is the diff between actual results and those expected :"
- cat /diff.txt
- exit 1
- fi
-done
-
-echo "All tests are OK."
+project=$1
+ref=$2
+url="https://gitlab.com/gitlab-org/security-products/tests/$project.git"
+
+# Clone the test repository.
+echo "Cloning the test project $project from $url"
+git clone "$url" "/code/$project"
+
+# Run license management on it.
+echo "Running license management on the $project with ref $ref"
+cd "/code/$project"
+git checkout "$ref" 2> /dev/null
+/run.sh analyze .
+
+mkdir -p /results/
+# In order to upload the artifact always
+cp "/code/$project/gl-license-management-report.json" "/results/$project-gl-license-management-report.json"
+
+# Compare results with expected results.
+set +e
+
+diff "/code/$project/gl-license-management-report.json" "/test/results/$project.json" > /diff.txt
+error=$?
+if [[ $error -eq 0 ]]; then
+ echo "The report matches the fixture."
+ exit 0
+elif [[ $error -eq 1 ]]; then
+ echo "Unexpected result. Here is the diff between actual results and those expected :"
+ cat /diff.txt
+ mv /diff.txt "/results/$project-diff.txt"
+else
+ echo "Could not compare the fixture to the generated report"
+fi
+
+exit 1