Skip to content

Commit

Permalink
chore(script): fix no tty err for bubbletea in gh-actions (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Feb 12, 2024
1 parent df3b51f commit 012dda3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
43 changes: 33 additions & 10 deletions src/app/proxy/pixa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package proxy_test

import (
"fmt"
"os"
"path/filepath"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -18,6 +19,15 @@ import (
"github.com/snivilised/pixa/src/internal/matchers"
)

func openInputTTY() (*os.File, error) {
f, err := os.Open("/dev/tty")
if err != nil {
return nil, fmt.Errorf("could not open a new TTY: %w", err)
}

return f, nil
}

const (
BackyardWorldsPlanet9Scan01 = "nasa/exo/Backyard Worlds - Planet 9/sessions/scan-01"
BackyardWorldsPlanet9Scan02 = "nasa/exo/Backyard Worlds - Planet 9/sessions/scan-02"
Expand Down Expand Up @@ -80,15 +90,15 @@ func assertInFs(entry *samplerTE, bs *command.Bootstrap, directory string) {
vfs := bs.Vfs

if entry.mandatory != nil && entry.dry {
dejaVuSupplement := filepath.Join(common.Definitions.Filing.DejaVu, entry.supplement)
supplement := helpers.Path(entry.intermediate, dejaVuSupplement)
dejaVu := filepath.Join(common.Definitions.Filing.DejaVu, entry.supplement)
supplement := helpers.Path(entry.intermediate, dejaVu)

for _, original := range entry.mandatory {
originalPath := filepath.Join(supplement, original)

if entry.withFake {
withFake := filing.ComposeFake(original, bs.Configs.Advanced.FakeLabel())
originalPath = filepath.Join(directory, withFake)
fake := filing.ComposeFake(original, bs.Configs.Advanced.FakeLabel())
originalPath = filepath.Join(directory, fake)
}

Expect(matchers.AsFile(originalPath)).To(matchers.ExistInFS(vfs))
Expand All @@ -98,17 +108,28 @@ func assertInFs(entry *samplerTE, bs *command.Bootstrap, directory string) {

var _ = Describe("pixa", Ordered, func() {
var (
repo string
l10nPath string
configPath string
root string
vfs storage.VirtualFS
repo string
l10nPath string
configPath string
root string
vfs storage.VirtualFS
withoutRenderer bool
)

BeforeAll(func() {
repo = helpers.Repo("")
l10nPath = helpers.Path(repo, "test/data/l10n")
configPath = helpers.Path(repo, "test/data/configuration")

var (
err error
f *os.File
)

if f, err = openInputTTY(); err != nil {
withoutRenderer = true
}
f.Close()
})

BeforeEach(func() {
Expand All @@ -130,14 +151,16 @@ var _ = Describe("pixa", Ordered, func() {
bootstrap := command.Bootstrap{
Vfs: vfs,
Presentation: common.PresentationOptions{
WithoutRenderer: true,
WithoutRenderer: withoutRenderer,
},
}

if !entry.isTui {
args = append(args, "--no-tui")
}

fmt.Printf("======> XTERM: '%v'\n", os.Getenv("XTERM"))

tester := helpers.CommandTester{
Args: args,
Root: bootstrap.Root(func(co *command.ConfigureOptionsInfo) {
Expand Down
2 changes: 1 addition & 1 deletion test/data/configuration/pixa-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sampler:
folders: 1
interaction:
tui:
per-item-delay: "1s"
per-item-delay: "1ms"
advanced:
abort-on-error: false
overwrite-on-collision: false
Expand Down

0 comments on commit 012dda3

Please sign in to comment.