-
Notifications
You must be signed in to change notification settings - Fork 792
/
Copy pathall.bash
executable file
·106 lines (93 loc) · 2.47 KB
/
all.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
set -e
# Copyright (C) Microsoft Corporation. All rights reserved.
# Modification copyright 2020 The Go Authors. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root for license information.
usage() {
cat <<EOUSAGE
Usage: $0 [subcommand]
Available subcommands:
help - display this help message.
test - build and test locally. Some tests may fail if vscode is already in use.
testlocal - build and test in a locally built container.
ci - build and test with headless vscode. Requires Xvfb.
EOUSAGE
}
# TODO(hyangah): commands for building docker container and running tests locally with docker run.
root_dir() {
local script_name=$(readlink -f "${0}")
local script_dir=$(dirname "${script_name}")
local parent_dir=$(dirname "${script_dir}")
echo "${parent_dir}"
}
setup_virtual_display() {
echo "**** Set up virtual display ****"
# Start xvfb (an in-memory display server for UNIX-like operating system)
# so we can launch a headless vscode for testing.
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
trap 'kill "$(jobs -p)"' EXIT
export DISPLAY=:99
sleep 3 # Wait for xvfb to be up.
}
go_binaries_info() {
echo "**** Go version ****"
go version
df -h | grep shm
}
run_doc_test() {
echo "**** Run settings generator ****"
go run -C extension ./tools/generate.go -w=false -gopls=true
}
run_test() {
pushd .
cd "$(root_dir)/extension"
echo "**** Test build ****"
npm ci
npm run compile
echo "**** Run Go tests ****"
VSCODE_GO_TEST_ALL="true" go test ./...
echo "**** Run test ****"
npm run unit-test
npm test --silent
popd
}
run_lint() {
pushd .
cd "$(root_dir)/extension"
echo "**** Run lint ****"
npm run lint
popd
}
run_test_in_docker() {
echo "**** Building the docker image ***"
docker build -t vscode-test-env ${GOVERSION:+ --build-arg GOVERSION="${GOVERSION}"} -f ./build/Dockerfile .
# For debug tests, we need ptrace.
docker run --cap-add SYS_PTRACE --shm-size=8G --workdir=/workspace vscode-test-env ci
}
main() {
cd "$(root_dir)" # always start to run from the extension source root.
case "$1" in
"help"|"-h"|"--help")
usage
exit 0
;;
"test")
go_binaries_info
run_test
;;
"testlocal")
run_test_in_docker
;;
"ci")
go_binaries_info
setup_virtual_display
run_doc_test
run_test
run_lint
;;
*)
usage
exit 2
esac
}
main $@