go-internal: testscript: panic: fail now! in stop command on Windows
I’m creating this issue in the hope that someone could give me some helping hints before I give in and start up my Windows VM.
The short take is:
- I have rewritten Hugo’s CLI and added testscripts for all of the commands. That process has been a real pleasure.
- All of them is smooth sailing on *nix.
- The server tests (using the background process support), fails on Windows with a not so informational error (see below).
- One example of such failing test is: https://github.com/bep/hugo/blob/ee8985cc3fdfab60c4c24e028cb33a33a3ce6ee5/testscripts/commands/server_render_to_memory.txt#L4
--- FAIL: TestCommands (2.00s)
--- FAIL: TestCommands/server_render_to_memory (1.11s)
testscript.go:534: # Test the hugo server command.
# We run these tests in parallel so let Hugo decide which port to use.
(1.102s)
> hugo server &
> waitServer
> httpget $HUGOTEST_BASEURL_0 'Title: Hugo Server Test' $HUGOTEST_BASEURL_0
> ! exists public/index.html
> ! exists public/mystatic.txt
> stop
stop
[background] hugo.exe server: exit status 1
[stdout]
Start building sites …
hugo v0.112.0-DEV windows/386 BuildDate=unknown
| EN
-------------------+-----
Pages | 2
Paginator pages | 0
Non-page files | 0
Static files | 1
Processed images | 0
Aliases | 0
Sitemaps | 0
Cleaned | 0
Built in 91 ms
Watching for changes in $WORK\{layouts,static}
Watching for config changes in $WORK\hugo.toml
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
FAIL: testscripts\commands\server_render_to_memory.txt:13: unexpected command failure
panic: fail now! [recovered]
panic: fail now!
goroutine 45 [running]:
testing.tRunner.func1.2({0x1b175c0, 0x14847970})
C:/hostedtoolcache/windows/go/1.19.9/x64/src/testing/testing.go:1[39](https://github.com/gohugoio/hugo/actions/runs/4961873656/jobs/8879210277?pr=10602#step:17:40)6 +0x2ab
testing.tRunner.func1()
C:/hostedtoolcache/windows/go/1.19.9/x64/src/testing/testing.go:1399 +0x[41](https://github.com/gohugoio/hugo/actions/runs/4961873656/jobs/8879210277?pr=10602#step:17:42)f
panic({0x1b175c0, 0x14847970})
C:/hostedtoolcache/windows/go/1.19.9/x64/src/runtime/panic.go:884 +0x1ba
github.com/rogpeppe/go-internal/testscript.(*TestScript).Fatalf(0x149e6900, {0x1d91689, 0x1a}, {0x0, 0x0, 0x0})
C:/Users/runneradmin/go/pkg/mod/github.com/rogpeppe/go-internal@v1.10.1-0.20230505210500-5150104[43](https://github.com/gohugoio/hugo/actions/runs/4961873656/jobs/8879210277?pr=10602#step:17:44)74f/testscript/testscript.go:1104 +0x1[49](https://github.com/gohugoio/hugo/actions/runs/4961873656/jobs/8879210277?pr=10602#step:17:50)
github.com/rogpeppe/go-internal/testscript.(*TestScript).waitBackground(0x149e[69](https://github.com/gohugoio/hugo/actions/runs/4961873656/jobs/8879210277?pr=10602#step:17:70)00, 0x1)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (9 by maintainers)
Commits related to this issue
- testscript: handle the "fail now!" panic in cmdWait Closes #228 — committed to bep/go-internal by bep 4 years ago
- testscript: ignore result when interrupting background processes When an entire script runs and the end is reached, any background processes begun with a '&' command get interrupted or killed, depend... — committed to mvdan/go-internal by mvdan 2 years ago
- testscript: ignore result when interrupting background processes When an entire script runs and the end is reached, any background processes begun with a '&' command get interrupted or killed, depend... — committed to mvdan/go-internal by mvdan 2 years ago
- testscript: ignore result when interrupting background processes When an entire script runs and the end is reached, any background processes begun with a '&' command get interrupted or killed, depend... — committed to rogpeppe/go-internal by mvdan 2 years ago
@myitcv thanks for the detailed explanation. OK, I understand how to set it up. The thing is, though, when I compare the 2 scripts below:
And:
I would much, much prefer the first variant any day of the week. And one great thing about it is that the average developer coming in to fix 1 thing in a project he/she has no experience with, can read that script and understand exactly what it does (also, it does not require 1K lines of custom test setup behind the scenes).
This particular issue (#228) is obviously a bug. It may be hard (impossible?) to fix for the
testscript.RunMaincommands, but perhaps theCmdscommands could have support for the&“operator” and astopwould run theDefer? Or something.My current workaround is a custom
stopServercommand that just sends aHEADrequest to a “stop server” endpoint.@myitcv Maybe. The thing is:
hugo server --renderToMemory &is incredibly powerful and self documenting.