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

fix: unify the precompile output to make it easier to parse and read. #1670

Merged
merged 14 commits into from
Feb 22, 2024

Conversation

tbruyelle
Copy link
Contributor

Fix #1636

Under the hood, use scanner.ErrorList from the stdlib all the way to store all errors with the filename and the position in the file. Note that kind of error is already returned by parser.ParserFile.

For the go build output, instead of printing it like it is, parse it and shift it to represent the related gno file.

Run the tests:

$ go test ./gnovm/cmd/gno -v -run Test_ScriptsPrecompile
Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Feb 20, 2024
Copy link

codecov bot commented Feb 20, 2024

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (b474043) 53.34% compared to head (333a28b) 56.10%.
Report is 1 commits behind head on master.

Files Patch % Lines
gnovm/pkg/gnolang/precompile.go 72.72% 10 Missing and 2 partials ⚠️
gnovm/cmd/gno/precompile.go 63.63% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1670      +/-   ##
==========================================
+ Coverage   53.34%   56.10%   +2.76%     
==========================================
  Files         480      447      -33     
  Lines       72597    66739    -5858     
==========================================
- Hits        38725    37446    -1279     
+ Misses      30865    26374    -4491     
+ Partials     3007     2919      -88     
Flag Coverage Δ
go-1.22.x ∅ <ø> (∅)
misc ∅ <ø> (∅)
misc-_test.genstd ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏

gnovm/pkg/gnolang/precompile.go Show resolved Hide resolved
@thehowl thehowl requested a review from gfanton February 20, 2024 22:49
@thehowl
Copy link
Member

thehowl commented Feb 20, 2024

Tagging @gfanton for second review/merge as he's worked on gno lint too

@thehowl thehowl merged commit 9ce5984 into gnolang:master Feb 22, 2024
71 of 75 checks passed
@tbruyelle tbruyelle deleted the tbruyelle/feat/std-precompile-output branch February 22, 2024 12:19
tbruyelle added a commit to tbruyelle/gno that referenced this pull request Feb 23, 2024
PR gnolang#1670 updated the `gno precompile` output, by translating the errors
reported from generated go files into their related gno files. This was
done by shifting the line number, because generated go files have an
extra header of 4 lines.

@thehowl found a better way to do this, by using the `//line` directive.
By adding this directive at the end of this extra header we have in
generated go files, the go compiler will skip it and will output file
position that corresponds exactly to the gno file position. This allows
the removal of the line shifting mentionned above.

See https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives
tbruyelle added a commit to tbruyelle/gno that referenced this pull request Feb 23, 2024
PR gnolang#1670 updated the `gno precompile` output by translating errors reported
by generated go files into their corresponding gno files. This was done
by shifting the line number, since generated go files have an extra header
of 4 lines.

@thehowl found a better way to do this by using the //line directive. By
adding this directive at the end of this extra header we have in generated
go files, the go compiler will skip it and output a file position that
exactly matches the gno file position. This eliminates the need for the
line shifting mentioned above.

See https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives
thehowl pushed a commit that referenced this pull request Feb 28, 2024
PR #1670 updated the `gno precompile` output by translating errors
reported by generated go files into their corresponding gno files. This
was done by shifting the line number, since generated go files have an
extra header of 4 lines.

@thehowl found a better way to do this by using the //line directive. By
adding this directive at the end of this extra header we have in
generated go files, the go compiler will skip it and output a file
position that exactly matches the gno file position. This eliminates the
need for the line shifting mentioned above.

See https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
leohhhn pushed a commit to leohhhn/gno that referenced this pull request Feb 29, 2024
…gnolang#1670)

<!-- please provide a detailed description of the changes made in this
pull request. -->
Fix gnolang#1636 

Under the hood, use `scanner.ErrorList` from the stdlib all the way to
store all errors with the filename and the position in the file. Note
that kind of error is already returned by `parser.ParserFile`.

For the `go build` output, instead of printing it like it is, parse it
and shift it to represent the related gno file.

Run the tests:
```
$ go test ./gnovm/cmd/gno -v -run Test_ScriptsPrecompile
```

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
leohhhn pushed a commit to leohhhn/gno that referenced this pull request Feb 29, 2024
…ng#1688)

PR gnolang#1670 updated the `gno precompile` output by translating errors
reported by generated go files into their corresponding gno files. This
was done by shifting the line number, since generated go files have an
extra header of 4 lines.

@thehowl found a better way to do this by using the //line directive. By
adding this directive at the end of this extra header we have in
generated go files, the go compiler will skip it and output a file
position that exactly matches the gno file position. This eliminates the
need for the line shifting mentioned above.

See https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Done
Status: No status
Archived in project
Development

Successfully merging this pull request may close these issues.

Make the output of gno precompile more parseable
3 participants