Open svaarala opened 7 years ago
With regards to tooling, runtests.js is a pretty awkward tool overall. Current plan is to split its functionality into two:
The main primitive would be a Python2 utility to prepare and optionally run a testcase:
Test
binding or similar) is automatically located relative to the utility location. The test framework would be pre-minified to a single-line file so that it can be prepended to the testcase without affecting line numbering (which matters to some tests). Pre-minification avoids a minified dependency which is simple but annoying.duk
, nodejs
, etc.duk
, nodejs
, or other engine. Differences to expected output are reported (hopefully with a better syntax than now).Runtests.js can then be kept and will be a bit smaller. It might still run API tests which involve compilation and linking. Or the unit test tool could also support API tests and be capable of compiling and linking individual tests.
util/runtest.py
which prepares and runs a testcase, with://>hello world
use_strict: true
metadata flagintended_uncaught: true
metadata flagprint()
and console.log()
are available for all enginesTest
binding which can be later extended with more test framework codeWhat is the purpose of the use_strict
flag? Wouldn't putting a real strict mode directive at the top of the file work just as well?
The testcase prologue is prepended into the prepared test so a real strict mode directive isn't effective.
Ideally the test preparation code would parse the real strict mode directive and place the prologue after it but that's more work than just a metadata flag.
Ah, didn't think of that, that makes sense :)
The testcase format with included files and expect string etc is quite old and could use a few improvements. The two main directions are:
Both have merits, see discussion in https://github.com/svaarala/duktape/pull/1073.
For print-and-expect:
Test
object with a bunch of helpers always exists. Also provide aTest
module for e.g. Node.js where possible, so that comparison is easy.print(-0); //> -0
so that expect strings and tests can mostly be close to each other.//! custom: true
.Test.run(function () { ... })
with automatic stack trace printing etc.console.log()
rather thanprint()
so that cross checking with other engines (V8 especially) is easier. Or maybeTest.print()
?Test
binding; this allows low level lexer tests and such to continue to work with minimal engine assumptions.strict: true
to indicate a test should run as a strict program. One can also use"use strict";
but that has some issues with prepending a test framework.Test
module can be pre-minimized to a single line function so that it can be prepended more easily without needing a minifier.