Skip to content

Commit

Permalink
chore: prevent debugger tests from speaking to a backend (#4313)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

We can avoid speaking to a backend in the noir debugger tests as we can
just pass in an explicit expression width. (although as we're generating
brillig then expression width doesn't really matter)

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
TomAFrench authored Feb 9, 2024
1 parent 87bb6e2 commit d1a2d18
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tooling/debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ serde_json.workspace = true
[dev-dependencies]
assert_cmd = "2.0.12"
rexpect = "0.5.0"
test-binary = "3.0.1"
tempfile.workspace = true
12 changes: 5 additions & 7 deletions tooling/debugger/tests/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,27 @@ mod tests {

use rexpect::spawn_bash;

test_binary::build_test_binary_once!(mock_backend, "../backend_interface/test-binaries");

// 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 mock_backend_path =
path_to_mock_backend().into_string().expect("Cannot parse mock_backend path");

let mut dbg_session = spawn_bash(Some(10000)).expect("Could not start bash session");

// Set backend to `/dev/null` to force an error if nargo tries to speak to a backend.
dbg_session
.send_line(&format!("export NARGO_BACKEND_PATH={}", mock_backend_path))
.send_line("export NARGO_BACKEND_PATH=/dev/null")
.expect("Could not export NARGO_BACKEND_PATH.");
dbg_session.wait_for_prompt().expect("Could not export NARGO_BACKEND_PATH.");

// Start debugger and test that it loads for the given program.
dbg_session
.execute(
&format!("{} debug --program-dir {} --force-brillig", nargo_bin, test_program_dir),
&format!(
"{nargo_bin} debug --program-dir {test_program_dir} --force-brillig --expression-width 3"
),
".*\\Starting debugger.*",
)
.expect("Could not start debugger");
Expand Down

0 comments on commit d1a2d18

Please sign in to comment.