Skip to content

Commit

Permalink
Re-shape file_manager_and_file_from to build_workspace_file_manager
Browse files Browse the repository at this point in the history
now it only returns a FileManager
  • Loading branch information
anaPerezGhiglia committed Aug 9, 2024
1 parent 2dbda88 commit 4364c48
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
11 changes: 2 additions & 9 deletions tooling/nargo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,10 @@ pub fn prepare_dependencies(
}
}

// TODO: find a better name
// Also, should we create a type that englobe fileManager + parsed_files?
// functions that need file_manager needs parsed_files as well
pub fn file_manager_and_files_from(
root: &Path,
workspace: &workspace::Workspace,
) -> (FileManager, ParsedFiles) {
pub fn build_workspace_file_manager(root: &Path, workspace: &workspace::Workspace) -> FileManager {
let mut workspace_file_manager = file_manager_with_stdlib(root);
insert_all_files_for_workspace_into_file_manager(workspace, &mut workspace_file_manager);
let parsed_files = parse_all(&workspace_file_manager);
(workspace_file_manager, parsed_files)
workspace_file_manager
}

pub fn insert_all_files_for_workspace_into_file_manager(
Expand Down
7 changes: 3 additions & 4 deletions tooling/nargo_cli/src/cli/dap_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use acvm::FieldElement;
use bn254_blackbox_solver::Bn254BlackBoxSolver;
use clap::Args;
use nargo::constants::PROVER_INPUT_FILE;
use nargo::file_manager_and_files_from;
use nargo::package::Package;
use nargo::workspace::Workspace;
use nargo::{build_workspace_file_manager, parse_all};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_abi::input_parser::Format;
use noirc_driver::{
Expand Down Expand Up @@ -157,9 +157,8 @@ fn load_and_compile_test_function(
package: &Package,
compile_options: &CompileOptions,
) -> Result<(CompiledProgram, Option<TestFunction>), LoadError> {
let (workspace_file_manager, mut parsed_files) =
file_manager_and_files_from(&workspace.root_dir, &workspace);

let workspace_file_manager = build_workspace_file_manager(&workspace.root_dir, &workspace);
let mut parsed_files = parse_all(&workspace_file_manager);
let test_functions = get_tests_in_package(
&workspace_file_manager,
&parsed_files,
Expand Down
10 changes: 5 additions & 5 deletions tooling/nargo_cli/src/cli/debug_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use nargo::ops::{
};
use nargo::package::Package;
use nargo::workspace::Workspace;
use nargo::{file_manager_and_files_from, prepare_package, NargoError};
use nargo::{build_workspace_file_manager, parse_all, prepare_package, NargoError};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};

use noirc_abi::input_parser::{Format, InputValue};
Expand Down Expand Up @@ -131,8 +131,8 @@ pub(crate) fn compile_bin_package_for_debugging(
package: &Package,
compile_options: &CompileOptions,
) -> Result<CompiledProgram, CompileError> {
let (workspace_file_manager, mut parsed_files) =
file_manager_and_files_from(std::path::Path::new(""), workspace);
let workspace_file_manager = build_workspace_file_manager(std::path::Path::new(""), workspace);
let mut parsed_files = parse_all(&workspace_file_manager);

let compilation_result = if compile_options.instrument_debug {
let debug_state =
Expand Down Expand Up @@ -195,8 +195,8 @@ fn debug_test(
execution_params: ExecutionParams,
expression_width: ExpressionWidth,
) -> Result<(), CliError> {
let (workspace_file_manager, mut parsed_files) =
file_manager_and_files_from(&workspace.root_dir, &workspace);
let workspace_file_manager = build_workspace_file_manager(&workspace.root_dir, &workspace);
let mut parsed_files = parse_all(&workspace_file_manager);
let (mut context, crate_id) =
prepare_package_for_debug(&workspace_file_manager, &mut parsed_files, package);

Expand Down
8 changes: 5 additions & 3 deletions tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use acvm::{BlackBoxFunctionSolver, FieldElement};
use bn254_blackbox_solver::Bn254BlackBoxSolver;
use clap::Args;
use fm::FileManager;
use nargo::{file_manager_and_files_from, ops::TestStatus, package::Package, prepare_package};
use nargo::{
build_workspace_file_manager, ops::TestStatus, package::Package, parse_all, prepare_package,
};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_driver::{check_crate, compile_no_check, CompileOptions, NOIR_ARTIFACT_VERSION_STRING};
use noirc_frontend::{
Expand Down Expand Up @@ -60,8 +62,8 @@ pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError
Some(NOIR_ARTIFACT_VERSION_STRING.to_string()),
)?;

let (workspace_file_manager, parsed_files) =
file_manager_and_files_from(&workspace.root_dir, &workspace);
let workspace_file_manager = build_workspace_file_manager(&workspace.root_dir, &workspace);
let parsed_files = parse_all(&workspace_file_manager);

let pattern = match &args.test_name {
Some(name) => {
Expand Down

0 comments on commit 4364c48

Please sign in to comment.