Skip to content

Commit e3bc6da

Browse files
committed
make: add task to check NodeJS version before running tests
Signed-off-by: deadprogram <[email protected]>
1 parent 3e2471d commit e3bc6da

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,22 @@ lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a:
267267
@if [ ! -e lib/wasi-libc/Makefile ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
268268
cd lib/wasi-libc && make -j4 EXTRA_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" MALLOC_IMPL=none CC=$(CLANG) AR=$(LLVM_AR) NM=$(LLVM_NM)
269269

270+
# Check for Node.js used during WASM tests.
271+
NODEJS_VERSION := $(word 1,$(subst ., ,$(shell node -v | cut -c 2-)))
272+
MIN_NODEJS_VERSION=16
273+
274+
.PHONY: check-nodejs-version
275+
check-nodejs-version:
276+
ifeq (, $(shell which node))
277+
@echo "Install NodeJS version 16+ to run tests."; exit 1;
278+
endif
279+
@if [ $(NODEJS_VERSION) -lt $(MIN_NODEJS_VERSION) ]; then echo "Install NodeJS version 16+ to run tests."; exit 1; fi
270280

271281
# Build the Go compiler.
272282
tinygo:
273283
@if [ ! -f "$(LLVM_BUILDDIR)/bin/llvm-config" ]; then echo "Fetch and build LLVM first by running:"; echo " make llvm-source"; echo " make $(LLVM_BUILDDIR)"; exit 1; fi
274284
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOENVFLAGS) $(GO) build -buildmode exe -o build/tinygo$(EXE) -tags "byollvm osusergo" -ldflags="-X github.com/tinygo-org/tinygo/goenv.GitSha1=`git rev-parse --short HEAD`" .
275-
test: wasi-libc
285+
test: wasi-libc check-nodejs-version
276286
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=20m -buildmode exe -tags "byollvm osusergo" ./builder ./cgo ./compileopts ./compiler ./interp ./transform .
277287

278288
# Standard library packages that pass tests on darwin, linux, wasi, and windows, but take over a minute in wasi

0 commit comments

Comments
 (0)