You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
filetest can provide the expected output by using a comment prefixed with // Output:. It's useful to assert for instance Render functions :
package main
import (
"gno.land/r/gnoland/faucet"
)
funcmain() {
println(faucet.Render(""))
}
// Output:// # Community Faucet.//// Status: active.// Balance: 200000000ugnot.// Total transfers: (in 0 times).//// Package address: g17rgsdnfxzza0sdfsdma37sdwxagsz378833ca4//// Admin: g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5//// Controllers://////// Per request limit: 350000000ugnot
When gnodev test executes this kind of test, it reads this comment and compare it with the test outputs. If it doesn't match, the test fails. The problem comes from how those comments are read, because it currently uses ast.CommentGroup.Text() method, which reduces multiple lines into one (see method comment).
So typically for the example above, it's not possible to
run gnodev test -update-golden-tests
run gnodev test
without having a failure at the second run, because the 3 empty lines between Controllers and Per request limit are reduced to one before comparison.
Steps to reproduce
The example above doesn't exist yet in the codebase, it's part of a fix I wanted to provide for #621. Anyway it should be easy to reproduce by testing a Render that returns multiple empty lines.
The text was updated successfully, but these errors were encountered:
Fixgnolang#621
`Render` prints the controllers in a loop but relies on
`gControllersSize` rather than `gControllers.Size()` to determine the
number of controllers. The fix simply replaces `gControllersSize` by
`gControllers.Size()`.
Fixgnolang#627
filetest `Output:` directive doesn't work when the output contains
multiple consecutive empty lines, because the method used to collect
those comments truncate them (see issue and `ast.CommentGroup.Text()`).
The fix replaces this method by a custom one that doesn't truncate.
Fixgnolang#621
`Render` prints the controllers in a loop but relies on
`gControllersSize` rather than `gControllers.Size()` to determine the
number of controllers. The fix simply replaces `gControllersSize` by
`gControllers.Size()`.
Fixgnolang#627
filetest `Output:` directive doesn't work when the output contains
multiple consecutive empty lines, because the method used to collect
those comments truncate them (see issue and `ast.CommentGroup.Text()`).
The fix replaces this method by a custom one that doesn't truncate.
Description
filetest can provide the expected output by using a comment prefixed with
// Output:
. It's useful to assert for instanceRender
functions :When
gnodev test
executes this kind of test, it reads this comment and compare it with the test outputs. If it doesn't match, the test fails. The problem comes from how those comments are read, because it currently usesast.CommentGroup.Text()
method, which reduces multiple lines into one (see method comment).So typically for the example above, it's not possible to
gnodev test -update-golden-tests
gnodev test
without having a failure at the second run, because the 3 empty lines between
Controllers
andPer request limit
are reduced to one before comparison.Steps to reproduce
The example above doesn't exist yet in the codebase, it's part of a fix I wanted to provide for #621. Anyway it should be easy to reproduce by testing a
Render
that returns multiple empty lines.The text was updated successfully, but these errors were encountered: