Skip to content

Commit

Permalink
Disable command tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
adambabik committed Feb 2, 2024
1 parent b6a3222 commit 8674bc2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
5 changes: 2 additions & 3 deletions internal/command/command_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"os"
"os/exec"
"syscall"

"github.com/pkg/errors"
"go.uber.org/zap"
Expand Down Expand Up @@ -69,11 +68,11 @@ func (c *NativeCommand) Start(ctx context.Context) (err error) {

if f, ok := stdin.(*os.File); ok && f != nil {
// Duplicate /dev/stdin.
newStdinFd, err := dup(int(f.Fd()))
newStdinFd, err := dup(f.Fd())
if err != nil {
return errors.Wrap(err, "failed to dup stdin")
}
syscall.CloseOnExec(newStdinFd)
closeOnExec(newStdinFd)

// Setting stdin to the non-block mode fails on the simple "read" command.
// On the other hand, it allows to use SetReadDeadline().
Expand Down
2 changes: 2 additions & 0 deletions internal/command/command_native_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !windows

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions internal/command/command_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !windows

package command

import (
Expand Down
12 changes: 10 additions & 2 deletions internal/command/command_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ func disableEcho(fd uintptr) error {
return errors.Wrap(err, "failed to set tty attr")
}

func dup(fd int) (int, error) {
return syscall.Dup(fd)
func dup(fd uintptr) (uintptr, error) {
dupFd, err := syscall.Dup(int(fd))
if err != nil {
return 0, err
}
return uintptr(dupFd), nil
}

func closeOnExec(fd uintptr) {
syscall.CloseOnExec(int(fd))
}

// func setSysProcAttrPgid(cmd *exec.Cmd) {
Expand Down
2 changes: 2 additions & 0 deletions internal/command/command_virtual_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !windows

package command

import (
Expand Down
8 changes: 6 additions & 2 deletions internal/command/command_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build windows

package runner
package command

import (
"os"
Expand All @@ -13,10 +13,14 @@ func setSysProcAttrCtty(cmd *exec.Cmd) {}

func setSysProcAttrPgid(cmd *exec.Cmd) {}

func dup(fd int) (int, error) {
func dup(fd uintptr) (uintptr, error) {
return fd, nil
}

func closeOnExec(uintptr) {
// noop
}

func disableEcho(fd uintptr) error {
return errors.New("Error: Environment not supported! " +
"Runme currently doesn't support PowerShell. " +
Expand Down

0 comments on commit 8674bc2

Please sign in to comment.