/test262_harness_cpp

C++ test harness for the Official ECMAScript Conformance Test Suite for embeddable JS engines

Primary LanguageC++

test262_harness_cpp

Source code and projects for a test harness that is able to run tests from the Official ECMAScript Conformance Test Suite over several C / C++ Javascript / ECMAScript runtimes available on the net.

Simply include the source code of the Javascript / ECMAScript engine of your choice into the project, plus the runtime that is associated with the engine, and you're ready to go.

Support for the following Javascript / ECMAScript engines is included:

  • Duktape
  • TinyJS
  • TinyJS's 42tiny_js branch

Other C / C++ engines can be easily added, as long as they can be added to the project either as source code or libraries - examine the various runtime_***.h/.cpp sources to give you an idea of how the engine is expected to be called for the various tests.

The source code of the test harness is written in C++, without external dependencies on third-party libraries - except for the runtimes themselves. test262_harness_cpp runs as a command-line application, which expects the following arguments:

  • -t /path/to/tests/directory : The directory that contains the test262 tests. Point it to the top-level directory that contains the /test and /harness directories.
  • -o /path/to/output/results.txt : The path to the results file containing the fail/pass status of the various tests in the suite.
  • -p : (Optional) Display progress messages detailing how many tests were run, and how many failed, updated once per ran test. Useful when debugging the harness or the engines being tested.

The following is an example of the output results file generated by test262_harness_cpp when run against Duktape:

[->PASS:NON_STRICT<-] /Users/heribertodelgado/Projects/test262-master/test/annexB/built-ins/escape/escape-above-astral.js
[->PASS:STRICT<-] /Users/heribertodelgado/Projects/test262-master/test/annexB/built-ins/escape/escape-above-astral.js
[->FAIL:NON_STRICT<-] /Users/heribertodelgado/Projects/test262-master/test/annexB/built-ins/escape/to-string-err-symbol.js
ReferenceError -  identifier 'Symbol' undefined
[->FAIL:STRICT<-] /Users/heribertodelgado/Projects/test262-master/test/annexB/built-ins/escape/to-string-err-symbol.js
ReferenceError -  identifier 'Symbol' undefined
[->PASS:NON_STRICT<-] /Users/heribertodelgado/Projects/test262-master/test/annexB/built-ins/escape/prop-desc.js
[->PASS:STRICT<-] /Users/heribertodelgado/Projects/test262-master/test/annexB/built-ins/escape/prop-desc.js

Compilation Instructions

Included with test262_harness_cpp are the following projects:

  • An Xcode 8.2 console project for MacOS;
  • A Visual Studio 2017 solution with two projects:
    • A Windows project for a command-line application;
    • A Linux project also for a command-line application.

The application can also be compiled for other platforms, provided that you specify a proper implementation of directories.h / .cpp for your platform.

To create the command-line application using the supplied components:

MacOS:

  • Rename runtime_duktape.h / .cpp, or runtime_tinyjs.h / .cpp or runtime_42tinyjs.h / .cpp (depending on the Javascript / ECMAScript engine you chose to run the tests) to runtime.h / .cpp .
  • Open the test262_harness_cpp project by using Xcode 8.2 or later.
  • Include all the renamed .h / .cpp files into the newly opened project.
  • Include the source code files of the engine you chose into the project.
  • Build the project (either by using Product / Build or clicking on the Run button in Xcode.)

Windows:

  • Rename runtime_duktape.h / .cpp, or runtime_tinyjs.h / .cpp or runtime_42tinyjs.h / .cpp (depending on the Javascript / ECMAScript engine you chose to run the tests) to runtime.h / .cpp .
  • Open the test262_harness_cpp solution by using Visual Studio 2017 or later.
  • Include all the renamed .h / .cpp files into the project named test262_harness_cpp_windows.
  • Include the source code files of the engine you chose into the project.
  • Build the project (either by using Project / Build or clicking on the Start Debugging button in the IDE.)

Linux (from Visual Studio):

  • Rename runtime_duktape.h / .cpp, or runtime_tinyjs.h / .cpp or runtime_42tinyjs.h / .cpp (depending on the Javascript / ECMAScript engine you chose to run the tests) to runtime.h / .cpp .
  • Open the test262_harness_cpp solution by using Visual Studio 2017 or later.
  • Include all the renamed .h / .cpp files into the project named test262_harness_cpp_linux.
  • Include the source code files of the engine you chose into the project.
  • Build the project (either by using Project / Build or clicking on the Start Debugging button in the IDE.)

Other platforms:

  • Create a copy of the file directories_posix.cpp and provide a suitable implementation for your platform if it's not POSIX-compliant already.
  • Rename runtime_duktape.h / .cpp, or runtime_tinyjs.h / .cpp or runtime_42tinyjs.h / .cpp (depending on the Javascript / ECMAScript engine you chose to run the tests) to runtime.h / .cpp .
  • Include the files harness.h / .cpp, metadata.h / .cpp, main.cpp, directories.h, and all copied / renamed files into your build system.
  • Include the source code or libraries of the Javascript / ECMAScript engine you chose into the build system.
  • Invoke the build command of your build system.

Licensing

The project is provided under the terms of the MIT License. Feel free to use this project and modify it to your leisure in order to run the tests of the Javascript / ECMAScript engine of your choice.