diff options
| author | Alon Levy <alon@pobox.com> | 2014-10-20 13:25:32 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-10-20 21:36:37 +0300 |
| commit | c919c4bfef4ad9e2dc25d040c0727dd29ad541ae (patch) | |
| tree | dd6394603680976c48801b53321e8085b0db1505 /tests/run_tests.js | |
| parent | f1f4e937932f52c630831d0d501f8f8756b37531 (diff) | |
introduce require.js and rewrite tests
Yes, I'm being lazy. The purpose of require.js is to allow writing
modules, i.e. individual smaller then the whole files with clear
dependencies. This is achieved by using a new api provided by
require.js:
define, require, requirejs
Read more at [requirejs] (http://requirejs.org)
Tests have been rewritten to work correctly with require.js; they still
use jsdom.
Test output is now stored in the repository, all tests are run via
run_tests.js; This is a hack - once a good harness (with assertions,
suites - unittest like) presents itself it will be used.
Hidden here is also using FileSaver for history saving, so history is
saved to history.json instead to a random name. Plus dropping some dead
code.
Diffstat (limited to 'tests/run_tests.js')
| -rw-r--r-- | tests/run_tests.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/run_tests.js b/tests/run_tests.js new file mode 100644 index 00000000..bfc129eb --- /dev/null +++ b/tests/run_tests.js @@ -0,0 +1,31 @@ +var fs = require('fs'); +var spawn = require('child_process').spawn; + +var tests = fs.readdirSync('.').filter(function (x) { return /^test_.*\.js$/.test(x); }); +var i; +var testname; + +function store_output(proc, args, stdout, stderr) +{ + var out = fs.openSync(stdout, 'w+'); + var err = fs.openSync(stderr, 'w+'); + var p = spawn(proc, args); + + p.stdout.on('data', function (data) { + console.log(args + ' gives ' + data.length); + fs.appendFileSync(stdout, data); + }); + p.stderr.on('data', function (data) { + console.log(args + ' gives ' + data.length + ' (err)'); + fs.appendFileSync(stderr, data); + }); + p.on('close', function (code, signal) { + console.log(proc + '(' + args.join(', ') + ') exited with ' + code); + }); + +} + +for (i in tests) { + testname = tests[i]; + store_output('/usr/bin/node', [__dirname + '/' + testname], 'output/' + testname + '.stdout', 'output/' + testname + '.stderr'); +} |
