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(gnolang): don't print debug logs for package unicode #1226

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions gnovm/pkg/gnolang/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@
return bool(debug) && enabled
}

func DisableDebug() {
func DisableDebug() (rollback func()) {
prev := enabled

Check warning on line 104 in gnovm/pkg/gnolang/debug.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/debug.go#L103-L104

Added lines #L103 - L104 were not covered by tests
enabled = false
return func() { enabled = prev }

Check warning on line 106 in gnovm/pkg/gnolang/debug.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/debug.go#L106

Added line #L106 was not covered by tests
}

func EnableDebug() {
func EnableDebug() (rollback func()) {
prev := enabled

Check warning on line 110 in gnovm/pkg/gnolang/debug.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/debug.go#L109-L110

Added lines #L109 - L110 were not covered by tests
enabled = true
return func() { enabled = prev }

Check warning on line 112 in gnovm/pkg/gnolang/debug.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/debug.go#L112

Added line #L112 was not covered by tests
}
9 changes: 7 additions & 2 deletions gnovm/pkg/gnolang/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@
m.Store.SetCachePackage(pv)
}
m.SetActivePackage(pv)
// unicode is terribly slow at printing debug logs.
if debug && memPkg.Path == "unicode" {
// disable debug until end of function
defer DisableDebug()()
}

Check warning on line 232 in gnovm/pkg/gnolang/machine.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/machine.go#L228-L232

Added lines #L228 - L232 were not covered by tests
// run files.
m.RunFiles(files.Files...)
// maybe save package value and mempackage.
Expand All @@ -244,7 +249,7 @@
// afterwards from the same store.
func (m *Machine) TestMemPackage(t *testing.T, memPkg *std.MemPackage) {
defer m.injectLocOnPanic()
DisableDebug()
enableDebug := DisableDebug()

Check warning on line 252 in gnovm/pkg/gnolang/machine.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/machine.go#L252

Added line #L252 was not covered by tests
fmt.Println("DEBUG DISABLED (FOR TEST DEPENDENCIES INIT)")
// parse test files.
tfiles, itfiles := ParseMemPackageTests(memPkg)
Expand All @@ -270,7 +275,7 @@
m.SetActivePackage(pv)
m.RunFiles(itfiles.Files...)
pn.PrepareNewValues(pv)
EnableDebug()
enableDebug()

Check warning on line 278 in gnovm/pkg/gnolang/machine.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/machine.go#L278

Added line #L278 was not covered by tests
fmt.Println("DEBUG ENABLED")
for i := 0; i < len(pvBlock.Values); i++ {
tv := pvBlock.Values[i]
Expand Down
4 changes: 2 additions & 2 deletions gnovm/tests/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error {
} else {
// realm case.
store.SetStrictGo2GnoMapping(true) // in gno.land, natives must be registered.
gno.DisableDebug() // until main call.
enableDebug := gno.DisableDebug()
// save package using realm crawl procedure.
memPkg := &std.MemPackage{
Name: string(pkgName),
Expand Down Expand Up @@ -217,7 +217,7 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error {
}
pv2 := store.GetPackage(pkgPath, false)
m.SetActivePackage(pv2)
gno.EnableDebug()
enableDebug()
if rops != "" {
// clear store.opslog from init function(s),
// and PreprocessAllFilesAndSaveBlockNodes().
Expand Down
Loading