Phase 6: Native Executables implementieren und Change archivieren
This commit is contained in:
@@ -329,3 +329,58 @@ fn designer_frm_is_accepted_by_the_standalone_cli_compiler() {
|
||||
tb_vm::project_io::load_program(&dir.join("designed.tbc")).unwrap();
|
||||
std::fs::remove_dir_all(dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_build_optionen_sind_explizit_und_tbc_bleibt_standard() {
|
||||
let dir = std::env::temp_dir().join(format!("tb-native-options-{}", std::process::id()));
|
||||
std::fs::create_dir(&dir).unwrap();
|
||||
struct Cleanup(std::path::PathBuf);
|
||||
impl Drop for Cleanup {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
let _cleanup = Cleanup(dir.clone());
|
||||
std::fs::write(dir.join("main.bas"), "PRINT 42\nEND\n").unwrap();
|
||||
assert!(tbc(&dir, "build", "main.bas").status.success());
|
||||
let original = std::fs::read(dir.join("main.tbc")).unwrap();
|
||||
assert_eq!(&original[..4], b"TBC\0");
|
||||
for (options, diagnostic) in [
|
||||
(vec!["--bogus"], "Unbekannte Build-Option"),
|
||||
(vec!["--exe", "--target"], "Wert fehlt"),
|
||||
(
|
||||
vec!["--exe", "--target", "x86_64-apple-darwin"],
|
||||
"Nicht unterstütztes Target",
|
||||
),
|
||||
(vec!["--exe", "--exe"], "Doppeltes --exe"),
|
||||
(vec!["--output", "program"], "benötigen --exe"),
|
||||
(
|
||||
vec!["--exe", "--template", "missing", "-o", "program"],
|
||||
"Runtime-Vorlage fehlt",
|
||||
),
|
||||
(
|
||||
vec![
|
||||
"--exe",
|
||||
"--target",
|
||||
"aarch64-apple-darwin",
|
||||
"--target",
|
||||
"aarch64-apple-darwin",
|
||||
],
|
||||
"Doppelte Option",
|
||||
),
|
||||
] {
|
||||
let out = std::process::Command::new(env!("CARGO_BIN_EXE_tbc"))
|
||||
.current_dir(&dir)
|
||||
.args(["build", "main.bas"])
|
||||
.args(options)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert_eq!(out.status.code(), Some(1), "{out:?}");
|
||||
assert!(
|
||||
String::from_utf8_lossy(&out.stderr).contains(diagnostic),
|
||||
"{out:?}"
|
||||
);
|
||||
assert_eq!(std::fs::read(dir.join("main.tbc")).unwrap(), original);
|
||||
assert!(!dir.join("program").exists());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user