{"thread":{"id":"49588","subject":"[PATCH] test-tool: show tool list on error","startedAt":"2018-10-17T09:25:10Z","lastAt":"2018-10-17T13:02:56Z","messageCount":2,"participants":["Jeff King","Derrick Stolee"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"360735","messageId":"20181017092506.GA15503@sigill.intra.peff.net","threadId":"49588","inReplyTo":null,"subject":"[PATCH] test-tool: show tool list on error","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-10-17T09:25:07Z","receivedAt":"2018-10-17T09:25:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Before we switched to one big test-tool binary, if you\nforgot the name of a tool, you could use tab-completion in\nthe shell to get a hint. But these days, all you get is:\n\n  $ t/helper/test-tool approxidate\n  fatal: There is no test named 'approxidate'\n\nand you're stuck reading the source code to find it. Let's\nprint a list of the available tools in this case.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nNot really user-facing, but this bugged me enough earlier to write the\npatch. ;)\n\nSome of the individual tools have nice help, too (try\n\"t/helper/test-tool date\", which shows the approxidate command I was\nlooking for), but some of them could probably stand to improve their\nfriendliness (try \"t/helper/test-tool config\"). I think it's fine for\npeople to improve them over time if and when they get annoyed.\n\n t/helper/test-tool.c | 15 +++++++++++++--\n 1 file changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/t/helper/test-tool.c b/t/helper/test-tool.c\nindex 6b5836dc1b..5df8b682aa 100644\n--- a/t/helper/test-tool.c\n+++ b/t/helper/test-tool.c\n@@ -55,13 +55,23 @@ static struct test_cmd cmds[] = {\n \t{ \"write-cache\", cmd__write_cache },\n };\n \n+static NORETURN void die_usage(void)\n+{\n+\tsize_t i;\n+\n+\tfprintf(stderr, \"usage: test-tool <toolname> [args]\\n\");\n+\tfor (i = 0; i < ARRAY_SIZE(cmds); i++)\n+\t\tfprintf(stderr, \"  %s\\n\", cmds[i].name);\n+\texit(128);\n+}\n+\n int cmd_main(int argc, const char **argv)\n {\n \tint i;\n \n \tBUG_exit_code = 99;\n \tif (argc < 2)\n-\t\tdie(\"I need a test name!\");\n+\t\tdie_usage();\n \n \tfor (i = 0; i < ARRAY_SIZE(cmds); i++) {\n \t\tif (!strcmp(cmds[i].name, argv[1])) {\n@@ -70,5 +80,6 @@ int cmd_main(int argc, const char **argv)\n \t\t\treturn cmds[i].fn(argc, argv);\n \t\t}\n \t}\n-\tdie(\"There is no test named '%s'\", argv[1]);\n+\terror(\"there is no tool named '%s'\", argv[1]);\n+\tdie_usage();\n }\n-- \n2.19.1.790.g519f91cad4\n"},{"id":"360746","messageId":"b8791c01-05be-20aa-f4e9-40eaa547f1c8@gmail.com","threadId":"49588","inReplyTo":"20181017092506.GA15503@sigill.intra.peff.net","subject":"Re: [PATCH] test-tool: show tool list on error","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-10-17T13:02:51Z","receivedAt":"2018-10-17T13:02:56Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 10/17/2018 5:25 AM, Jeff King wrote:\n> Before we switched to one big test-tool binary, if you\n> forgot the name of a tool, you could use tab-completion in\n> the shell to get a hint. But these days, all you get is:\n>\n>    $ t/helper/test-tool approxidate\n>    fatal: There is no test named 'approxidate'\n>\n> and you're stuck reading the source code to find it. Let's\n> print a list of the available tools in this case.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> Not really user-facing, but this bugged me enough earlier to write the\n> patch. ;)\n>\n> Some of the individual tools have nice help, too (try\n> \"t/helper/test-tool date\", which shows the approxidate command I was\n> looking for), but some of them could probably stand to improve their\n> friendliness (try \"t/helper/test-tool config\"). I think it's fine for\n> people to improve them over time if and when they get annoyed.\nThis will improve contributors' lives! Thanks.\n\nReviewed-by: Derrick Stolee <dstolee@microsoft.com>\n"}]}