Skip to content

Comments

feat(config): consistent CLI behaviour and e2e test coverage#801

Open
natalie-o-perret wants to merge 11 commits intomasterfrom
natalieperret/sc-167884/feature-request-cli-consistent-behaviour
Open

feat(config): consistent CLI behaviour and e2e test coverage#801
natalie-o-perret wants to merge 11 commits intomasterfrom
natalieperret/sc-167884/feature-request-cli-consistent-behaviour

Conversation

@natalie-o-perret
Copy link
Contributor

@natalie-o-perret natalie-o-perret commented Feb 23, 2026

Description

Checklist

(For exoscale contributors)

  • Changelog updated (under Unreleased block, and add the Pull Request #number for each bit you add to the CHANGELOG.md)
  • Testing

Testing

- Add PTY infrastructure for testing interactive commands using testscript
- Add execpty command with support for 8 input tokens
- Add automated tests for interactive flows
- Fix config file creation when adding first account
- Fix circular dependency in config set command
- Fix panic when used without default account set #798
- Update CI workflow to use build action and add test job dependencies
- Remove redundant testscript.yml workflow
- Make integration tests resilient when no test files exist

#800
- Exit with code 130 and print 'Error: Operation Cancelled' on Ctrl+C
  in exo config menu and exo config add flows
- Propagate zone selection cancellation cleanly via io.EOF
- Rename tests/integ/ to tests/integration/ with clearer split:
  - without-api/ for CI-safe tests
  - with-api/ for tests requiring real API credentials
- Add tests/integration/README.md documenting test structure
- Add 13 new e2e testscript scenarios covering cancellation, input
  validation, multi-account workflows and edge cases

Relates-to: SC-167884
@natalie-o-perret natalie-o-perret changed the title Natalieperret/sc 167884/feature request cli consistent behaviour feat(config): consistent CLI behaviour and e2e test coverage Feb 23, 2026
utils.AskQuestion uses bufio.ReadString('\n') which blocks in PTY raw
mode — after promptui.Select (zone picker) returns, the terminal buffer
already holds '\r' from raw mode, which is never translated to '\n'.

Replace with a promptui.Prompt (askSetDefault) that reads character-by-
character in raw mode and accepts '\r' as confirmation, matching the
behaviour of the other interactive prompts.

Fixes timeout in:
- add_interactive_second_account
- add_interactive_make_new_default
- add_interactive_duplicate_name

Relates-to: SC-167884
…Y race

- Rename tests/integration/ to tests/integ/ for consistency
- Fix package name in suite.go from 'integration' to 'integ'
- Fix tests/e2e module name to github.com/exoscale/cli/internal/e2e
  (was incorrectly sharing the same name as tests/integ)
- Fix race condition in runInPTY: cmd.Wait() was running in a goroutine
  without synchronisation, causing ProcessState to be unpopulated when
  cmdExecPTY read the exit code (always -1 on Linux via EIO path)
The goroutine-based cmd.Wait() approach introduced a race where
ProcessState could be nil when cmdExecPTY read the exit code.
Revert to the simpler sequential approach: wait for the process,
close the PTY master, then drain the output channel.
…o reader

promptui.Prompt uses readline which defers its initial PTY render until the
first keystroke arrives. This creates a deadlock with the settle-based PTY
test harness: the harness waits for output-then-silence before sending each
keystroke, but the prompt waits for a keystroke before producing output.

Replace with a plain bufio.ReadString('\n') that mirrors the other prompts
and avoids readline raw-mode entirely. The PTY line discipline (cooked mode,
restored by the preceding promptui.Select) translates '\r' -> '\n' for us.
…ness

The 80ms inter-keystroke delay was too short on CI: keystrokes sent
after zone selection arrived before the process had rendered the next
prompt (e.g. 'Make default? [y/n]'), causing the process to hang
waiting for input with an empty inputs channel.

Increase the fixed delay to 300ms to give the process enough time to
render each prompt before the next keystroke is sent.
@natalie-o-perret natalie-o-perret marked this pull request as ready for review February 24, 2026 09:17
@natalie-o-perret natalie-o-perret requested a review from a team February 24, 2026 09:17
@natalie-o-perret natalie-o-perret force-pushed the natalieperret/sc-167884/feature-request-cli-consistent-behaviour branch from afe431b to c51ae1d Compare February 24, 2026 09:24
switch err {
case promptui.ErrInterrupt:
return nil
fmt.Fprintln(os.Stderr, "Error: Operation Cancelled")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Fatal may do the same behavior, except if you want this specific exitcode. If 130 is a known exit code, we may have constants somewhere to understand those exitcodes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you're right 💭 lemme think this through.
I had some idea to have a consistent behaviour across the cli 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants