From 5e0fc24c1a014bd5852debf198fbbdf345969147 Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 24 Nov 2017 17:40:24 +0000 Subject: [PATCH] Allow modules to specific their own acceptance tests --- services/web/Makefile | 21 +++++++++++++++++---- services/web/bin/acceptance_test | 16 +--------------- services/web/bin/generate_volumes_file | 2 +- services/web/package.json | 3 ++- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/services/web/Makefile b/services/web/Makefile index 25c0eb2cca..3955fe1d52 100644 --- a/services/web/Makefile +++ b/services/web/Makefile @@ -36,17 +36,30 @@ test: test_unit test_acceptance test_unit: docker-shared.yml docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} run --rm test_unit npm run test:unit -- ${MOCHA_ARGS} -test_acceptance: test_acceptance_start_service test_acceptance_run test_acceptance_stop_service +test_acceptance: test_acceptance_app test_acceptance_modules -test_acceptance_start_service: docker-shared.yml +test_acceptance_app: test_acceptance_app_start_service test_acceptance_app_run test_acceptance_app_stop_service + +test_acceptance_app_start_service: docker-shared.yml docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} up -d test_acceptance -test_acceptance_stop_service: docker-shared.yml +test_acceptance_app_stop_service: docker-shared.yml docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} stop test_acceptance redis mongo -test_acceptance_run: docker-shared.yml +test_acceptance_app_run: docker-shared.yml docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} exec -T test_acceptance npm run test:acceptance -- ${MOCHA_ARGS} +test_acceptance_modules: docker-shared.yml + for dir in modules/*; \ + do \ + if [ -e $$dir/makefile ]; then \ + (make test_acceptance_module MODULE=$$dir) \ + fi \ + done + +test_acceptance_module: docker-shared.yml + cd $(MODULE) && make test_acceptance + .PHONY: all add install update test test_unit test_acceptance \ test_acceptance_start_service test_acceptance_stop_service \ diff --git a/services/web/bin/acceptance_test b/services/web/bin/acceptance_test index 717e8542ad..fd2e5137b5 100755 --- a/services/web/bin/acceptance_test +++ b/services/web/bin/acceptance_test @@ -1,18 +1,4 @@ #!/bin/bash set -e; - MOCHA="node_modules/.bin/mocha --recursive --reporter spec --timeout 15000" - -$MOCHA "$@" test/acceptance/js - -# TODO: Module acceptance tests are hard to get working, -# because they typically require the server to be instantiated -# with a different config. - -# for dir in modules/*; -# do -# if [ -d $dir/test/acceptance/js ]; then -# $MOCHA "$@" $dir/test/acceptance/js -# fi -# done - +$MOCHA "$@" diff --git a/services/web/bin/generate_volumes_file b/services/web/bin/generate_volumes_file index 2117ff5342..d70ac11c3d 100755 --- a/services/web/bin/generate_volumes_file +++ b/services/web/bin/generate_volumes_file @@ -9,7 +9,7 @@ for module in listdir("modules/"): if module[0] != '.': if isfile(join("modules", module, 'index.coffee')): volumes.append(join("modules", module, 'index.coffee')) - for directory in ['app/coffee', 'app/views', 'public/coffee', 'test/unit/coffee', 'test/acceptance/coffee']: + for directory in ['app/coffee', 'app/views', 'public/coffee', 'test/unit/coffee', 'test/acceptance/coffee', 'test/acceptance/config']: if isdir(join("modules", module, directory)): volumes.append(join("modules", module, directory)) diff --git a/services/web/package.json b/services/web/package.json index a795df999e..b14cdf8b20 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -12,7 +12,8 @@ "scripts": { "test:acceptance:wait_for_app": "echo 'Waiting for app to be accessible' && while (! curl -s -o /dev/null localhost:3000/status) do sleep 1; done", "test:acceptance:run": "bin/acceptance_test $@", - "test:acceptance": "npm run compile:acceptance_tests && npm run test:acceptance:wait_for_app && npm run test:acceptance:run -- $@", + "test:acceptance:dir": "npm run compile:acceptance_tests && npm run test:acceptance:wait_for_app && npm run test:acceptance:run -- $@", + "test:acceptance": "npm run test:acceptance:dir test/acceptance/js", "test:unit": "npm run compile:app && npm run compile:unit_tests && bin/unit_test $@", "compile:unit_tests": "bin/compile_unit_tests", "compile:acceptance_tests": "bin/compile_acceptance_tests",