Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Compiler Testing Support #47

Open
wants to merge 81 commits into
base: main
Choose a base branch
from

Conversation

alexisthedev
Copy link

@alexisthedev alexisthedev commented Dec 7, 2022

TypeScript + Hephaestus

This pull request consists of the required modules and additions to test the TypeScript compiler with Hephaestus.

Important additions include:

AST-to-TypeScript Translator
Core API extension to allow generation of programs with native types of any language (eg. TypeScript's unique union types)
Null and Undefined Types
Null Constant
Literal Types (Native TypeScript)
Type Aliases (Native TypeScript)
Union Types (Native TypeScript)
A more detailed overview is available here.

How to use Hephaestus to test the compiler of TypeScript

Here is a typical command used to test Typescript with Hephaestus.

python3 hephaestus.py -t 0 -w 8 -i 150 --batch 30 -P --language typescript --disable-use-site-variance

Key differences from testing other languages:

  • The transformations flag must be set to 0 (-t 0 ) because transformations are not currently supported for TypeScript.
  • Must include -P flag, so Hephaestus only runs correctness-preserving transformations (which are zero).
  • Must include -disable-use-site-variance because TypeScript doesn't support use-site variance.

Afterward, it is the typical Hephaestus process! (Check in the bugs folder to see the reported faults).

Expected result after running the above command:

Ubuntu 22.04 LTS
image

Had there been an error, a Main.ts file would have been stored at bugs/{name}/generator/iter_{i} (in the previous case the name is w0zy2).

image

Ignoring certain error messages

When testing TypeScript, it can be helpful to instruct Hephaestus to ignore certain error messages when they come up. For example, in the above image, the comparison ((77.79) !== (70.238)) has resulted in an error:

ts(2367): This condition will always return 'true' since the types '77.79' and '70.238' have no overlap.

This is working as intended (these two number literals are considered literal types in TypeScript), however knowing that this error might come up in a lot of our programs with TypeScript, we might want to tell Hephaestus to ignore this error message and not report the test program as failed.

For this, we use the flag --error-filter-patterns FILE, where each line in FILE contains a regex pattern that matches the error message we'd like to ignore.

For example in my own patterns file, I have the regex .*This condition will always return.* to ignore the above error.

alexisthedev and others added 30 commits July 29, 2022 11:13
@alexisthedev
Copy link
Author

alexisthedev commented Dec 7, 2022

This has been reopened (as explained here).

Todo list from comments on previous PR #46

  • Remove GSOC.md
  • Wrap reinstalling the nightly TS build in an install_nightly function
  • Add example instructions and expected results in PR description

@alexisthedev alexisthedev force-pushed the merge-with-central-repo branch from 86bab20 to 101d787 Compare December 7, 2022 13:49
@alexisthedev
Copy link
Author

@StefanosChaliasos The conflicts mentioned do not appear on my end (probably because they are rebase conflicts and not merge conflicts).

image

@theosotr theosotr requested review from theosotr and StefanosChaliasos and removed request for theosotr December 7, 2022 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants