Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ksew1 committed Oct 18, 2024
1 parent 3366a07 commit 8f9063c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions crates/forge-runner/src/coverage_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ pub fn run_coverage(saved_trace_data_paths: &[PathBuf], coverage_args: &[OsStrin
}
);

let dir_to_save_coverage = PathBuf::from(COVERAGE_DIR);
fs::create_dir_all(&dir_to_save_coverage).context("Failed to create a coverage dir")?;
let path_to_save_coverage = dir_to_save_coverage.join(OUTPUT_FILE_NAME);

let trace_files: Vec<&str> = saved_trace_data_paths
.iter()
.map(|trace_data_path| {
Expand All @@ -51,6 +47,10 @@ pub fn run_coverage(saved_trace_data_paths: &[PathBuf], coverage_args: &[OsStrin
let mut command = Command::new(coverage);

if coverage_args.iter().all(|arg| arg != "--output-path") {
let dir_to_save_coverage = PathBuf::from(COVERAGE_DIR);
fs::create_dir_all(&dir_to_save_coverage).context("Failed to create a coverage dir")?;
let path_to_save_coverage = dir_to_save_coverage.join(OUTPUT_FILE_NAME);

command.arg("--output-path").arg(&path_to_save_coverage);
}

Expand Down
7 changes: 4 additions & 3 deletions crates/forge-runner/src/profiler_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ pub fn run_profiler(
.map(PathBuf::from)
.ok()
.unwrap_or_else(|| PathBuf::from("cairo-profiler"));
let dir_to_save_profile = PathBuf::from(PROFILE_DIR);
fs::create_dir_all(&dir_to_save_profile).context("Failed to create a profile dir")?;
let path_to_save_profile = dir_to_save_profile.join(format!("{test_name}.pb.gz"));

let mut command = Command::new(profiler);

if profiler_args.iter().all(|arg| arg != "--output-path") {
let dir_to_save_profile = PathBuf::from(PROFILE_DIR);
fs::create_dir_all(&dir_to_save_profile).context("Failed to create a profile dir")?;
let path_to_save_profile = dir_to_save_profile.join(format!("{test_name}.pb.gz"));

command.arg("--output-path").arg(&path_to_save_profile);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/e2e/build_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn simple_package_build_profile() {
}

#[test]
fn simple_package_build_profile_pass_flags() {
fn simple_package_build_profile_and_pass_args() {
let temp = setup_package("simple_package");

test_runner(&temp)
Expand Down
6 changes: 3 additions & 3 deletions crates/forge/tests/e2e/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ fn test_coverage_project() {

#[test]
#[cfg_attr(not(feature = "scarb_2_8_3"), ignore)]
fn test_coverage_project_with_pass_flags() {
fn test_coverage_project_and_pass_args() {
let temp = setup_package("coverage_project");

test_runner(&temp)
.arg("--coverage")
.arg("--output-path")
.arg(".")
.arg("./my_file.lcov")
.assert()
.success();

assert!(temp.join(OUTPUT_FILE_NAME).is_file());
assert!(temp.join("my_file.lcov").is_file());
}

#[test]
Expand Down

0 comments on commit 8f9063c

Please sign in to comment.