@@ -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}
0 commit comments