Skip to content

Commit 7ee8b24

Browse files
authored
Merge pull request #209 from tenstorrent/manifest_checks
Manifest checks
2 parents 357ec68 + d5b4f8d commit 7ee8b24

File tree

8 files changed

+388
-60
lines changed

8 files changed

+388
-60
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
2626
- `packages`: Add `--targets` flag to print targets used in the corresponding manifest.
2727
- Add `clean` command to clean all bender related dependencies.
2828
- `script`: Allow flist formats to use `only-sources`/`only-includes`/`only-defines` flags.
29+
- Add check to ensure files referenced in all manifests exist.
30+
- Add warnings for unknown fields in manifest.
2931

3032
### Changed
3133
- `update`: Clean up alignment of manual resolution output.

src/cli.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,11 @@ pub fn read_manifest(path: &Path) -> Result<Manifest> {
366366
.map_err(|cause| Error::chain(format!("Cannot open manifest {:?}.", path), cause))?;
367367
let partial: PartialManifest = serde_yaml::from_reader(file)
368368
.map_err(|cause| Error::chain(format!("Syntax error in manifest {:?}.", path), cause))?;
369-
let manifest = partial
370-
.validate()
371-
.map_err(|cause| Error::chain(format!("Error in manifest {:?}.", path), cause))?;
372-
manifest.prefix_paths(path.parent().unwrap())
369+
partial
370+
.prefix_paths(path.parent().unwrap())
371+
.map_err(|cause| Error::chain(format!("Error in manifest prefixing {:?}.", path), cause))?
372+
.validate("", false)
373+
.map_err(|cause| Error::chain(format!("Error in manifest {:?}.", path), cause))
373374
}
374375

375376
/// Load a configuration by traversing a directory hierarchy upwards.
@@ -446,7 +447,7 @@ fn load_config(from: &Path, warn_config_loaded: bool) -> Result<Config> {
446447

447448
// Validate the configuration.
448449
let mut out = out
449-
.validate()
450+
.validate("", false)
450451
.map_err(|cause| Error::chain("Invalid configuration:", cause))?;
451452

452453
out.overrides = out

src/cmd/clone.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ pub fn run(sess: &Session, path: &Path, matches: &ArgMatches) -> Result<()> {
9494
debugln!("main: checkouts {:#?}", checkouts);
9595
for c in checkouts {
9696
if let Some(s) = c.to_str() {
97+
if !Path::new(s).exists() {
98+
Err(Error::new(format!("`{dep}` path `{s}` does not exist")))?;
99+
}
97100
let command = SysCommand::new("cp")
98101
.arg("-rf")
99102
.arg(s)

src/cmd/script.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use indexmap::{IndexMap, IndexSet};
1313
use tera::{Context, Tera};
1414
use tokio::runtime::Runtime;
1515

16+
use crate::config::Validate;
1617
use crate::error::*;
1718
use crate::sess::{Session, SessionIo};
1819
use crate::src::{SourceFile, SourceGroup};
@@ -292,8 +293,12 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
292293
});
293294
}
294295

295-
// Flatten the sources.
296-
let srcs = srcs.flatten();
296+
// Flatten and validate the sources.
297+
let srcs = srcs
298+
.flatten()
299+
.into_iter()
300+
.map(|f| f.validate("", false))
301+
.collect::<Result<Vec<_>>>()?;
297302

298303
// Validate format-specific options.
299304
if (matches.contains_id("vcom-arg") || matches.contains_id("vlog-arg"))

0 commit comments

Comments
 (0)