From c879c784a7367ee6ad0b6a0c0e6d72e56fa874b9 Mon Sep 17 00:00:00 2001 From: ssube Date: Tue, 2 Jul 2019 08:42:48 -0500 Subject: [PATCH] lint: better test targets, misc shell quotes --- Makefile | 35 ++++++++++++++++++----------------- README.md | 2 +- scripts/test-examples.sh | 6 +++--- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index bcac57f..bdd0b5a 100755 --- a/Makefile +++ b/Makefile @@ -87,15 +87,28 @@ build-bundle: node_modules build-image: build-bundle docker build $(ROOT_PATH) -test: test-mocha test-examples - -test-mocha: ## run small (unit) tests -test-mocha: build-bundle - $(NODE_BIN)/mocha $(TARGET_PATH)/test.js +test: test-bundle test-rules test-examples test-examples: ## run medium (feature) tests $(SCRIPT_PATH)/test-examples.sh +test-bundle: ## run small (unit) tests +test-bundle: build-bundle + $(NODE_BIN)/mocha $(TARGET_PATH)/test.js + +test-rules: ## validate the rules directory +test-rules: build-bundle + find $(ROOT_PATH)/rules -maxdepth 1 -name '*.yml' | while read file; \ + do \ + echo "Validating $${file}..."; \ + node out/index.js \ + --config-path $(ROOT_PATH)/docs \ + --config-name config-stderr.yml \ + --rules $(ROOT_PATH)/rules/salty-dog.yml \ + --source $${file} \ + --tag salty-dog > /dev/null || exit 1; \ + done + yarn-install: ## install dependencies from package and lock file yarn @@ -137,18 +150,6 @@ upload-codecov: run-help: ## print the help @node out/index.js --help -run-rules: ## validate the rules directory - find $(ROOT_PATH)/rules -maxdepth 1 -name '*.yml' | while read file; \ - do \ - echo "Validating $${file}..."; \ - node out/index.js \ - --config-path $(ROOT_PATH)/docs \ - --config-name config-stderr.yml \ - --rules $(ROOT_PATH)/rules/salty-dog.yml \ - --source $${file} \ - --tag salty-dog > /dev/null || exit 1; \ - done - run-stream: ## validate stdin and write it to stdout, errors to stderr @node out/index.js \ --config-path $(ROOT_PATH)/docs \ diff --git a/README.md b/README.md index 500f94d..b57a497 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ To enable a group of rules by tag, `--include-tag foo`. To validate the rules in the `rules/` directory using the meta-rules: ```shell -> make run-rules +> make test-rules ... {"name":"salty-dog","hostname":"cerberus","pid":29403,"level":30,"msg":"all rules passed","time":"2019-06-16T00:56:55.132Z","v":0} diff --git a/scripts/test-examples.sh b/scripts/test-examples.sh index 0a074df..32b6a5a 100755 --- a/scripts/test-examples.sh +++ b/scripts/test-examples.sh @@ -27,12 +27,12 @@ do --config-path ./docs \ --config-name config-stderr.yml \ --rules "rules/${USE_RULES}.yml" \ - --tag ${USE_TAGS} \ - --source ${example} + --tag "${USE_TAGS}" \ + --source "${example}" ACTUAL_STATUS=$? - if [[ ${ACTUAL_STATUS} != ${EXPECTED_STATUS} ]]; + if [[ "${ACTUAL_STATUS}" != "${EXPECTED_STATUS}" ]]; then echo "Exit status does not match! (expected ${EXPECTED_STATUS}, got ${ACTUAL_STATUS})" exit 1