t/helper: merge test-mktemp into test-tool
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 24 Mar 2018 07:44:47 +0000 (08:44 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Mar 2018 15:45:47 +0000 (08:45 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
t/helper/test-mktemp.c
t/helper/test-tool.c
t/helper/test-tool.h
t/t0070-fundamental.sh
index 67f37b849e9fd7e33234ded67777fcf903ecd465..3145a9b1b23af6a06a0f0bef4e497eaa3814ecf0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -667,13 +667,13 @@ TEST_BUILTINS_OBJS += test-index-version.o
 TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
 TEST_BUILTINS_OBJS += test-match-trees.o
 TEST_BUILTINS_OBJS += test-mergesort.o
+TEST_BUILTINS_OBJS += test-mktemp.o
 TEST_BUILTINS_OBJS += test-sha1.o
 
 TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
 TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
 TEST_PROGRAMS_NEED_X += test-fake-ssh
 TEST_PROGRAMS_NEED_X += test-line-buffer
-TEST_PROGRAMS_NEED_X += test-mktemp
 TEST_PROGRAMS_NEED_X += test-online-cpus
 TEST_PROGRAMS_NEED_X += test-parse-options
 TEST_PROGRAMS_NEED_X += test-path-utils
index 89d9b2f7bee05ff5c9fde31ba6798651ccee2947..229068894029338c52f5d0b9828c442658be67e5 100644 (file)
@@ -1,9 +1,10 @@
 /*
  * test-mktemp.c: code to exercise the creation of temporary files
  */
+#include "test-tool.h"
 #include "git-compat-util.h"
 
-int cmd_main(int argc, const char **argv)
+int cmd__mktemp(int argc, const char **argv)
 {
        if (argc != 2)
                usage("Expected 1 parameter defining the temporary file template");
index 5d470158b1466ea21c803212d18843bf521cc2e6..421634aeaa6177045dbf1cf3bf7a8af2dc13949e 100644 (file)
@@ -22,6 +22,7 @@ static struct test_cmd cmds[] = {
        { "lazy-init-name-hash", cmd__lazy_init_name_hash },
        { "match-trees", cmd__match_trees },
        { "mergesort", cmd__mergesort },
+       { "mktemp", cmd__mktemp },
        { "sha1", cmd__sha1 },
 };
 
index 6c9437ff5eaf28578cf0254e4e0dfbf295fb204d..cf2598798acb18416bd5cefd270dae55920638c2 100644 (file)
@@ -16,6 +16,7 @@ int cmd__index_version(int argc, const char **argv);
 int cmd__lazy_init_name_hash(int argc, const char **argv);
 int cmd__match_trees(int argc, const char **argv);
 int cmd__mergesort(int argc, const char **argv);
+int cmd__mktemp(int argc, const char **argv);
 int cmd__sha1(int argc, const char **argv);
 
 #endif
index 70d4d98a2e22659396c401ccc0deed1eadd7265a..ac007938ee9b0fc58266862c574fa9245a18d93e 100755 (executable)
@@ -13,7 +13,7 @@ test_expect_success 'character classes (isspace, isalpha etc.)' '
 '
 
 test_expect_success 'mktemp to nonexistent directory prints filename' '
-       test_must_fail test-mktemp doesnotexist/testXXXXXX 2>err &&
+       test_must_fail test-tool mktemp doesnotexist/testXXXXXX 2>err &&
        grep "doesnotexist/test" err
 '
 
@@ -21,7 +21,7 @@ test_expect_success POSIXPERM,SANITY 'mktemp to unwritable directory prints file
        mkdir cannotwrite &&
        chmod -w cannotwrite &&
        test_when_finished "chmod +w cannotwrite" &&
-       test_must_fail test-mktemp cannotwrite/testXXXXXX 2>err &&
+       test_must_fail test-tool mktemp cannotwrite/testXXXXXX 2>err &&
        grep "cannotwrite/test" err
 '