Skip to content

Commit

Permalink
Add test command to run and wait for sigint
Browse files Browse the repository at this point in the history
  • Loading branch information
infogulch committed Apr 2, 2024
1 parent 6afe70c commit e469e9d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"io/fs"
"os"
"os/exec"
"os/signal"
"path/filepath"
"runtime"
"strings"
"sync"
"syscall"
"time"

"github.com/Hellseher/go-shellquote"
Expand Down Expand Up @@ -36,11 +38,12 @@ func main() {
}
}()

command := ""
if len(os.Args) > 1 {
switch os.Args[1] {
case "hurl":
goto hurl
}
command = os.Args[0]
}
if command == "hurl" {
goto hurl
}

// Build xtemplate
Expand Down Expand Up @@ -90,6 +93,13 @@ hurl:
try0(cmd.Run(), "run hurl")
fmt.Println("~ Run hurl ~")
}

if command == "start" {
// block until ^C or xtemplate exits
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
<-sigs
}
}

func split(a string) []string { return try(shellquote.Split(a))("split args") }
Expand Down

0 comments on commit e469e9d

Please sign in to comment.