mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	shtests: report total errors on terminal and in exit status
Setting the exit status allows build scripts and the like to actually detect regression test failures. src/cmd/ksh93/tests/shtests: - Add counter for total number of errors. - Report total to stdout at the end. - Set the exit status to the total number of errors, up to 125 (higher statuses have special meanings). (cherry picked from commit c0dd80b14d4d316b4e9eff4b1b67d4e47f23a6ba)
This commit is contained in:
		
							parent
							
								
									fb652a7e50
								
							
						
					
					
						commit
						c2eabc57e0
					
				
					 1 changed files with 10 additions and 4 deletions
				
			
		| 
						 | 
					@ -307,6 +307,7 @@ then	if	[[ -x $SHELL-g ]]
 | 
				
			||||||
	valgrind+=" --xml-file=$valxml"
 | 
						valgrind+=" --xml-file=$valxml"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
typeset -A tests
 | 
					typeset -A tests
 | 
				
			||||||
 | 
					typeset -i total_e=0
 | 
				
			||||||
for i in ${*-*.sh}
 | 
					for i in ${*-*.sh}
 | 
				
			||||||
do	[[ $i == *.sh ]] || i+='.sh'
 | 
					do	[[ $i == *.sh ]] || i+='.sh'
 | 
				
			||||||
	if	[[ ! -r $i ]]
 | 
						if	[[ ! -r $i ]]
 | 
				
			||||||
| 
						 | 
					@ -345,11 +346,12 @@ do	[[ $i == *.sh ]] || i+='.sh'
 | 
				
			||||||
			then	valxml $valxml
 | 
								then	valxml $valxml
 | 
				
			||||||
				(( e += $? ))
 | 
									(( e += $? ))
 | 
				
			||||||
			fi
 | 
								fi
 | 
				
			||||||
			if	(( e > 256 ))
 | 
								if	(( e > 256 && ++total_e ))
 | 
				
			||||||
			then	E="(killed by SIG$(kill -l "$e"))"
 | 
								then	E="(killed by SIG$(kill -l "$e"))"
 | 
				
			||||||
			elif	(( e == 1 ))
 | 
								elif	(( e == 1 && ++total_e ))
 | 
				
			||||||
			then	E="1 error"
 | 
								then	E="1 error"
 | 
				
			||||||
			else	E="$e errors"
 | 
								else	E="$e errors"
 | 
				
			||||||
 | 
									(( total_e += e ))
 | 
				
			||||||
			fi
 | 
								fi
 | 
				
			||||||
			if	(( e == 0 ))
 | 
								if	(( e == 0 ))
 | 
				
			||||||
			then	echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T $E ]"
 | 
								then	echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T $E ]"
 | 
				
			||||||
| 
						 | 
					@ -365,15 +367,17 @@ do	[[ $i == *.sh ]] || i+='.sh'
 | 
				
			||||||
		then	if	$valgrind $SHELL $trace $c
 | 
							then	if	$valgrind $SHELL $trace $c
 | 
				
			||||||
			then	echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 errors ]"
 | 
								then	echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 errors ]"
 | 
				
			||||||
			else	e=$?
 | 
								else	e=$?
 | 
				
			||||||
				if	(( e > 256 ))
 | 
									if	(( e > 256 && ++total_e ))
 | 
				
			||||||
				then	E="(killed by SIG$(kill -l "$e"))"
 | 
									then	E="(killed by SIG$(kill -l "$e"))"
 | 
				
			||||||
				elif	(( e == 1 ))
 | 
									elif	(( e == 1 && ++total_e ))
 | 
				
			||||||
				then	E="1 error"
 | 
									then	E="1 error"
 | 
				
			||||||
				else	E="$e errors"
 | 
									else	E="$e errors"
 | 
				
			||||||
 | 
										(( total_e += e ))
 | 
				
			||||||
				fi
 | 
									fi
 | 
				
			||||||
				echo test $o failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $E ]"
 | 
									echo test $o failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $E ]"
 | 
				
			||||||
			fi
 | 
								fi
 | 
				
			||||||
		else	e=$?
 | 
							else	e=$?
 | 
				
			||||||
 | 
								(( ++total_e ))
 | 
				
			||||||
			echo test $o failed to compile ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ 1 test 1 error ]"
 | 
								echo test $o failed to compile ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ 1 test 1 error ]"
 | 
				
			||||||
		fi
 | 
							fi
 | 
				
			||||||
		if	[[ $i == $timesensitive ]]
 | 
							if	[[ $i == $timesensitive ]]
 | 
				
			||||||
| 
						 | 
					@ -381,3 +385,5 @@ do	[[ $i == *.sh ]] || i+='.sh'
 | 
				
			||||||
		fi
 | 
							fi
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 | 
					print "Total errors: $total_e"
 | 
				
			||||||
 | 
					exit $((total_e > 125 ? 125 : total_e))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue