-
Notifications
You must be signed in to change notification settings - Fork 387
Expand file tree
/
Copy pathdebug.rs
More file actions
52 lines (44 loc) · 2.02 KB
/
debug.rs
File metadata and controls
52 lines (44 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#[cfg(test)]
mod tests {
// Some of these imports are consumed by the injected tests
use assert_cmd::cargo::cargo_bin;
use rexpect::spawn_bash;
// include tests generated by `build.rs`
include!(concat!(env!("OUT_DIR"), "/debug.rs"));
pub fn debugger_execution_success(test_program_dir: &str) {
let nargo_bin =
cargo_bin("nargo").into_os_string().into_string().expect("Cannot parse nargo path");
let timeout_seconds = 30;
let mut dbg_session =
spawn_bash(Some(timeout_seconds * 1000)).expect("Could not start bash session");
// Start debugger and test that it loads for the given program.
dbg_session
.execute(
&format!(
"{nargo_bin} debug --program-dir {test_program_dir} --force-brillig --expression-width 3"
),
".*\\Starting debugger.*",
)
.expect("Could not start debugger");
// While running the debugger, issue a "continue" cmd,
// which should run to the program to end given
// we haven't set any breakpoints.
// ">" is the debugger's prompt, so finding one
// after running "continue" indicates that the
// debugger has not panicked until the end of the program.
dbg_session
.send_line("c")
.expect("Debugger panicked while attempting to step through program.");
dbg_session
.exp_string(">")
.expect("Failed while waiting for debugger to step through program.");
// Run the "quit" command, then check that the debugger confirms
// having successfully solved the circuit witness.
dbg_session.send_line("quit").expect("Failed to quit debugger");
dbg_session
.exp_regex(".*Circuit witness successfully solved.*")
.expect("Expected circuit witness to be successfully solved.");
// Exit the bash session.
dbg_session.send_line("exit").expect("Failed to quit bash session");
}
}