Skip to content

Commit

Permalink
feat(forge build): err if no source file in specified paths
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed Nov 15, 2024
1 parent 36cbce7 commit e90abe0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/forge/bin/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ impl BuildArgs {
let path = if joined.exists() { &joined } else { path };
files.extend(source_files_iter(path, MultiCompilerLanguage::FILE_EXTENSIONS));
}
if files.is_empty() {
eyre::bail!("No source files found in specified build paths.")
}
}

let format_json = shell::is_json();
Expand Down
10 changes: 9 additions & 1 deletion crates/forge/tests/cli/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2829,7 +2829,7 @@ Compiler run successful!
"#]]);

// Expect compilation to be skipped as no files have changed
cmd.arg("build").assert_success().stdout_eq(str![[r#"
cmd.forge_fuse().arg("build").assert_success().stdout_eq(str![[r#"
No files changed, compilation skipped
"#]]);
Expand Down Expand Up @@ -2952,6 +2952,14 @@ Compiler run successful!
[SOLC_VERSION] [ELAPSED]
Compiler run successful!
"#]]);

// Fail if no source file found.
prj.clear();
cmd.forge_fuse();
cmd.args(["build", "test/Dummy.sol", "--force"]).assert_failure().stderr_eq(str![[r#"
Error: No source files found in specified build paths.
"#]]);
});

Expand Down

0 comments on commit e90abe0

Please sign in to comment.