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