Open jcaplan opened 2 years ago
another thing for a clean repl that's really helpful in driving embedded testing is nice color coded logging on the host. being able to assign each repl a name and getting something back like:
dut> ifconfig
dut< insert_ifconfig_output_here
where dut<
and dut>
are coloured differently.
setup something like:
let mut p = spawn_ssh(ip_addr, username, password)?
.set_name('dut')
.repl_log();
let output = p.run("ifconfig")?;
works great if you're doing tests with multiple targets and/or also running stuff in a terminal on the host machine.
without colour/other control character stripping I get a test failure because my bash prompt pollutes the terminal. This is a problem people likely face with pexpect all the time (I know I have) and would be nice if there was a built-in way to deal with it.
test session::tests::test_bash ... FAILED
test session::tests::test_kill_timeout ... ok
test session::tests::test_bash_control_chars ... ok
failures:
---- session::tests::test_bash stdout ----
thread 'session::tests::test_bash' panicked at 'assertion failed: `(left == right)`
left: `"/tmp\r\n"`,
right: `"\u{1b}[?2004l\r/tmp\r\n\u{1b}[?2004h"`', src/session.rs:540:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
It would also be nice to borrow from
replwrap
and have a method to fold these three lines into one:becomes something like
other things that would help missing from pexpect that I've had to add for run(): take multiple commands to pass a script that you read from the host filesystem either as a vec or by splitting on newlines, sanitizing carriage returns, stripping out colour