This project is read-only.

TSC Compiler Development: How to run a particular test case?

Topics: General
Feb 18, 2014 at 10:18 PM
"jake runtests" will run the entire test suite. There is a touch of documentation hinting at a tests=<testpath> feature for this command but I don't know how this works. Can you shed some light on this functionality?
Feb 19, 2014 at 12:28 AM
You can use tests= to run either individual tests or specific suites/sets of suites. You can see the full list of suite options and which suites are involved in src\harness\runner.ts, ex to run only compiler tests:

jake runtests tests=--compiler

or just language service tests in our fourslash suite:

jake runtests tests=--fourslash

To run individual tests you just pass the relative path to the test and the right test runner will be used, ex

jake runtests tests=tests\cases\compiler\2dArrays.ts
Feb 19, 2014 at 7:40 PM
Thanks! That helps a lot. And now a general testing question: Is there anyway to run a test that compares the compiled output?

I have a basic modification to the compiler to look anywhere in the file for amd-dependency comments and I'm trying to create a simple test case for this functionality.
Feb 20, 2014 at 8:33 PM
The compiler baseline tests are the type of tests you're looking for. They're in tests\cases\compiler (the conformance suite in tests\cases\conformance are also of this style). If you simply add a .ts file under tests\cases\compiler the test will be picked up (and included if you run tests=--compiler or --compiler-baselines). This will cause a set of baseline files to be placed in tests\baselines\local and a baseline-report.html file to be placed at the root of your typescript repo which will show you a diff of the codegen, errors (if any) and types (if the test had no errors) for the changed tests/results. If you are happy with the baseline results you run 'jake baseline-accept' which will blindly replace the entire contents of tests\baseline\reference with everything in tests\baseline\local (meaning don't run 'jake baseline-accept' if you've just run a subset of the full test suite, do a full 'jake runtests' so that the baseline folders have baselines for all tests). Then you would check in your new .ts files and the new baseline files in tests\baseline\reference.