Skip to content

Commit 9d7557f

Browse files
authored
feat(forge build): err if no source file in specified paths (#9329)
1 parent c526cab commit 9d7557f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: crates/forge/bin/cmd/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ impl BuildArgs {
9494
let path = if joined.exists() { &joined } else { path };
9595
files.extend(source_files_iter(path, MultiCompilerLanguage::FILE_EXTENSIONS));
9696
}
97+
if files.is_empty() {
98+
eyre::bail!("No source files found in specified build paths.")
99+
}
97100
}
98101

99102
let format_json = shell::is_json();

Diff for: crates/forge/tests/cli/cmd.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -2829,7 +2829,7 @@ Compiler run successful!
28292829
"#]]);
28302830

28312831
// Expect compilation to be skipped as no files have changed
2832-
cmd.arg("build").assert_success().stdout_eq(str![[r#"
2832+
cmd.forge_fuse().arg("build").assert_success().stdout_eq(str![[r#"
28332833
No files changed, compilation skipped
28342834
28352835
"#]]);
@@ -2952,6 +2952,14 @@ Compiler run successful!
29522952
[SOLC_VERSION] [ELAPSED]
29532953
Compiler run successful!
29542954
2955+
"#]]);
2956+
2957+
// Fail if no source file found.
2958+
prj.clear();
2959+
cmd.forge_fuse();
2960+
cmd.args(["build", "test/Dummy.sol", "--force"]).assert_failure().stderr_eq(str![[r#"
2961+
Error: No source files found in specified build paths.
2962+
29552963
"#]]);
29562964
});
29572965

0 commit comments

Comments
 (0)