From 95aeb27f0bc07e91002e726b981c517ca9b2fbf7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Oct 2018 21:08:49 -0400 Subject: [PATCH] feat: add timing info --- .circleci/config.yml | 6 ++++++ .gitignore | 1 + tests.mk | 5 +++-- tests/organize-tests | 31 +++++++++++++++++++++++++++++++ tests/unit/10_tar.bats | 2 +- 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100755 tests/organize-tests diff --git a/.circleci/config.yml b/.circleci/config.yml index 056410ca2..419719e1c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,6 +8,7 @@ jobs: - run: | make ci-dependencies - run: | + ./contrib/release build ./tests/ci/setup.sh - run: | echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup @@ -27,3 +28,8 @@ jobs: no_output_timeout: 60m - store_artifacts: path: ./coverage.out + - store_artifacts: + path: ./test-results + destination: test-results + - store_test_results: + path: test-results diff --git a/.gitignore b/.gitignore index 47cf7b700..9323ab8a3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .vagrant build/ data/ +test-results/ stack.tgz tmp coverage.out diff --git a/tests.mk b/tests.mk index 3acc43968..9bce5a385 100644 --- a/tests.mk +++ b/tests.mk @@ -209,5 +209,6 @@ deploy-tests: test: setup-deploy-tests lint unit-tests deploy-tests test-ci: - @echo "executing tests: $(shell circleci tests glob tests/unit/*.bats | circleci tests split --split-by=timings | xargs)" - bats $(shell circleci tests glob tests/unit/*.bats | circleci tests split --split-by=timings | xargs) + mkdir -p test-results/bats + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; circleci tests glob *.bats | circleci tests split --split-by=timings | xargs)" + cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; circleci tests glob *.bats | circleci tests split --split-by=timings | xargs) diff --git a/tests/organize-tests b/tests/organize-tests new file mode 100755 index 000000000..6e93d09be --- /dev/null +++ b/tests/organize-tests @@ -0,0 +1,31 @@ +#!/usr/bin/env python +import errno +import glob +import os +import xml.etree.ElementTree as ET + +def mkdir_p(directory_name): + try: + os.makedirs(directory_name) + except OSError as exc: + if exc.errno == errno.EEXIST and os.path.isdir(directory_name): + pass + +def main(): + root_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') + test_results_path = os.path.realpath(os.path.join(root_path, 'test-results')) + test_file_glob = os.path.join(test_results_path, 'bats', '*.xml') + + files = glob.glob(test_file_glob) + for file in files: + tree = ET.parse(file) + root = tree.getroot() + name = root.attrib['name'] + if name == '': + continue + new_path = '{0}/{1}/results.xml'.format(test_results_path, name.replace('.bats', '')) + mkdir_p(os.path.dirname(new_path)) + os.rename(file, new_path) + +if __name__ == "__main__": + main() diff --git a/tests/unit/10_tar.bats b/tests/unit/10_tar.bats index 519dbe577..7b2fe1fc4 100644 --- a/tests/unit/10_tar.bats +++ b/tests/unit/10_tar.bats @@ -16,7 +16,7 @@ deploy_app_tar() { APP_TYPE="$1"; APP_TYPE=${APP_TYPE:="nodejs-express"} TMP=$(mktemp -d "/tmp/dokku.me.XXXXX") - rmdir "$TMP" && cp -r "./tests/apps/$APP_TYPE" "$TMP" + rmdir "$TMP" && cp -r "${BATS_TEST_DIRNAME}/../../tests/apps/$APP_TYPE" "$TMP" pushd "$TMP" &> /dev/null || exit 1 trap 'popd &> /dev/null || true; rm -rf "$TMP"' RETURN INT TERM