From b8649698432652f4d198b47ccd7f6eed64a135ee Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Thu, 17 Jan 2019 23:43:04 +0100 Subject: Parallelize QA tests Test projects are now given as a parameter to the test command --- test/test.sh | 58 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 23 deletions(-) (limited to 'test') 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 -- cgit v1.2.3