-
Notifications
You must be signed in to change notification settings - Fork 375
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
feat(gnovm): test execution refactor + speedup #3119
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3119 +/- ##
==========================================
- Coverage 63.80% 63.59% -0.21%
==========================================
Files 549 553 +4
Lines 78833 78928 +95
==========================================
- Hits 50301 50196 -105
- Misses 25143 25361 +218
+ Partials 3389 3371 -18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Marking this as ready for review. Yes, there are a lot of changed files, but I'm thinking we can still do this in one go rather than doing multiple PRs because there are actually very few "tricky" changes (ie., those involving non-test code in As usual for my large PRs, I tried updating OP to give it as much information and guidance on how to review the PR. 🥂 |
This PR tackles a large amount of improvements in our current internal testing systems for the gnovm, as well as those for
gno test
. The primary target is the execution of filetests; however many improvements have been implemented to remove dead or duplicate code, and bring over some of the improvements that have been implemented in tests to filetests, when they come at little added "cost".The biggest headline concerns the execution of filetests. I wrote the specific improvements undertaken in a blog post on "diary of a gnome", but here's a side-by-side comparison of the execution in this PR (left) and the execution on master (right).
tests
variable #1084_long
filetests on master and generally speeding up test execution.Impact
test.Store
when running. Coupled withtest.LoadImports
, it allows us to "eagerly load" imports ahead of the test execution, and save it in the store. This is the primary performance improvement of this PR, as all pure packages can be run and preprocessed only once, whereas before it was once per package, and once per filetest. (More info in the blog post.)println
used in package initialization.// SEND:
, andstd.TestIssueCoin
. Some test balances had to be updated.gno test -v
now also prints their output.main.gno
, but in a filename following the name of the filetest; this changed some// Realm:
directives.//
in the tests.// Error:
directives are now treated the same as everything else; and are updated if the-update-golden-tests
flag is passed.imports
metric from the runtime metrics, as it's now no longer straightforward to calculate (given that imports are loaded "eagerly").os
,fmt
,encoding/json
,internal/os_test
andmath/big
. This removes the-with-native-fallback
flag fromgno test
._native.gno
have largely been removed, and those ending with_stdlibs.go
have had their suffix removed.gonative
types and functions which were only used in a small subset of these tests, have been removed.gno test
, for testing packages, created amain_test.gno
file that is then called directly from the machine on each test. This creates two identifiers,tests
andruntest
, which could come into conflict with those defined by the tests themselves. We now calltesting.RunTest
directly, without an intermediary.pkg
) are now visible in the tests ofpkg_test
. This is most useful for some standard library tests, where there often is anexport_test.go
with the sole scope of exporting some internal functions and methods for testing in the "real" testing file.gno lint
, and other occasions where we useissueFromError
(like when parsing errors ingno test
), will now also print the column of the error if given.Summary of internal changes
TestFiles
is the new function running the filetests.eval_test.go
has been removed, moving some of its improvements over toTestFiles
, and reducing the scope of the corresponding tests indebugger.go
, to what it's actually supposed to test for.imports.go
, I removedSetStrictGo2GnoMapping
in favour of always being "strict", and not allowing defining native types of defined types any more.gonative_test
where primarily related to this, so I removed them. Similarly forpreprocess_test
.TestFunc
/TestMemPackage
have been removed as redundant, including some of their features incmd/go/test.go
(like supporting exporting symbols in_test.gno
files)Store
no longer hasClearCache
andSetStrictGo2GnoMapping
;ClearCache
now has a better substitute inBeginTransaction
.testing
stdlib no longer cachesmatchPat
andmatchString
as pure packages should not be able to modify their values during execution, and as a result of other changes this was failing.gnovm/pkg/test
. This directory should eventually contain the internal code forgno test
as well; but for now I wanted to cleantests
to ensure it is a directory just for integration tests, rather than code and testing systems.TestMachine
andTestStore
have been renamed to Machine and Store, to avoid redundancy with thetest
package name.gnovm/Makefile
as now most tests are just inpkg/gnolang
.MsgContext.Msg
as unused. It can be re-added later if necessary.-short
, at least until we figure out how to make the VM efficient enough to run these tests. Aside from some filetests, this now excludes some stdlibs:bytes
,strconv
,regexp/syntax
. I accept other proposals that could make us have fast tests on PR's, while still testing (mostly) everything.