Files
honey-biscuit-workshop/workshop-baker/tests/bake_pipeline_integration.rs
T
Catty Steve 8fd807f174 refactor!: extract execution engine into standalone workshop-engine
crate

BREAKING CHANGE: Moved engine/ module (cgroups, executor, pm, upm,
types) and shared types (command, repology, time) from workshop-baker to
new workshop-engine crate. All internal error types consolidated into
workshop-engine::error. Import paths changed throughout codebase.
2026-04-26 23:07:08 +08:00

85 lines
2.2 KiB
Rust

use workshop_baker::bake::parser::parse_script;
#[test]
fn test_full_pipeline_parse() {
let script = r#"
# @pipeline
func1() { echo 1; }
# @pipeline
func2() { echo 2; }
"#;
let parsed = parse_script(script).unwrap();
assert_eq!(parsed.pipeline_functions.len(), 2);
assert_eq!(parsed.pipeline_functions[0].name, "func1");
assert_eq!(parsed.pipeline_functions[1].name, "func2");
}
#[test]
fn test_pipeline_with_after_decorator() {
let script = r#"
# @pipeline
build() { echo building; }
# @pipeline
# @after(build)
test() { echo testing; }
"#;
let parsed = parse_script(script).unwrap();
assert_eq!(parsed.pipeline_functions.len(), 2);
assert_eq!(parsed.pipeline_functions[0].name, "build");
assert_eq!(parsed.pipeline_functions[1].name, "test");
assert_eq!(parsed.pipeline_functions[1].decorators.len(), 2);
}
#[test]
fn test_pipeline_with_mixed_decorators() {
let script = r#"
# @pipeline
# @timeout(60)
step1() { echo step1; }
# @pipeline
# @retry(3, 10)
# @after(step1)
step2() { echo step2; }
"#;
let parsed = parse_script(script).unwrap();
assert_eq!(parsed.pipeline_functions.len(), 2);
assert_eq!(parsed.pipeline_functions[0].name, "step1");
assert_eq!(parsed.pipeline_functions[1].name, "step2");
assert_eq!(parsed.pipeline_functions[0].decorators.len(), 2);
assert_eq!(parsed.pipeline_functions[1].decorators.len(), 3);
}
#[test]
fn test_pipeline_remaining_code_excludes_pipeline_functions() {
let script = r#"#!/bin/bash
# comment
helper() { echo helper; }
# @pipeline
build() { echo build; }
"#;
let parsed = parse_script(script).unwrap();
assert_eq!(parsed.pipeline_functions.len(), 1);
assert_eq!(parsed.pipeline_functions[0].name, "build");
assert!(parsed.remaining_code.contains("helper"));
assert!(!parsed.remaining_code.contains("# @pipeline"));
}
#[test]
fn test_pipeline_multiline_function() {
let script = r#"
# @pipeline
deploy() {
echo "deploying"
echo "done"
}
"#;
let parsed = parse_script(script).unwrap();
assert_eq!(parsed.pipeline_functions.len(), 1);
assert_eq!(parsed.pipeline_functions[0].name, "deploy");
assert!(parsed.pipeline_functions[0].body.contains("deploying"));
}