| 31 | } |
| 32 | |
| 33 | func GetCliPath() (cliPath string, cliDir string, err error) { |
| 34 | _, fileName, _, ok := runtime.Caller(1) |
| 35 | if ok { |
| 36 | // we expect to be in <base>\integrationtest |
| 37 | // we expect the CLI executable to be in <base>\cmd\octopus |
| 38 | myDir := path.Dir(fileName) |
| 39 | cliDir = path.Join(myDir, "../..", "cmd", "octopus") |
| 40 | if _, err = os.Stat(cliDir); os.IsNotExist(err) { |
| 41 | err = fmt.Errorf("expected directory %s not found", cliDir) |
| 42 | return |
| 43 | } |
| 44 | |
| 45 | //goland:noinspection GoBoolExpressions |
| 46 | if runtime.GOOS == "windows" { |
| 47 | cliPath = path.Join(cliDir, "octopus.exe") |
| 48 | } else { |
| 49 | cliPath = path.Join(cliDir, "octopus") |
| 50 | } |
| 51 | } else { |
| 52 | err = errors.New("can't get runtime.caller(1)") |
| 53 | } |
| 54 | return |
| 55 | } |
| 56 | |
| 57 | var ensureCliHasRun = false |
| 58 | |