Просмотр исходного кода

Allow modules to specific their own acceptance tests

James Allen 9 лет назад
Родитель
Сommit
5e0fc24c1a

+ 17 - 4
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 \

+ 1 - 15
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 "$@"

+ 1 - 1
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))
 

+ 2 - 1
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",