git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Aug 21, 2009, 09:28 UTC
Message-ID
<4A8E68AF.8040001@viscovery.net>
From: Johannes Sixt <j6t@kdbg.org>

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.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 t/Makefile                |    1 +
 t/check_unique_numbers.sh |   27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100755 t/check_unique_numbers.sh
diff --git a/t/Makefile b/t/Makefile
index bd09390..2a451b7 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -17,6 +17,7 @@ T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
 TSVN = $(wildcard t91[0-9][0-9]-*.sh)

 all: pre-clean
+	'$(SHELL_PATH_SQ)' ./check_unique_numbers.sh
 	$(MAKE) aggregate-results-and-cleanup

 $(T):
diff --git a/t/check_unique_numbers.sh b/t/check_unique_numbers.sh
new file mode 100755
index 0000000..e767275
--- /dev/null
+++ 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
-- 
1.6.4.204.g6aad7
Next: Jeff King
Message 1 of 4 in “test suite: add a check that all test numbers are unique”
  1. test suite: add a check that all test numbers are uniqueJohannes Sixt, Aug 21, 2009
  2. Jeff KingAug 21, 2009
  3. test suite: add a check that all test numbers are uniqueJohannes Sixt, Aug 21, 2009
  4. Jeff KingAug 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.