Re: [PATCH] test suite: add a check that all test numbers are unique

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 21, 2009 at 11:28:15AM +0200, Johannes Sixt wrote:

> The test runs only if 'make all' is used. Its purpose is to alert our
> valued integrator if different branches are merged that happen to
> introduce the same test number.

I think this is probably useful. In addition to the t7406 you posted a
patch for, it looks like t4037 has a duplicate in next.

As for the implementation:

> +++ b/t/check_unique_numbers.sh
> @@ -0,0 +1,27 @@
> +#!/bin/sh
> +
> +# checks whether test case numbers are unique;
> +# returns non-zero if any duplicates were found
> +
> +check_numbers () {
> +	last= dup=
> +	while read name
> +	do
> +		case $name in
> +		t[0-9][0-9][0-9][0-9]-*.sh)
> +			number=${name%%-*}
> +			if test "$number" = "$last"; then
> +				dup="$dup $number"
> +			fi
> +			last=$number
> +			;;
> +		esac
> +	done
> +	test -z "$dup" || {
> +		echo >&2 "error: duplicate test numbers:" $dup
> +		return 1
> +	}
> +}
> +
> +ls -1 |	# no wildcard to avoid overflow of command line
> +check_numbers

Why not the much shorter:

tests() {
  ls | sed -n 's/^\(t[0-9][0-9][0-9][0-9]\)-.*\.sh$/\1/p'
}
dups=`tests | uniq -d`

instead of the long shell loop?

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]