Skip to content

Commit 458169d

Browse files
committed
feat: Include manifest file name into error output
Before: $ ../../target/debug/spin build Error: expected a comma, found an identifier at line 9 column 28 After: $ ../../target/debug/spin build Error: Cannot read manifest file from "spin.toml" Caused by: expected a comma, found an identifier at line 9 column 28 Refs: #769 Signed-off-by: Konstantin Shabanov <mail@etehtsea.me>
1 parent 1ce374a commit 458169d

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

crates/loader/src/local/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ pub async fn raw_manifest_from_file(app: &impl AsRef<Path>) -> Result<RawAppMani
6363
.await
6464
.with_context(|| anyhow!("Cannot read manifest file from {:?}", app.as_ref()))?;
6565

66-
let manifest: RawAppManifestAnyVersion = toml::from_slice(&buf)?;
66+
let manifest: RawAppManifestAnyVersion = toml::from_slice(&buf)
67+
.with_context(|| anyhow!("Cannot read manifest file from {:?}", app.as_ref()))?;
68+
6769
Ok(manifest)
6870
}
6971

crates/loader/src/local/tests.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ fn test_manifest() -> Result<()> {
9999
Ok(())
100100
}
101101

102+
#[tokio::test]
103+
async fn test_invalid_manifest() -> Result<()> {
104+
const MANIFEST: &str = "tests/invalid-manifest.toml";
105+
106+
let temp_dir = tempfile::tempdir()?;
107+
let dir = temp_dir.path();
108+
let app = from_file(MANIFEST, dir, &None, false).await;
109+
110+
let e = app.unwrap_err().to_string();
111+
assert!(
112+
e.contains("invalid-manifest.toml"),
113+
"Expected error to contain the manifest name"
114+
);
115+
116+
Ok(())
117+
}
118+
102119
#[test]
103120
fn test_unknown_version_is_rejected() {
104121
const MANIFEST: &str = include_str!("../../tests/invalid-version.toml");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spin_version = "1"
2+
authors = ["Gul Madred", "Edward Jellico", "JL"]
3+
description = "A simple application that returns the number of lights"
4+
name = "chain-of-command"
5+
trigger = {type = "http", base = "/"}
6+
ver

0 commit comments

Comments
 (0)