Skip to content

Commit

Permalink
Try to test against Windows
Browse files Browse the repository at this point in the history
Adds Windows to the test matrix. We'll see what breaks.
For creack/pty, we need to use the currently-unmerged change in
`creack/pty#155` for Windows support.
  • Loading branch information
abhinav committed Sep 8, 2024
1 parent 2670f5e commit a3ee9e0
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20240907-161636.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: Windows support.
time: 2024-09-07T16:16:36.18073-07:00
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# Don't magically change line endings by default,
# but always use LF in test scripts.
#
# Ref:
# - https://github.com/golang/go/blob/807e01db4840e25e4d98911b28a8fa54244b8dfa/.gitattributes
# - https://github.com/rogpeppe/go-internal/pull/106
* -text
*.txt text eol=lf

*.png filter=lfs diff=lfs merge=lfs -text
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
name: Test (${{ matrix.os}})
strategy:
matrix:
os: ["ubuntu-latest"] # TODO: ["windows-latest"]
os: ["ubuntu-latest", "windows-latest"]
steps:
- uses: actions/checkout@v4
- name: Set up Go
Expand Down
4 changes: 3 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ builds:
- CGO_ENABLED=0
main: .
binary: gs
goos: [darwin, linux]
goos: [darwin, linux, windows]
goarch: [amd64, arm64, arm]
goarm: [5, 6, 7]
ldflags: '-s -w -X main._version={{.Version}}'
ignore:
- goos: darwin
goarch: arm
- goos: windows
goarch: arm
flags:
- -trimpath

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/charmbracelet/bubbletea v1.1.0
github.com/charmbracelet/lipgloss v0.13.0
github.com/charmbracelet/log v0.4.0
github.com/creack/pty v1.1.23
github.com/creack/pty/v2 v2.0.0-20231028221118-e9c1f000f465
github.com/dustin/go-humanize v1.0.1
github.com/mattn/go-isatty v0.0.20
github.com/rogpeppe/go-internal v1.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/charmbracelet/x/ansi v0.2.3 h1:VfFN0NUpcjBRd4DnKfRaIRo53KRgey/nhOoEqo
github.com/charmbracelet/x/ansi v0.2.3/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0=
github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0=
github.com/creack/pty v1.1.23 h1:4M6+isWdcStXEf15G/RbrMPOQj1dZ7HPZCGwE4kOeP0=
github.com/creack/pty v1.1.23/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
github.com/creack/pty/v2 v2.0.0-20231028221118-e9c1f000f465 h1:KQ+iWxxc2qYyfK3GGrjNJ73GvDAd9Ecz8pK4FpdtI6Y=
github.com/creack/pty/v2 v2.0.0-20231028221118-e9c1f000f465/go.mod h1:zTYJ0iXAFhiKeguJdMR/LEecltLOG5Wz3lo1lIi0CLU=
github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE=
github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
1 change: 1 addition & 0 deletions internal/git/gittest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func DefaultConfig() Config {
return Config{
"init.defaultBranch": "main",
"alias.graph": "log --graph --decorate --oneline",
"core.autocrlf": "false",
}
}

Expand Down
16 changes: 8 additions & 8 deletions internal/termtest/with_term.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"sync"
"time"

"github.com/creack/pty"
"github.com/creack/pty/v2"
"github.com/vito/midterm"
)

Expand Down Expand Up @@ -254,14 +254,14 @@ func WithTerm() (exitCode int) {
type terminalEmulator struct {
mu sync.Mutex
cmd *exec.Cmd
pty *os.File
pty pty.Pty
logf func(string, ...any)

term *midterm.Terminal
}

func newVT100Emulator(
f *os.File,
f pty.Pty,
cmd *exec.Cmd,
rows, cols int,
autoResize bool,
Expand Down Expand Up @@ -317,19 +317,19 @@ func (m *terminalEmulator) Close() error {
select {
case waitErr = <-waitErrc:
// ok
case <-time.After(3 * time.Second):
case <-time.After(5 * time.Second):
waitErr = fmt.Errorf("timeout waiting for %v", m.cmd)
_ = m.cmd.Process.Kill()
}

closeErr := m.pty.Close()

return errors.Join(waitErr, closeErr, writeErr)
// On Windows, pty.Close may fail with invalid handle or access denied.
// It's not really a problem, so we ignore the error.
_ = m.pty.Close()
return errors.Join(waitErr, writeErr)
}

func (m *terminalEmulator) FeedKeys(s string) error {
_, err := io.WriteString(m.pty, s)
_ = m.pty.Sync()
return err
}

Expand Down
2 changes: 1 addition & 1 deletion testdata/script/auth_insecure_storage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ gs auth login --forge=shamhub
cmp stderr $WORK/golden/login-secure.stderr

-- golden/login.stderr --
WRN Storing secrets in plain text at $WORK/home/.config/git-spice/secrets.json. Be careful!
WRN Storing secrets in plain text at $WORK${/}home${/}.config${/}git-spice${/}secrets.json. Be careful!
INF shamhub: successfully logged in
-- golden/login-secure.stderr --
INF shamhub: successfully logged in
1 change: 1 addition & 0 deletions testdata/script/branch_submit_remote_prompt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Contents of feature1
await Please select a remote
snapshot dialog
feed \r
await

-- golden/prompt.txt --
### dialog ###
Expand Down

0 comments on commit a3ee9e0

Please sign in to comment.