From 89e97b05daf6fd98fce48cf3fef624e55905af46 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 30 Aug 2017 01:17:58 +0300 Subject: Add into .gitlab-ci.yml job for run separatly all unit tests. --- .gitlab-ci.yml | 13 ++++++++ build/bmaketest | 2 +- tools/ci/scripts/gettests.py | 62 +++++++++++++++++++++++++++++++++++ tools/ci/scripts/separateunittests.sh | 17 ++++++++++ tools/ci/scripts/test.sh | 6 ++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100755 tools/ci/scripts/gettests.py create mode 100755 tools/ci/scripts/separateunittests.sh create mode 100755 tools/ci/scripts/test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 67dafeca7..ba85e0223 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1629,6 +1629,19 @@ gcc-7_tests_tcmalloc_sdl2_i386: tags: - docker +gcc-7_separate_doctest: + stage: prebuild + script: + - ./tools/ci/jobs/gcc7_silent.sh --enable-unittestsbin=doctest --without-manaplusgame --without-dyecmd + - ./tools/ci/scripts/separateunittests.sh + <<: *job-push + variables: + PACKAGES: gcc-7 g++-7 + make autoconf automake autopoint gettext + libxml2-dev libcurl4-gnutls-dev libpng-dev + libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev + python + gcc-7_lto: stage: build script: diff --git a/build/bmaketest b/build/bmaketest index 85acc944b..a0712db15 100755 --- a/build/bmaketest +++ b/build/bmaketest @@ -21,7 +21,7 @@ autoreconf -i --datadir=$dir/run/share/games \ --bindir=$dir/run/bin \ --mandir=$dir/run/share/man \ ---enable-unittests +--enable-unittests=doctest cd po make -j8 update-gmo 2>../build/make1.log diff --git a/tools/ci/scripts/gettests.py b/tools/ci/scripts/gettests.py new file mode 100755 index 000000000..ff2b89faa --- /dev/null +++ b/tools/ci/scripts/gettests.py @@ -0,0 +1,62 @@ +#! /usr/bin/env python +# -*- coding: utf8 -*- +# +# Copyright (C) 2017 Andrei Karas + +import os +import re + +testCaseRe = re.compile("^TEST_CASE[(]\"(?P([\w ()_:.,]*))\",[ ]\"(?P([\w ()_:.,]*))\"[)]$") +sectionRe = re.compile("^([ ]*)SECTION[(]\"(?P([\w ()_:.,]*))\"[)]$") + + +def printTestCase(testCase): +# print("func --test-case=\"{0}\"".format(testCase)) +# print("func \"{0}\" \"\"".format(testCase)) + print("\"{0}\" \"\"".format(testCase)) + + +def printSection(testCase, section): +# print("func --test-case=\"{0}\" --subcase=\"{1}\"".format(testCase, section)) +# print("func \"{0}\" \"{1}\"".format(testCase, section)) + print("\"{0}\" \"{1}\"".format(testCase, section)) + + +def parseCC(srcFile): + with open(srcFile, "r") as r: + testCase = "" + sectionsCount = 0 + for line in r: + m = testCaseRe.search(line) + if m != None: + if testCase != "" and sectionsCount == 0: + printTestCase(testCase) + testCase = m.group("name1") + " " + m.group("name2") + sectionsCount = 0 + elif line.find("TEST_CASE(\"") >= 0: + print("Error: test case regexp failed for: " + line) + exit(1) + m = sectionRe.search(line) + if m != None: + sectionsCount = sectionsCount + 1 + printSection(testCase, m.group("name")) + elif line.find("SECTION(\"") >= 0: + print("Error: section regexp failed for: " + line) + exit(1) + if testCase != "" and sectionsCount == 0: + printTestCase(testCase) + + +def enumFiles(srcDir): + files = os.listdir(srcDir) + for file1 in files: + if file1[0] == ".": + continue + srcPath = os.path.abspath(srcDir + os.path.sep + file1) + if os.path.isdir(srcPath): + enumFiles(srcPath) + elif file1[-3:] == ".cc": + parseCC(srcPath) + + +enumFiles("src/unittests") diff --git a/tools/ci/scripts/separateunittests.sh b/tools/ci/scripts/separateunittests.sh new file mode 100755 index 000000000..9db32ead8 --- /dev/null +++ b/tools/ci/scripts/separateunittests.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +export LIST=./logs/testslist.txt + +./tools/ci/scripts/gettests.py >${LIST} || exit 1 + +IFS=' +' + +for str in $(cat ${LIST}) +do + unset IFS + declare -a "arr=($str)" + echo ./src/manaplustests --test-case=\"${arr[0]}\" --subcase=\"${arr[1]}\" + ./src/manaplustests --test-case="${arr[0]}" --subcase="${arr[1]}" || exit 1 +done + diff --git a/tools/ci/scripts/test.sh b/tools/ci/scripts/test.sh new file mode 100755 index 000000000..4d4426780 --- /dev/null +++ b/tools/ci/scripts/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +echo 1: $1 +echo 2: $2 +echo 3: $3 +echo 4: $4 -- cgit v1.2.3-70-g09d2