svaarala / duktape

Duktape - embeddable Javascript engine with a focus on portability and compact footprint
MIT License
5.92k stars 514 forks source link

Improvements to testcase format and tooling #1075

Open svaarala opened 7 years ago

svaarala commented 7 years ago

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:

svaarala commented 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:

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.

svaarala commented 7 years ago

1094 adds util/runtest.py which prepares and runs a testcase, with:

fatcerberus commented 7 years ago

What 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?

svaarala commented 7 years ago

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.

fatcerberus commented 7 years ago

Ah, didn't think of that, that makes sense :)