/
tools_unix.go
34 lines (27 loc) · 1.02 KB
/
tools_unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//go:build !windows
// +build !windows
package test
import "os"
// This package contains platform-specific testing tool implementations for Unix-like platforms.
// CallScriptArgs provides the command and arguments to call the given script on Windows.
//
//nolint:nonamedreturns // multiple return values with non-obvious meaning
func CallScriptArgs(toolPath string) (cmd string, args []string) {
return toolPath, []string{}
}
// CreateInputTool creates a tool that reads two inputs from STDIN and prints them back to the user.
func CreateInputTool(toolPath string) error {
return os.WriteFile(toolPath, []byte(`#!/usr/bin/env bash
read i1
read i2
echo You entered $i1 and $i2
`), 0o500)
}
// CreateLsTool creates a tool in the given folder that lists all files in its current folder.
func CreateLsTool(toolPath string) error {
return os.WriteFile(toolPath, []byte("#!/usr/bin/env bash\n\nls\n"), 0o500)
}
// ScriptName provides the name of the given script file on the Windows.
func ScriptName(command string) string {
return command
}