Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions tests/by-util/test_stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,13 +866,24 @@ fn test_saved_state_valid_formats() {
let (path, _controller, _replica) = pty_path();
let (_at, ts) = at_and_ts!();

// Generate valid saved state from the actual terminal
let saved = unwrap_or_return!(expected_result(&ts, &["-g", "--file", &path])).stdout_move_str();
// Generate valid saved state from the actual terminal with our own stty,
// so the test doesn't depend on the system stty
let saved = ts
.ucmd()
.args(&["-g", "--file", &path])
.succeeds()
.stdout_move_str();
let saved = saved.trim();

let result = ts.ucmd().args(&["--file", &path, saved]).run();

result.success().no_stderr();
result.success().no_output();

// Restoring the state leaves the terminal as it was

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this restores the state that is already set, so it can't really catch much. could you change a setting first, then restore and compare?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. It now sets -echo first, checks the saved state changed, then restores and compares.

ts.ucmd()
.args(&["-g", "--file", &path])
.succeeds()
.stdout_only(format!("{saved}\n"));

let exp_result = unwrap_or_return!(expected_result(&ts, &["--file", &path, saved]));
let normalized_stderr = normalize_stderr(result.stderr_str());
Expand Down
Loading