-
Notifications
You must be signed in to change notification settings - Fork 1
Phase 22: Extended Codegen — DWARF Debug Info, LTO, PIC #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,3 +245,93 @@ fn test_evolve_with_testdata() { | |
| "stderr should contain best fitness" | ||
| ); | ||
| } | ||
|
|
||
| // --------------------------------------------------------------------------- | ||
| // Phase 22: --debug-info and --lto CLI flags | ||
| // --------------------------------------------------------------------------- | ||
|
|
||
| #[test] | ||
| fn build_with_debug_info() { | ||
| let out_path = std::env::temp_dir().join("flux_cli_test_dbg"); | ||
| let _ = std::fs::remove_file(&out_path); | ||
|
Comment on lines
+255
to
+256
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hallo! Für eine robustere Handhabung von temporären Dateien in Tests empfehle ich die Verwendung des Dies würde den Code vereinfachen und die manuelle Erstellung und Löschung von Dateipfaden überflüssig machen. Ein Beispiel, wie dieser Test mit use tempfile::NamedTempFile;
#[test]
fn build_with_debug_info() {
let out_file = NamedTempFile::new().expect("failed to create temp file");
let out_path = out_file.path();
let output = flux_cmd()
.args([
"build",
"testdata/hello_world.ftl",
"--debug-info",
"-o",
out_path.to_str().unwrap(),
])
.output()
.expect("failed to execute");
assert!(
output.status.success(),
"build --debug-info failed: {}",
String::from_utf8_lossy(&output.stderr)
);
assert!(out_path.exists(), "executable was not created with --debug-info");
// Run the built executable to verify it still works
let run_output = Command::new(&out_path)
.output()
.expect("failed to run built binary");
let stdout = String::from_utf8_lossy(&run_output.stdout);
assert_eq!(stdout, "Hello World\n");
// out_file und die zugehörige temporäre Datei werden hier automatisch entfernt.
}Diese Empfehlung gilt auch für den |
||
|
|
||
| let output = flux_cmd() | ||
| .args([ | ||
| "build", | ||
| "testdata/hello_world.ftl", | ||
| "--debug-info", | ||
| "-o", | ||
| out_path.to_str().unwrap(), | ||
| ]) | ||
| .output() | ||
| .expect("failed to execute"); | ||
|
|
||
| assert!( | ||
| output.status.success(), | ||
| "build --debug-info failed: {}", | ||
| String::from_utf8_lossy(&output.stderr) | ||
| ); | ||
| assert!(out_path.exists(), "executable was not created with --debug-info"); | ||
|
|
||
| // Run the built executable to verify it still works | ||
| let run_output = Command::new(&out_path) | ||
| .output() | ||
| .expect("failed to run built binary"); | ||
| let stdout = String::from_utf8_lossy(&run_output.stdout); | ||
| assert_eq!(stdout, "Hello World\n"); | ||
|
|
||
| let _ = std::fs::remove_file(&out_path); | ||
| } | ||
|
|
||
| #[test] | ||
| fn build_with_lto() { | ||
| let out_path = std::env::temp_dir().join("flux_cli_test_lto"); | ||
| let _ = std::fs::remove_file(&out_path); | ||
|
|
||
| let output = flux_cmd() | ||
| .args([ | ||
| "build", | ||
| "testdata/hello_world.ftl", | ||
| "--lto", | ||
| "-o", | ||
| out_path.to_str().unwrap(), | ||
| ]) | ||
| .output() | ||
| .expect("failed to execute"); | ||
|
|
||
| assert!( | ||
| output.status.success(), | ||
| "build --lto failed: {}", | ||
| String::from_utf8_lossy(&output.stderr) | ||
| ); | ||
| assert!(out_path.exists(), "executable was not created with --lto"); | ||
|
|
||
| // Run the built executable to verify it still works | ||
| let run_output = Command::new(&out_path) | ||
| .output() | ||
| .expect("failed to run built binary"); | ||
| let stdout = String::from_utf8_lossy(&run_output.stdout); | ||
| assert_eq!(stdout, "Hello World\n"); | ||
|
|
||
| let _ = std::fs::remove_file(&out_path); | ||
| } | ||
|
|
||
| #[test] | ||
| fn build_help_shows_debug_info_and_lto() { | ||
| let output = flux_cmd() | ||
| .args(["build", "--help"]) | ||
| .output() | ||
| .expect("failed to execute"); | ||
|
|
||
| assert!(output.status.success(), "build --help should succeed"); | ||
|
|
||
| let stdout = String::from_utf8_lossy(&output.stdout); | ||
| assert!( | ||
| stdout.contains("--debug-info"), | ||
| "help should mention --debug-info" | ||
| ); | ||
| assert!( | ||
| stdout.contains("--lto"), | ||
| "help should mention --lto" | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hallo! Um die Notwendigkeit von
#[allow(clippy::too_many_arguments)]zu vermeiden und die Wartbarkeit zu verbessern, könnten Sie die Argumente für denbuild-Befehl in einer eigenen Struktur zusammenfassen. Dies würde diecmd_build-Funktion übersichtlicher machen und die Kopplung reduzieren.Sie könnten eine
BuildArgs-Struktur definieren und diese imCommands::Build-Enum verwenden:Die
cmd_build-Funktion würde dann eine Referenz aufBuildArgsentgegennehmen:Und der Aufruf in
mainwürde entsprechend angepasst werden: