{"thread":{"id":"20683","subject":"[PATCH] test suite: add a check that all test numbers are unique","startedAt":"2009-08-21T09:28:15Z","lastAt":"2009-08-21T14:37:00Z","messageCount":4,"participants":["Johannes Sixt","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"121407","messageId":"4A8E68AF.8040001@viscovery.net","threadId":"20683","inReplyTo":null,"subject":"[PATCH] test suite: add a check that all test numbers are unique","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-08-21T09:28:15Z","receivedAt":"2009-08-21T09:28:15Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <j6t@kdbg.org>\n\nThe test runs only if 'make all' is used. Its purpose is to alert our\nvalued integrator if different branches are merged that happen to\nintroduce the same test number.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n t/Makefile                |    1 +\n t/check_unique_numbers.sh |   27 +++++++++++++++++++++++++++\n 2 files changed, 28 insertions(+), 0 deletions(-)\n create mode 100755 t/check_unique_numbers.sh\n\ndiff --git a/t/Makefile b/t/Makefile\nindex bd09390..2a451b7 100644\n--- a/t/Makefile\n+++ b/t/Makefile\n@@ -17,6 +17,7 @@ T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\n TSVN = $(wildcard t91[0-9][0-9]-*.sh)\n\n all: pre-clean\n+\t'$(SHELL_PATH_SQ)' ./check_unique_numbers.sh\n \t$(MAKE) aggregate-results-and-cleanup\n\n $(T):\ndiff --git a/t/check_unique_numbers.sh b/t/check_unique_numbers.sh\nnew file mode 100755\nindex 0000000..e767275\n--- /dev/null\n+++ b/t/check_unique_numbers.sh\n@@ -0,0 +1,27 @@\n+#!/bin/sh\n+\n+# checks whether test case numbers are unique;\n+# returns non-zero if any duplicates were found\n+\n+check_numbers () {\n+\tlast= dup=\n+\twhile read name\n+\tdo\n+\t\tcase $name in\n+\t\tt[0-9][0-9][0-9][0-9]-*.sh)\n+\t\t\tnumber=${name%%-*}\n+\t\t\tif test \"$number\" = \"$last\"; then\n+\t\t\t\tdup=\"$dup $number\"\n+\t\t\tfi\n+\t\t\tlast=$number\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+\ttest -z \"$dup\" || {\n+\t\techo >&2 \"error: duplicate test numbers:\" $dup\n+\t\treturn 1\n+\t}\n+}\n+\n+ls -1 |\t# no wildcard to avoid overflow of command line\n+check_numbers\n-- \n1.6.4.204.g6aad7\n"},{"id":"121413","messageId":"20090821125324.GA6280@coredump.intra.peff.net","threadId":"20683","inReplyTo":"4A8E68AF.8040001@viscovery.net","subject":"Re: [PATCH] test suite: add a check that all test numbers are unique","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-21T12:53:24Z","receivedAt":"2009-08-21T12:53:24Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 21, 2009 at 11:28:15AM +0200, Johannes Sixt wrote:\n\n> The test runs only if 'make all' is used. Its purpose is to alert our\n> valued integrator if different branches are merged that happen to\n> introduce the same test number.\n\nI think this is probably useful. In addition to the t7406 you posted a\npatch for, it looks like t4037 has a duplicate in next.\n\nAs for the implementation:\n\n> +++ b/t/check_unique_numbers.sh\n> @@ -0,0 +1,27 @@\n> +#!/bin/sh\n> +\n> +# checks whether test case numbers are unique;\n> +# returns non-zero if any duplicates were found\n> +\n> +check_numbers () {\n> +\tlast= dup=\n> +\twhile read name\n> +\tdo\n> +\t\tcase $name in\n> +\t\tt[0-9][0-9][0-9][0-9]-*.sh)\n> +\t\t\tnumber=${name%%-*}\n> +\t\t\tif test \"$number\" = \"$last\"; then\n> +\t\t\t\tdup=\"$dup $number\"\n> +\t\t\tfi\n> +\t\t\tlast=$number\n> +\t\t\t;;\n> +\t\tesac\n> +\tdone\n> +\ttest -z \"$dup\" || {\n> +\t\techo >&2 \"error: duplicate test numbers:\" $dup\n> +\t\treturn 1\n> +\t}\n> +}\n> +\n> +ls -1 |\t# no wildcard to avoid overflow of command line\n> +check_numbers\n\nWhy not the much shorter:\n\ntests() {\n  ls | sed -n 's/^\\(t[0-9][0-9][0-9][0-9]\\)-.*\\.sh$/\\1/p'\n}\ndups=`tests | uniq -d`\n\ninstead of the long shell loop?\n\n-Peff\n"},{"id":"121414","messageId":"4A8E9D73.1090604@viscovery.net","threadId":"20683","inReplyTo":"20090821125324.GA6280@coredump.intra.peff.net","subject":"[PATCH v2] test suite: add a check that all test numbers are unique","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-08-21T13:13:23Z","receivedAt":"2009-08-21T13:13:23Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Jeff King schrieb:\n> Why not the much shorter:\n> \n> tests() {\n>   ls | sed -n 's/^\\(t[0-9][0-9][0-9][0-9]\\)-.*\\.sh$/\\1/p'\n> }\n> dups=`tests | uniq -d`\n> \n> instead of the long shell loop?\n\nBecause it's faster on Windows ;-) No, seriously, I didn't know about\nuniq -d.\n\nHere is a replacement patch.\n\n--- 8< ---\nFrom: Johannes Sixt <j6t@kdbg.org>\nSubject: [PATCH] t/Makefile: add a check that all test numbers are unique\n\nThe test runs only if 'make all' is used. Its purpose is to alert our\nvalued integrator if different branches are merged that happen to\nintroduce the same test number.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n t/Makefile |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/t/Makefile b/t/Makefile\nindex bd09390..ed8281a 100644\n--- a/t/Makefile\n+++ b/t/Makefile\n@@ -17,6 +17,10 @@ T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\n TSVN = $(wildcard t91[0-9][0-9]-*.sh)\n\n all: pre-clean\n+\t@dups=`ls | sed -n 's/^\\(t[0-9][0-9][0-9][0-9]\\)-.*\\.sh$$/\\1/p' | \\\n+\t\t\tuniq -d` && \\\n+\t\ttest -z \"$$dups\" || { \\\n+\t\techo \"duplicate test numbers:\" $$dups; exit 1; }\n \t$(MAKE) aggregate-results-and-cleanup\n\n $(T):\n-- \n1.6.4.204.g6aad7\n"},{"id":"121433","messageId":"20090821143700.GA6850@coredump.intra.peff.net","threadId":"20683","inReplyTo":"4A8E9D73.1090604@viscovery.net","subject":"Re: [PATCH v2] test suite: add a check that all test numbers are unique","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-21T14:37:00Z","receivedAt":"2009-08-21T14:37:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 21, 2009 at 03:13:23PM +0200, Johannes Sixt wrote:\n\n> Because it's faster on Windows ;-) No, seriously, I didn't know about\n> uniq -d.\n\n:)\n\n> Here is a replacement patch.\n\nLooks good to me. Thanks.\n\n-Peff\n"}]}