Skip to content

Commit

Permalink
skip_oracle as a test option
Browse files Browse the repository at this point in the history
  • Loading branch information
guipublic committed Dec 4, 2024
1 parent 071b2a3 commit af3bc52
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 0 additions & 4 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ pub struct CompileOptions {
/// A lower value keeps the original program if it was smaller, even if it has more jumps.
#[arg(long, hide = true, allow_hyphen_values = true)]
pub max_bytecode_increase_percent: Option<i32>,

/// Flag to skip tests using oracles.
#[arg(long, hide = true)]
pub skip_oracle: bool,
}

pub fn parse_expression_width(input: &str) -> Result<ExpressionWidth, std::io::Error> {
Expand Down
1 change: 1 addition & 0 deletions tooling/lsp/src/requests/test_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fn on_test_run_request_inner(
None,
Some(workspace.root_dir.clone()),
Some(package.name.to_string()),
false,
&CompileOptions::default(),
);
let result = match test_result {
Expand Down
3 changes: 2 additions & 1 deletion tooling/nargo/src/ops/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub fn run_test<B: BlackBoxFunctionSolver<FieldElement>>(
foreign_call_resolver_url: Option<&str>,
root_path: Option<PathBuf>,
package_name: Option<String>,
skip_oracle: bool,
config: &CompileOptions,
) -> TestStatus {
let test_function_has_no_arguments = context
Expand All @@ -67,7 +68,7 @@ pub fn run_test<B: BlackBoxFunctionSolver<FieldElement>>(

match compile_no_check(context, config, test_function.get_id(), None, false) {
Ok(compiled_program) => {
if config.skip_oracle {
if skip_oracle {
let mut has_oracle = false;
for brillig_function in &compiled_program.program.unconstrained_functions {
match brillig_function.get_oracle_status(ForeignCall::check_oracle_status) {
Expand Down
10 changes: 9 additions & 1 deletion tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ pub(crate) struct TestCommand {
/// JSON RPC url to solve oracle calls
#[clap(long)]
oracle_resolver: Option<String>,

/// Flag to skip tests using oracles.
#[arg(long, hide = true)]
skip_oracle: bool,
}

pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError> {
Expand Down Expand Up @@ -76,7 +80,6 @@ pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError
}
None => FunctionNameMatch::Anything,
};

// Configure a thread pool with a larger stack size to prevent overflowing stack in large programs.
// Default is 2MB.
let pool = rayon::ThreadPoolBuilder::new().stack_size(4 * 1024 * 1024).build().unwrap();
Expand All @@ -94,6 +97,7 @@ pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError
args.oracle_resolver.as_deref(),
Some(workspace.root_dir.clone()),
Some(package.name.to_string()),
args.skip_oracle,
&args.compile_options,
)
})
Expand Down Expand Up @@ -133,6 +137,7 @@ fn run_tests<S: BlackBoxFunctionSolver<FieldElement> + Default>(
foreign_call_resolver_url: Option<&str>,
root_path: Option<PathBuf>,
package_name: Option<String>,
skip_oracle: bool,
compile_options: &CompileOptions,
) -> Result<Vec<(String, TestStatus)>, CliError> {
let test_functions =
Expand All @@ -155,6 +160,7 @@ fn run_tests<S: BlackBoxFunctionSolver<FieldElement> + Default>(
foreign_call_resolver_url,
root_path.clone(),
package_name.clone(),
skip_oracle,
compile_options,
);

Expand All @@ -176,6 +182,7 @@ fn run_test<S: BlackBoxFunctionSolver<FieldElement> + Default>(
foreign_call_resolver_url: Option<&str>,
root_path: Option<PathBuf>,
package_name: Option<String>,
skip_oracle: bool,
compile_options: &CompileOptions,
) -> TestStatus {
// This is really hacky but we can't share `Context` or `S` across threads.
Expand All @@ -199,6 +206,7 @@ fn run_test<S: BlackBoxFunctionSolver<FieldElement> + Default>(
foreign_call_resolver_url,
root_path,
package_name,
skip_oracle,
compile_options,
)
}
Expand Down

0 comments on commit af3bc52

Please sign in to comment.