noir-lang/vscode-noir

Run Test Error: cannot find a Nargo.toml in <VS_Code_root_directory>

Closed this issue · 4 comments

Aim

Running a test by clicking the "Run Test" button in a main.nr file that is located in:

VS_Code_root_directory
└── sub_folder
    └── src
        └── main.nr

Expected Behavior

Test runs.

Bug

 *  Executing task: /<home_dir>/.nargo/bin/nargo test test_main 

Error: cannot find a Nargo.toml in /Users/s/Dev

Location:
    crates/nargo_cli/src/cli/mod.rs:67:30

 *  The terminal process "/<home_dir>/.nargo/bin/nargo 'test', 'test_main'" failed to launch (exit code: 1). 
 *  Terminal will be reused by tasks, press any key to close it.

To Reproduce

  1. Run nargo new <project_name> in a VS Code instance's root directory
  2. Click the "Run Test" button in <project_name>/src/main.nr

Environment

Nargo version:

  • v0.8.0 release (i.e. commit d9e346) installed with noirup -v 0.8.0

Test ran:

  • The default test generated with nargo new <project_name>, i.e.
    fn main(x : Field, y : pub Field) {
        assert(x != y);
    }
    
    #[test]
    fn test_main() {
        main(1, 2);
    
        // Uncomment to make test fail
        // main(1, 1);
    }

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

phated commented

I believe this is solved by noir-lang/noir#2226 which roots everything based on Nargo.toml files

Getting the same error with the latest Nargo nightly (commit 3d1b252) paired with v0.0.4-pre of the extension.

Do I need to compile the extension from source to get the fix?

phated commented

Doing some more debugging. If you tried to run nargo test inside of "VS_Code_root_directory` you'd get the same panic; however, in the vscode plugin, we know the location of the package the test is being resolved against so we can set an arbitrary root directory that allows this to work.

phated commented

Note that this needs the linked PRs and a custom build of the extension with #29 included