Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(forge build): err if no source file in specified paths #9329

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading