Fixed bug with upload
This commit is contained in:
@@ -637,3 +637,35 @@ fn test_readme_documents_self_contained_workflow() {
|
||||
"README should mention self-contained"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_scripts_tolerate_missing_toml_keys() {
|
||||
// Regression: toml_get must not kill the script when a key is absent.
|
||||
// With set -euo pipefail, bare grep returns exit 1 on no match,
|
||||
// pipefail propagates it, and set -e terminates silently.
|
||||
// Every grep in toml_get/toml_array must have "|| true".
|
||||
let tmp = TempDir::new().unwrap();
|
||||
let ctx = TemplateContext {
|
||||
project_name: "grep_safe".to_string(),
|
||||
anvil_version: "1.0.0".to_string(),
|
||||
};
|
||||
|
||||
TemplateManager::extract("basic", tmp.path(), &ctx).unwrap();
|
||||
|
||||
for script in &["build.sh", "upload.sh", "monitor.sh"] {
|
||||
let content = fs::read_to_string(tmp.path().join(script)).unwrap();
|
||||
|
||||
// If the script uses set -e (or -euo pipefail), then every
|
||||
// toml_get/toml_array function must guard grep with || true
|
||||
if content.contains("set -e") || content.contains("set -euo") {
|
||||
// Find the toml_get function body and check for || true
|
||||
let has_safe_grep = content.contains("|| true");
|
||||
assert!(
|
||||
has_safe_grep,
|
||||
"{} uses set -e but toml_get/toml_array lacks '|| true' guard. \
|
||||
Missing TOML keys will silently kill the script.",
|
||||
script
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user