Skip to content

Commit 9a8581c

Browse files
authored
Verify go test works without node installed (#64082)
1 parent 61691a5 commit 9a8581c

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ jobs:
6060
package-manager-cache: false
6161
- run: npm ci --registry=https://packagefeedproxy.microsoft.io/npm/
6262

63+
go-test:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
67+
- uses: ./.github/actions/setup-go
68+
- name: Prepare standalone tsc module
69+
run: |
70+
mkdir "$RUNNER_TEMP/go-test-bin"
71+
ln -s "$(go env GOROOT)/bin/go" "$RUNNER_TEMP/go-test-bin/go"
72+
cp -R tsc "$RUNNER_TEMP/tsc"
73+
- name: Tests without Node.js
74+
run: |
75+
export PATH="$RUNNER_TEMP/go-test-bin"
76+
export GOEXPERIMENT=ms_nocgo_opensslcrypto
77+
export CGO_ENABLED=0
78+
! command -v node
79+
cd "$RUNNER_TEMP/tsc"
80+
go test ./...
81+
go test -run=- -bench=. -benchtime=1x ./...
82+
6383
test:
6484
strategy:
6585
fail-fast: ${{ github.event_name == 'merge_group' }}
@@ -322,6 +342,7 @@ jobs:
322342
- extension
323343
- format
324344
- generate
345+
- go-test
325346
- lint
326347
- misc
327348
- package-feed-proxy

‎tsc/cmd/tsc/sys_unix_test.go‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ package main
55
import (
66
"bufio"
77
"bytes"
8+
"fmt"
9+
"os"
10+
"os/exec"
811
"strconv"
912
"strings"
1013
"syscall"
@@ -15,8 +18,32 @@ import (
1518
)
1619

1720
func TestChildProcessCloseDoesNotWaitForLauncherDescendants(t *testing.T) {
21+
const (
22+
launcherArg = "child-process-launcher"
23+
descendantArg = "child-process-descendant"
24+
)
25+
if len(os.Args) > 1 {
26+
switch os.Args[len(os.Args)-1] {
27+
case launcherArg:
28+
cmd := exec.Command(os.Args[0], "-test.run=^TestChildProcessCloseDoesNotWaitForLauncherDescendants$", "--", descendantArg)
29+
cmd.Stdout = os.Stdout
30+
cmd.Stderr = os.Stderr
31+
assert.NilError(t, cmd.Start())
32+
fmt.Println(cmd.Process.Pid)
33+
assert.NilError(t, cmd.Wait())
34+
return
35+
case descendantArg:
36+
time.Sleep(time.Minute)
37+
return
38+
}
39+
}
40+
1841
t.Parallel()
19-
process, err := spawnProcess([]string{"sh", "-c", "nohup sleep 60 & echo $!; wait"}, "", &bytes.Buffer{})
42+
process, err := spawnProcess(
43+
[]string{os.Args[0], "-test.run=^TestChildProcessCloseDoesNotWaitForLauncherDescendants$", "--", launcherArg},
44+
"",
45+
&bytes.Buffer{},
46+
)
2047
assert.NilError(t, err)
2148
pidText, err := bufio.NewReader(process).ReadString('\n')
2249
assert.NilError(t, err)

0 commit comments

Comments
 (0)