cmd line file return exit code
This commit is contained in:
parent
e25ed6fb8f
commit
7fba8a57ea
|
|
@ -130,9 +130,11 @@ staTclAppInit(int argc,
|
|||
if (argc == 2) {
|
||||
char *cmd_file = argv[1];
|
||||
if (cmd_file) {
|
||||
sourceTclFile(cmd_file, false, false, interp);
|
||||
if (exit_after_cmd_file)
|
||||
exit(EXIT_SUCCESS);
|
||||
int result = sourceTclFile(cmd_file, false, false, interp);
|
||||
if (exit_after_cmd_file) {
|
||||
int exit_code = (result == TCL_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
exit(exit_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ findCmdLineKey(int &argc,
|
|||
}
|
||||
|
||||
// Use overridden version of source to echo cmds and results.
|
||||
void
|
||||
int
|
||||
sourceTclFile(const char *filename,
|
||||
bool echo,
|
||||
bool verbose,
|
||||
|
|
@ -93,7 +93,11 @@ sourceTclFile(const char *filename,
|
|||
echo ? "-echo " : "",
|
||||
verbose ? "-verbose " : "",
|
||||
filename);
|
||||
Tcl_Eval(interp, cmd.c_str());
|
||||
int code = Tcl_Eval(interp, cmd.c_str());
|
||||
const char *result = Tcl_GetStringResult(interp);
|
||||
if (result[0] != '\0')
|
||||
printf("%s\n", result);
|
||||
return code;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ findCmdLineKey(int &argc,
|
|||
int
|
||||
parseThreadsArg(int &argc,
|
||||
char *argv[]);
|
||||
void
|
||||
int
|
||||
sourceTclFile(const char *filename,
|
||||
bool echo,
|
||||
bool verbose,
|
||||
|
|
|
|||
32
tcl/Sdc.tcl
32
tcl/Sdc.tcl
|
|
@ -71,7 +71,7 @@ proc source_ { filename echo verbose } {
|
|||
set sdc_file $filename
|
||||
set sdc_line 1
|
||||
set cmd ""
|
||||
set errors 0
|
||||
set error {}
|
||||
while {![eof $stream]} {
|
||||
gets $stream line
|
||||
if { $line != "" } {
|
||||
|
|
@ -84,6 +84,8 @@ proc source_ { filename echo verbose } {
|
|||
&& [info complete $cmd] } {
|
||||
set error {}
|
||||
set error_code [catch {uplevel \#0 $cmd} result]
|
||||
# cmd consumed
|
||||
set cmd ""
|
||||
# Flush results printed outside tcl to stdout/stderr.
|
||||
fflush
|
||||
switch $error_code {
|
||||
|
|
@ -93,15 +95,16 @@ proc source_ { filename echo verbose } {
|
|||
3 { set error {invoked "break" outside of a loop.} }
|
||||
4 { set error {invoked "continue" outside of a loop.} }
|
||||
}
|
||||
set cmd ""
|
||||
if { $error != {} } {
|
||||
if { [string first "Error" $error] == 0 } {
|
||||
puts $error
|
||||
} else {
|
||||
puts "Error: [file tail $sdc_file], $sdc_line $error"
|
||||
}
|
||||
set errors 1
|
||||
if { !$sta_continue_on_error } {
|
||||
if { $sta_continue_on_error } {
|
||||
# Only prepend error message with file/line once.
|
||||
if { [string first "Error" $error] == 0 } {
|
||||
puts $error
|
||||
} else {
|
||||
puts "Error: [file tail $sdc_file], $sdc_line $error"
|
||||
}
|
||||
set error {}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -112,6 +115,8 @@ proc source_ { filename echo verbose } {
|
|||
if { $cmd != {} } {
|
||||
sta_error "incomplete command at end of file."
|
||||
}
|
||||
set error_sdc_file $sdc_file
|
||||
set error_sdc_line $sdc_line
|
||||
if { [info exists sdc_file_save] } {
|
||||
set sdc_file $sdc_file_save
|
||||
set sdc_line $sdc_line_save
|
||||
|
|
@ -119,7 +124,14 @@ proc source_ { filename echo verbose } {
|
|||
unset sdc_file
|
||||
unset sdc_line
|
||||
}
|
||||
return $errors
|
||||
if { $error != {} } {
|
||||
# Only prepend error message with file/line once.
|
||||
if { [string first "Error" $error] == 0 } {
|
||||
error $error
|
||||
} else {
|
||||
error "Error: [file tail $error_sdc_file], $error_sdc_line $error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ proc run_test_app { test cmd_file log_file } {
|
|||
proc run_test_plain { test cmd_file log_file } {
|
||||
global app_path app_options result_dir errorCode
|
||||
global report_stats
|
||||
global test_expect_eror
|
||||
|
||||
if { ![file exists $app_path] } {
|
||||
return "ERROR $app_path not found."
|
||||
|
|
@ -266,7 +267,8 @@ proc run_test_plain { test cmd_file log_file } {
|
|||
}
|
||||
close $run_stream
|
||||
|
||||
if { [catch [concat exec $app_path $app_options $run_file >& $log_file]] } {
|
||||
if { [catch [concat exec $app_path $app_options $run_file >& $log_file]] \
|
||||
&& ![info exists test_expect_eror($test)] } {
|
||||
set signal [lindex $errorCode 2]
|
||||
set error [lindex $errorCode 3]
|
||||
# Error strings are not consistent across platforms but signal
|
||||
|
|
|
|||
Loading…
Reference in New Issue