Skip to content

Commit

Permalink
build: migrate "./all.bash ci" script test to go test
Browse files Browse the repository at this point in the history
"./build/all.bash ci" trigges go test, go generate, npm
build, npm lint and npm test.

Remove npm ansi coding through npm config set color false

Because logs are printed as text without any rendering in
LUCI, coloring is disabled for npm and mocha during
integration test.

LUCI test run https://ci.chromium.org/b/8724574189483344737

For #3533

Change-Id: I8cb3340db48ed91cfb06165dd227241ea5f5b0a4
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/642097
Reviewed-by: Robert Findley <[email protected]>
kokoro-CI: kokoro <[email protected]>
Commit-Queue: Hongxiang Jiang <[email protected]>
Auto-Submit: Hongxiang Jiang <[email protected]>
  • Loading branch information
h9jiang authored and gopherbot committed Jan 27, 2025
1 parent 2e07aa3 commit 8b6e6f8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
43 changes: 35 additions & 8 deletions build/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ func TestIntegration(t *testing.T) {
if err != nil {
t.Fatalf("failed to read current dir: %v", err)
}
root := filepath.Dir(dir)

// Build docker image.
// TODO(hxjiang): use Go in PATH instead of env GOVERSION. LUCI will prepare
// the Go in different version so vscode-go test don't need to worry.
dockerBuild := exec.Command("docker", "build", "-q", "-f", "./build/Dockerfile", ".")
// The docker build must be executed at the root of the vscode-go repository
// to ensure the entire repository is copied into the image.
dockerBuild.Dir = root
dockerBuild.Dir = filepath.Dir(dir)
output, err := dockerBuild.Output()
if err != nil {
t.Fatalf("failed to build docker image: %v", err)
Expand All @@ -42,14 +41,42 @@ func TestIntegration(t *testing.T) {
t.Logf("image cleanup log:\n%s\n", output)
}()

// Run integration test using previous build docker image.
// Run tests using previous build docker image.
//
// Coloring is disabled for integration tests but preserved for manual
// triggers.
// Use "npm config set color false" to disable npm color output globally,
// and because we cannot access the Mocha command directly in this script,
// we use env "FORCE_COLOR=0" to disable its color output.
script := `npm config set color false;
npm ci;
echo "**** Set up virtual display ****";
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
trap "kill \"\$(jobs -p)\"" EXIT;
export DISPLAY=:99;
sleep 3;
echo "**** Run settings generator ****";
go run ./tools/generate.go -w=false -gopls=true;
echo "**** Test build ****";
npm run compile;
echo "**** Run Go tests ****";
go test ./...;
echo "**** Run test ****";
FORCE_COLOR=0 npm run unit-test;
FORCE_COLOR=0 npm test --silent;
echo "**** Run lint ****";
npm run lint`
// For debug tests, we need ptrace.
// TODO(hxjiang): migrate the shell based ci test with go test.
// TODO(hxjiang): remove ANSI escape codes from npm log.
dockerRun := exec.Command("docker", "run", "--cap-add", "SYS_PTRACE", "--shm-size=8G", "--workdir=/workspace", imageID, "ci")
output, err = dockerRun.CombinedOutput()
cmd := exec.Command("docker", "run", "--cap-add", "SYS_PTRACE", "--shm-size=8G", "--workdir=/workspace/extension", "--entrypoint", "/bin/bash", imageID, "-c", script)
output, err = cmd.CombinedOutput()
t.Logf("integration test log:\n%s\n", output)
if err != nil {
t.Errorf("failed to run integration test: %v", err)
t.Errorf("failed to run integration test in docker: %v", err)
}
}
2 changes: 1 addition & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"test": "npm run test-compile && node ./out/test/runTest.js",
"lint": "gts lint src test",
"fix-lint": "gts fix src test",
"unit-test": "npm run test-compile && node ./node_modules/mocha/bin/_mocha -u tdd --timeout 5000 --colors ./out/test/unit",
"unit-test": "npm run test-compile && node ./node_modules/mocha/bin/_mocha -u tdd --timeout 5000 ./out/test/unit",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\""
},
"extensionDependencies": [],
Expand Down

0 comments on commit 8b6e6f8

Please sign in to comment.