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

make clean test: sometimes fails on version.go #874

Closed
Deleplace opened this issue Feb 23, 2021 · 3 comments
Closed

make clean test: sometimes fails on version.go #874

Deleplace opened this issue Feb 23, 2021 · 3 comments

Comments

@Deleplace
Copy link
Contributor

Hello, this is what I've observed several times on my Linux amd64 workstation with go1.16.

Then when I run make clean test again, it works.

$ make clean test
rm -f esbuild
rm -f npm/esbuild-windows-32/esbuild.exe
rm -f npm/esbuild-windows-64/esbuild.exe
rm -rf npm/esbuild-darwin-64/bin
rm -rf npm/esbuild-darwin-arm64/bin
rm -rf npm/esbuild-freebsd-64/bin
rm -rf npm/esbuild-freebsd-amd64/bin
rm -rf npm/esbuild-linux-32/bin
rm -rf npm/esbuild-linux-64/bin
rm -rf npm/esbuild-linux-arm/bin
rm -rf npm/esbuild-linux-arm64/bin
rm -rf npm/esbuild-linux-mips64le/bin
rm -rf npm/esbuild-linux-ppc64le/bin
rm -f npm/esbuild-wasm/esbuild.wasm npm/esbuild-wasm/wasm_exec.js
rm -rf npm/esbuild/lib
rm -rf npm/esbuild-wasm/lib
rm -rf require/*/bench/
rm -rf require/*/demo/
rm -rf require/*/node_modules/
go clean -testcache ./internal/...
make -j6 test-common
make[1]: Entering directory 'esbuild'
go test -race ./internal/...
go vet ./cmd/... ./internal/... ./pkg/...
node -e 'console.log(`package main\n\nconst esbuildVersion = "0.8.51"`)' > cmd/esbuild/version.go
cmd/esbuild/version.go:1:1: expected 'package', found 'EOF'
make[1]: *** [Makefile:26: vet-go] Error 1
make[1]: *** Waiting for unfinished jobs....
?   	github.com/evanw/esbuild/internal/ast	[no test files]
ok  	github.com/evanw/esbuild/internal/bundler	1.294s
?   	github.com/evanw/esbuild/internal/cache	[no test files]
?   	github.com/evanw/esbuild/internal/cli_helpers	[no test files]
?   	github.com/evanw/esbuild/internal/compat	[no test files]
?   	github.com/evanw/esbuild/internal/config	[no test files]
?   	github.com/evanw/esbuild/internal/css_ast	[no test files]
ok  	github.com/evanw/esbuild/internal/css_lexer	0.047s
ok  	github.com/evanw/esbuild/internal/css_parser	0.186s
ok  	github.com/evanw/esbuild/internal/css_printer	0.100s
ok  	github.com/evanw/esbuild/internal/fs	0.046s
ok  	github.com/evanw/esbuild/internal/js_ast	0.050s
ok  	github.com/evanw/esbuild/internal/js_lexer	0.104s
ok  	github.com/evanw/esbuild/internal/js_parser	1.451s
ok  	github.com/evanw/esbuild/internal/js_printer	0.232s
?   	github.com/evanw/esbuild/internal/logger	[no test files]
ok  	github.com/evanw/esbuild/internal/renamer	0.042s
?   	github.com/evanw/esbuild/internal/resolver	[no test files]
?   	github.com/evanw/esbuild/internal/runtime	[no test files]
?   	github.com/evanw/esbuild/internal/sourcemap	[no test files]
?   	github.com/evanw/esbuild/internal/test	[no test files]
make[1]: Leaving directory 'esbuild'
make: *** [Makefile:7: test] Error 2
@kzc
Copy link
Contributor

kzc commented Feb 24, 2021

It's a Makefile parallel job race due to insufficient dependencies.

The problem is more deterministic when you put a sleep in there:

--- a/Makefile
+++ b/Makefile
@@ -66,4 +66,5 @@ lib-typecheck: | lib/node_modules
 
 cmd/esbuild/version.go: version.txt
+       sleep 5 # for debugging only
        node -e 'console.log(`package main\n\nconst esbuildVersion = "$(ESBUILD_VERSION)"`)' > cmd/esbuild/version.go
 
@@ -236,4 +237,5 @@ publish-neutral: platform-neutral
 clean:
        rm -f esbuild
+       rm -f cmd/esbuild/version.go
        rm -f npm/esbuild-windows-32/esbuild.exe
        rm -f npm/esbuild-windows-64/esbuild.exe

fix:

--- a/Makefile
+++ b/Makefile
@@ -20,11 +20,12 @@ check-go-version:
        @go version | grep ' go1\.16 ' || (echo 'Please install Go version 1.16.0' && false)
 
-test-go:
-       go test -race ./internal/...
+RACE ?= "-race"
+test-go: cmd/esbuild/version.go
+       go test $(RACE) ./internal/...
 
-vet-go:
+vet-go: cmd/esbuild/version.go
        go vet ./cmd/... ./internal/... ./pkg/...
 
-fmt-go:
+fmt-go: cmd/esbuild/version.go
        go fmt ./cmd/... ./internal/... ./pkg/...
 
@@ -236,4 +237,5 @@ publish-neutral: platform-neutral
 clean:
        rm -f esbuild
+       rm -f cmd/esbuild/version.go
        rm -f npm/esbuild-windows-32/esbuild.exe
        rm -f npm/esbuild-windows-64/esbuild.exe

Side note: @evanw I'd appreciate it if you added the RACE ?= "-race" stuff so that I can run make RACE="" clean test on my unsupported macos 10.9 with a buggy go -race implementation.

@evanw
Copy link
Owner

evanw commented Feb 24, 2021

cmd/esbuild/version.go:1:1: expected 'package', found 'EOF'

That's strange. I've never experienced this personally. I'm guessing it's something to do with the file not being updated atomically? I'm also confused about why that is even running at all because cmd/esbuild/version.go should only be updated if it's older than version.txt, which should never happen outside of releases, which is only relevant to me.

It's a Makefile parallel job race due to insufficient dependencies.

This file is not deleted during make clean because it's checked in: cmd/esbuild/version.go. The make clean command only deletes temporary files that aren't checked in. One reason for checking it in is that I want the Makefile to be optional so that it's possible to build esbuild on Windows without installing make.

@evanw evanw closed this as completed in db38df5 Feb 24, 2021
@Deleplace
Copy link
Contributor Author

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants