<'
extend global {
dump_results_csv ( result_file_name:string=NULL ) is {
if result_file_name == NULL { result_file_name = "results.csv"; };
var all_sessions := vm_manager.get_all_sessions();
var ctx : vm_context = vm_manager.create_context(all_sessions.as_a(list of vm_attribute_container), "Default");
var all_runs := ctx.get_runs();
var result_file := files.open(result_file_name,"w","Text file");
files.write(result_file,"Test, Seed, Status, First Failure");
var attr_seed := vm_manager.get_attribute_by_name("sv_seed");
var attr_title := vm_manager.get_attribute_by_name("test_name");
for each (run) in all_runs {
var line :string;
line = append(run.get_attribute_value_or_default(attr_title), ", ");
line = append(line, run.get_attribute_value_or_default(attr_seed), ", ");
line = append(line, run.get_status(), ", ");
if (run.get_status_enum() == failed) {
var first_failure := run.get_first_failure();
line = append(line, first_failure.get_value("description"));
} else {
line = append(line, "n/a");
};
files.write(result_file,line);
};
files.close(result_file);
};
};
'>