Skip to content

Commit 8b6e6f8

Browse files
h9jianggopherbot
authored andcommitted
build: migrate "./all.bash ci" script test to go test
"./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]>
1 parent 2e07aa3 commit 8b6e6f8

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

build/integration_test.go

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ func TestIntegration(t *testing.T) {
1717
if err != nil {
1818
t.Fatalf("failed to read current dir: %v", err)
1919
}
20-
root := filepath.Dir(dir)
2120

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

45-
// Run integration test using previous build docker image.
44+
// Run tests using previous build docker image.
45+
//
46+
// Coloring is disabled for integration tests but preserved for manual
47+
// triggers.
48+
// Use "npm config set color false" to disable npm color output globally,
49+
// and because we cannot access the Mocha command directly in this script,
50+
// we use env "FORCE_COLOR=0" to disable its color output.
51+
script := `npm config set color false;
52+
npm ci;
53+
54+
echo "**** Set up virtual display ****";
55+
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
56+
trap "kill \"\$(jobs -p)\"" EXIT;
57+
export DISPLAY=:99;
58+
sleep 3;
59+
60+
echo "**** Run settings generator ****";
61+
go run ./tools/generate.go -w=false -gopls=true;
62+
63+
echo "**** Test build ****";
64+
npm run compile;
65+
66+
echo "**** Run Go tests ****";
67+
go test ./...;
68+
69+
echo "**** Run test ****";
70+
FORCE_COLOR=0 npm run unit-test;
71+
FORCE_COLOR=0 npm test --silent;
72+
73+
echo "**** Run lint ****";
74+
npm run lint`
4675
// For debug tests, we need ptrace.
47-
// TODO(hxjiang): migrate the shell based ci test with go test.
48-
// TODO(hxjiang): remove ANSI escape codes from npm log.
49-
dockerRun := exec.Command("docker", "run", "--cap-add", "SYS_PTRACE", "--shm-size=8G", "--workdir=/workspace", imageID, "ci")
50-
output, err = dockerRun.CombinedOutput()
76+
cmd := exec.Command("docker", "run", "--cap-add", "SYS_PTRACE", "--shm-size=8G", "--workdir=/workspace/extension", "--entrypoint", "/bin/bash", imageID, "-c", script)
77+
output, err = cmd.CombinedOutput()
5178
t.Logf("integration test log:\n%s\n", output)
5279
if err != nil {
53-
t.Errorf("failed to run integration test: %v", err)
80+
t.Errorf("failed to run integration test in docker: %v", err)
5481
}
5582
}

extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"test": "npm run test-compile && node ./out/test/runTest.js",
4848
"lint": "gts lint src test",
4949
"fix-lint": "gts fix src test",
50-
"unit-test": "npm run test-compile && node ./node_modules/mocha/bin/_mocha -u tdd --timeout 5000 --colors ./out/test/unit",
50+
"unit-test": "npm run test-compile && node ./node_modules/mocha/bin/_mocha -u tdd --timeout 5000 ./out/test/unit",
5151
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\""
5252
},
5353
"extensionDependencies": [],

0 commit comments

Comments
 (0)