This commit is contained in:
2024-12-25 21:53:50 +01:00
parent 958daaa697
commit 53f8b9ff96

View File

@@ -15,6 +15,8 @@ mut:
tests map[string]i64 // Map of test paths to last successful run timestamp tests map[string]i64 // Map of test paths to last successful run timestamp
} }
// Load the test cache from JSON file // Load the test cache from JSON file
fn load_test_cache() TestCache { fn load_test_cache() TestCache {
if !os.exists(cache_file) { if !os.exists(cache_file) {
@@ -146,6 +148,26 @@ fn dotest(path string, base_dir string, mut cache TestCache)! {
///////////////////////// /////////////////////////
///////////////////////// /////////////////////////
// Parse command line flags
mut fp := flag.new_flag_parser(os.args)
fp.application('test_basic')
fp.description('Run tests for herolib')
remove_cache := fp.bool('r', `r`, false, 'Remove cache file before running tests', flag.FlagConfig{})
fp.finalize() or {
eprintln(err)
exit(1)
}
// Remove cache file if -r flag is set
if remove_cache && os.exists(cache_file) {
os.rm(cache_file) or {
eprintln('Failed to remove cache file: ${err}')
exit(1)
}
println('Removed cache file: ${cache_file}')
}
abs_dir_of_script := dir(@FILE) abs_dir_of_script := dir(@FILE)
norm_dir_of_script := normalize_path(abs_dir_of_script) norm_dir_of_script := normalize_path(abs_dir_of_script)