diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3c2edf9d3f..ad342b8fb0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -269,12 +269,14 @@ jobs: name: chezmoi-windows-amd64 path: dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe test-ubuntu: + name: test-ubuntu-umask${{ matrix.umask }}-${{ matrix.test-index }} strategy: fail-fast: false matrix: umask: - "022" - "002" + test-index: [0, 1] needs: changes runs-on: ubuntu-20.04 # use older Ubuntu for older glibc permissions: @@ -318,8 +320,14 @@ jobs: if: github.event_name == 'push' || needs.changes.outputs.code == 'true' env: CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }} - run: | - go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o${{ matrix.umask }}" -race -timeout=1h ./... + TEST_FLAGS: '-ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o${{ matrix.umask }}" -race -timeout=1h' + run: | + if [ "${{ matrix.test-index }}" -eq 0 ]; then + go test ./... -short ${{ env.TEST_FLAGS }} + go test ./internal/cmd -run=TestScript -filter='^[0-9a-kA-K]' -v ${{ env.TEST_FLAGS }} + else + go test ./internal/cmd -run=TestScript -filter='^[l-zL-Z]' -v ${{ env.TEST_FLAGS }} + fi test-website: runs-on: ubuntu-22.04 permissions: diff --git a/internal/cmd/main_test.go b/internal/cmd/main_test.go index 3b87b26a211..53e29934314 100644 --- a/internal/cmd/main_test.go +++ b/internal/cmd/main_test.go @@ -48,8 +48,10 @@ var ( ) func TestMain(m *testing.M) { - flag.StringVar(&filterRegex, "filter", "", "regex to filter test scripts") - flag.Parse() + if strings.HasSuffix(os.Args[0], "test") { + flag.StringVar(&filterRegex, "filter", "", "regex to filter test scripts") + flag.Parse() + } os.Exit(testscript.RunMain(m, map[string]func() int{ "chezmoi": func() int { return cmd.Main(cmd.VersionInfo{ @@ -77,7 +79,7 @@ func TestScript(t *testing.T) { } var filteredFiles []string for _, f := range files { - baseName := filepath.Base(f) + baseName := strings.Split(filepath.Base(f), ".")[0] if re.MatchString(baseName) { filteredFiles = append(filteredFiles, f) }