Skip to content

Add tests to the compiler package #1571

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

Merged
merged 2 commits into from
Jan 15, 2021
Merged

Add tests to the compiler package #1571

merged 2 commits into from
Jan 15, 2021

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented Jan 13, 2021

This is my next attempt to make the compiler more modular (also see #1008). This time I managed to add tests to the compiler without too many complications.

Testing is still quite limited as it isn't yet possible to test anything that refers to runtime types or functions, which are the most interesting tests. I did this in #1008 but left it out in this PR to keep things simple and focused. I intend to introduce runtime types in a later PR and with that change, add more compiler tests.

The first commit of this PR is a small change that renames the main package in the IR. This could have real world impact but I think it is an improvement as output binaries now better match the symbol name conventions of the Go toolchain.

Updates #285.

This should make exported names a bit more consistent.

I believe there was a bug report for this issue, but I can't easily find
it. In any case, I think it's an important improvement to match the
behavior of the Go toolchain.
This commit finally introduces unit tests for the compiler, to check
whether input Go code is converted to the expected output IR.

To make this necessary, a few refactors were needed. Hopefully these
refactors (to compile a program package by package instead of all at
once) will eventually become standard, so that packages can all be
compiled separate from each other and be cached between compiles.
@deadprogram
Copy link
Member

Thanks @aykevl for the changes and to @niaow for reviewing. Now merging.

@deadprogram deadprogram merged commit a848d72 into dev Jan 15, 2021
@deadprogram deadprogram deleted the compiler-tests-2 branch January 15, 2021 13:43
aykevl added a commit that referenced this pull request Jan 24, 2021
Since #1571 (in particular, the first
commit that sets the main package path), the main package is always named
"main". This makes the callMain() workaround in the runtime unnecessary and
allows directly calling the main.main function with a //go:linkname pragma.
deadprogram pushed a commit that referenced this pull request Jan 24, 2021
Since #1571 (in particular, the first
commit that sets the main package path), the main package is always named
"main". This makes the callMain() workaround in the runtime unnecessary and
allows directly calling the main.main function with a //go:linkname pragma.
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.

3 participants