feat: miro test command
This commit is contained in:
@@ -12,6 +12,12 @@ import (
|
||||
|
||||
const recordShellName = "shell.sh"
|
||||
|
||||
const (
|
||||
compareMarkerEnvName = "MIRO_COMPARE_MARKER"
|
||||
compareMarkerEnabledValue = "1"
|
||||
compareOutputMarker = "__MIRO_E2E_BEGIN__"
|
||||
)
|
||||
|
||||
//go:embed record_shell.sh
|
||||
var recordShellFS embed.FS
|
||||
|
||||
@@ -21,8 +27,10 @@ func recordShellPath(testDir string) string {
|
||||
|
||||
func ensureRecordShell(testDir string) error {
|
||||
path := recordShellPath(testDir)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return nil
|
||||
if info, err := os.Stat(path); err == nil {
|
||||
if info.IsDir() {
|
||||
return fmt.Errorf("recorder shell %q is a directory; remove it and rerun `miro init`", path)
|
||||
}
|
||||
} else if !errors.Is(err, os.ErrNotExist) {
|
||||
return fmt.Errorf("failed to check recorder shell %q: %v", path, err)
|
||||
}
|
||||
@@ -72,15 +80,22 @@ func buildRecordShellScript() string {
|
||||
}
|
||||
|
||||
func recordSessionEnv(sandbox recordSandbox, sandboxConfig map[string]string) []string {
|
||||
return recordSessionEnvWithExtra(sandbox, sandboxConfig, nil)
|
||||
}
|
||||
|
||||
func recordSessionEnvWithExtra(sandbox recordSandbox, sandboxConfig, extraEnv map[string]string) []string {
|
||||
env := append([]string{}, os.Environ()...)
|
||||
env = append(env,
|
||||
"MIRO_HOST_HOME="+sandbox.hostHome,
|
||||
"MIRO_HOST_TMP="+sandbox.hostTmp,
|
||||
"MIRO_PATH_ENV="+sandbox.pathEnv,
|
||||
)
|
||||
for _, key := range sortedSandboxKeys(sandboxConfig) {
|
||||
for _, key := range sortedKeys(sandboxConfig) {
|
||||
env = append(env, sandboxEnvName(key)+"="+sandboxConfig[key])
|
||||
}
|
||||
for _, key := range sortedKeys(extraEnv) {
|
||||
env = append(env, key+"="+extraEnv[key])
|
||||
}
|
||||
|
||||
return env
|
||||
}
|
||||
@@ -89,9 +104,9 @@ func sandboxEnvName(key string) string {
|
||||
return "MIRO_" + strings.ToUpper(key)
|
||||
}
|
||||
|
||||
func sortedSandboxKeys(sandboxConfig map[string]string) []string {
|
||||
keys := make([]string, 0, len(sandboxConfig))
|
||||
for key := range sandboxConfig {
|
||||
func sortedKeys(values map[string]string) []string {
|
||||
keys := make([]string, 0, len(values))
|
||||
for key := range values {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
Reference in New Issue
Block a user