Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn execute(path_str: Option<&str>, fix: bool) -> ExitCode {
}
}

// Fix deprecation warnings
// If --fix is enabled, automatically modernize deprecated keywords and constructs
if fix {
let migrated = migrate_source(&content);
if migrated != content {
Expand Down
27 changes: 27 additions & 0 deletions cli/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,30 @@ fn test_cli_emit_commands() {
_ => panic!("Expected EmitLlvm subcommand"),
}
}

#[test]
fn test_cli_lint_fix() {
let args = vec!["tech", "lint", "src/main.txs", "--fix"];
let cli = Cli::try_parse_from(args).expect("args parse successfully");
match cli.command {
Commands::Lint { path, fix } => {
assert_eq!(path.as_deref(), Some("src/main.txs"));
assert!(fix);
}
_ => panic!("Expected Lint subcommand"),
}

// Verify actual lint execute with --fix on a temporary file with deprecated syntax
let temp_dir = std::env::temp_dir().join("techscript_lint_test");
let _ = std::fs::create_dir_all(&temp_dir);
let test_file = temp_dir.join("deprecated.txs");
std::fs::write(&test_file, "let x = 10;").expect("write test file");

let status = techscript_cli::commands::lint::execute(Some(test_file.to_str().unwrap()), true);
assert_eq!(status, techscript_cli::exit_code::ExitCode::Success);

let content = std::fs::read_to_string(&test_file).expect("read test file");
assert_eq!(content, "x = 10");

let _ = std::fs::remove_dir_all(&temp_dir);
}
Loading