Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 6 additions & 11 deletions tooling/nargo_cli/src/cli/check_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use noirc_frontend::{
use super::NargoConfig;
use super::{fs::write_to_file, PackageOptions};

/// Checks the constraint system for errors
/// Check a local package and all of its dependencies for errors
#[derive(Debug, Clone, Args)]
#[clap(visible_alias = "c")]
pub(crate) struct CheckCommand {
Expand All @@ -34,7 +34,7 @@ pub(crate) struct CheckCommand {
#[clap(flatten)]
compile_options: CompileOptions,

/// Just show the hash of each paackages, without actually performing the check.
/// Just show the hash of each packages, without actually performing the check.
#[clap(long, hide = true)]
show_program_hash: bool,
}
Expand Down Expand Up @@ -66,16 +66,13 @@ pub(crate) fn run(args: CheckCommand, config: NargoConfig) -> Result<(), CliErro
continue;
}

let any_file_written = check_package(
check_package(
&workspace_file_manager,
&parsed_files,
package,
&args.compile_options,
args.allow_overwrite,
)?;
if any_file_written {
println!("[{}] Constraint system successfully built!", package.name);
}
}
Ok(())
}
Expand All @@ -88,13 +85,13 @@ fn check_package(
package: &Package,
compile_options: &CompileOptions,
allow_overwrite: bool,
) -> Result<bool, CompileError> {
) -> Result<(), CompileError> {
let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package);
check_crate_and_report_errors(&mut context, crate_id, compile_options)?;

if package.is_library() || package.is_contract() {
// Libraries do not have ABIs while contracts have many, so we cannot generate a `Prover.toml` file.
Ok(false)
Ok(())
} else {
// XXX: We can have a --overwrite flag to determine if you want to overwrite the Prover/Verifier.toml files
if let Some((parameters, _)) = compute_function_abi(&context, &crate_id) {
Expand All @@ -110,9 +107,7 @@ fn check_package(
eprintln!("Note: Prover.toml already exists. Use --overwrite to force overwrite.");
}

let any_file_written = should_write_prover;

Ok(any_file_written)
Ok(())
} else {
Err(CompileError::MissingMainFunction(package.name.clone()))
}
Expand Down
4 changes: 1 addition & 3 deletions tooling/nargo_cli/tests/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ fn hello_world_example() {
// `nargo check`
let mut cmd = Command::cargo_bin("nargo").unwrap();
cmd.arg("check");
cmd.assert()
.success()
.stdout(predicate::str::contains("Constraint system successfully built!"));
cmd.assert().success().stdout(predicate::str::is_empty());

project_dir.child("Prover.toml").assert(predicate::path::is_file());

Expand Down