Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-02-16 14:02:18 -0500
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-02-19 15:21:14 -0500
commitf788edd675e3662192c2421ae142fb1f42d3da49 (patch)
tree3d4c10c25b31bf1ffcf8190c7951577281e83d76 /progtest
parent253f8458039f1331a6b62f3a8a6d3510ae49868b (diff)
downloadtame-f788edd675e3662192c2421ae142fb1f42d3da49.tar.gz
tame-f788edd675e3662192c2421ae142fb1f42d3da49.tar.bz2
tame-f788edd675e3662192c2421ae142fb1f42d3da49.zip
Initial embedding of YAML test case runner
Diffstat (limited to 'progtest')
-rw-r--r--progtest/Makefile9
-rw-r--r--progtest/bin/runner.js34
-rw-r--r--progtest/package.json1
-rw-r--r--progtest/src/env.js59
4 files changed, 73 insertions, 30 deletions
diff --git a/progtest/Makefile b/progtest/Makefile
index e4808ae..2b01a10 100644
--- a/progtest/Makefile
+++ b/progtest/Makefile
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-.PHONY: check test modindex FORCE
+.PHONY: check test modindex browserify FORCE
namespaces=$(shell find src/ -type d)
nsindex=$(addsuffix /index.js, $(namespaces))
@@ -31,3 +31,10 @@ modindex: $(nsindex)
%/index.js: FORCE
$(CURDIR)/build-aux/gen-index "$*" > "$@"
+browserify: tame-progtest.js
+tame-progtest.js: FORCE
+ $(CURDIR)/node_modules/.bin/browserify \
+ --debug \
+ -r $(CURDIR)/src/index.js:progtest \
+ $(CURDIR)/src/index.js \
+ -o "$@"
diff --git a/progtest/bin/runner.js b/progtest/bin/runner.js
index 65a499a..d0a95ad 100644
--- a/progtest/bin/runner.js
+++ b/progtest/bin/runner.js
@@ -24,36 +24,12 @@
const program = require( process.argv[ 2 ] );
const filename = process.argv[ 3 ];
-const fs = require( 'fs' );
-const yaml_reader = require( 'js-yaml' );
+const fs = require( 'fs' );
-const {
- TestCase,
- TestRunner,
+const case_yaml = fs.readFileSync( filename, 'utf8' );
- reader: {
- ConstResolver,
- DateResolver,
- YamlTestReader
- },
-
- reporter: {
- ConsoleTestReporter
- },
-} = require( '../src' );
-
-const runner = TestRunner(
- ConsoleTestReporter( process.stdout ),
- program
-);
-
-const reader = YamlTestReader
- .use( DateResolver )
- .use( ConstResolver( program ) )
- ( yaml_reader, TestCase );
-
-const cases = reader.loadCases(
- fs.readFileSync( filename, 'utf8' )
+const runner = require( '../src/env' ).console(
+ program, process.stdout
);
-const results = runner.runTests( cases );
+runner( case_yaml );
diff --git a/progtest/package.json b/progtest/package.json
index 7166796..97c70f1 100644
--- a/progtest/package.json
+++ b/progtest/package.json
@@ -9,6 +9,7 @@
"js-yaml": "3.10.0"
},
"devDependencies": {
+ "browserify": "16.10.0"
},
"license": "GPL-3.0+"
diff --git a/progtest/src/env.js b/progtest/src/env.js
new file mode 100644
index 0000000..7c09cf6
--- /dev/null
+++ b/progtest/src/env.js
@@ -0,0 +1,59 @@
+/**
+ * Environment-specific runner initialization
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+"use strict";
+
+const yaml_reader = require( 'js-yaml' );
+
+const {
+ TestCase,
+ TestRunner,
+
+ reader: {
+ ConstResolver,
+ DateResolver,
+ YamlTestReader
+ },
+
+ reporter: {
+ ConsoleTestReporter
+ },
+} = require( '../src' );
+
+
+module.exports = {
+ console: ( program, stdout ) =>
+ {
+ const runner = TestRunner(
+ ConsoleTestReporter( stdout ),
+ program
+ );
+
+ const reader = YamlTestReader
+ .use( DateResolver )
+ .use( ConstResolver( program ) )
+ ( yaml_reader, TestCase );
+
+ return yaml => runner.runTests(
+ reader.loadCases( yaml )
+ );
+ },
+};