Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nargo): add support for testing noir libraries #752

Merged
merged 4 commits into from
Feb 6, 2023
Merged
Changes from all commits
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
18 changes: 9 additions & 9 deletions crates/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,19 @@ impl Driver {
// Optional override to provide a different `main` function to start execution
main_function: Option<FuncId>,
) -> Result<CompiledProgram, ReportedError> {
// Check the crate type
// We don't panic here to allow users to `evaluate` libraries
// which will do nothing
if self.context.crate_graph[LOCAL_CRATE].crate_type != CrateType::Binary {
println!("cannot compile crate into a program as the local crate is not a binary. For libraries, please use the build command");
std::process::exit(1);
};

// Find the local crate, one should always be present
let local_crate = self.context.def_map(LOCAL_CRATE).unwrap();

// All Binaries should have a main function
// If no override for the `main` function has been provided, attempt to find it.
let main_function = main_function.unwrap_or_else(|| {
// Check the crate type
// We don't panic here to allow users to `evaluate` libraries which will do nothing
if self.context.crate_graph[LOCAL_CRATE].crate_type != CrateType::Binary {
println!("cannot compile crate into a program as the local crate is not a binary. For libraries, please use the check command");
std::process::exit(1);
};

// All Binaries should have a main function
local_crate.main_function().expect("cannot compile a program with no main function")
});

Expand Down