diff --git a/progtest/Makefile.am b/progtest/Makefile.am index 4276795f..9af1d9c0 100644 --- a/progtest/Makefile.am +++ b/progtest/Makefile.am @@ -33,9 +33,10 @@ modindex: $(nsindex) $(CURDIR)/build-aux/gen-index "$*" > "$@" test: check -check: +check: modindex PATH="$(PATH):$(CURDIR)/node_modules/mocha/bin" \ mocha @NODE_DESTRUCTURE@ --recursive test/ + test/runner-test browserify: tame-progtest.js tame-progtest.js: check modindex diff --git a/progtest/bin/runner.js b/progtest/bin/runner.js index c6c5debf..4dddf200 100644 --- a/progtest/bin/runner.js +++ b/progtest/bin/runner.js @@ -33,4 +33,17 @@ const runner = require( '../src/env' ).console( ); runner( case_yaml ) - .catch( e => console.error( e ) ); + .then( results => + { + const failed = results.some( + ( { failures } ) => failures.length + ); + + process.exit( +failed ); + } ) + .catch( e => + { + console.error( e ); + process.exit( 1 ); + } ); + diff --git a/progtest/test/_stub/bad.yml b/progtest/test/_stub/bad.yml new file mode 100644 index 00000000..793f0c98 --- /dev/null +++ b/progtest/test/_stub/bad.yml @@ -0,0 +1,7 @@ +# Simple test case that should fail + +- description: Failure + data: + in: 0 + expect: + out: 1 diff --git a/progtest/test/_stub/good.yml b/progtest/test/_stub/good.yml new file mode 100644 index 00000000..a4c682e2 --- /dev/null +++ b/progtest/test/_stub/good.yml @@ -0,0 +1,7 @@ +# Simple test case that should succeed + +- description: Success + data: + in: 1 + expect: + out: 1 diff --git a/progtest/test/_stub/program.js b/progtest/test/_stub/program.js new file mode 100644 index 00000000..cb9e67d3 --- /dev/null +++ b/progtest/test/_stub/program.js @@ -0,0 +1,25 @@ +/** + * Stub program ("rater") + * + * Copyright (C) 2018 R-T Specialty, LLC. + * + * This file is part of TAME. + * + * TAME is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +exports.rater = data => +{ + return { vars: { out: data.in } }; +}; diff --git a/progtest/test/runner-test b/progtest/test/runner-test new file mode 100755 index 00000000..5091bd39 --- /dev/null +++ b/progtest/test/runner-test @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# Runner script system test +# +# Copyright (C) 2018 R-T Specialty, LLC. +# +# This file is part of TAME. +# +# TAME is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -euo pipefail + +cd "$( dirname "$0" )" + +declare -r bin=../bin + + +main() +{ + set -x + + # should succeed + "$bin"/runner _stub/program.js _stub/good.yml >/dev/null + + # should fail + "$bin"/runner _stub/program.js _stub/bad.yml >/dev/null && exit 1 || true +} + +main "$@"