Re: [PATCH v4 0/4] Maintenance IV: Platform-specific background maintenance
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Nov 17, 2020, 23:36 UTC
- Message-ID
- <X7ReZXuwAaAZzMSU@flurp.local>
- In-Reply-To
- <pull.776.v4.git.1605647598.gitgitgadget@gmail.com>
On Tue, Nov 17, 2020 at 09:13:14PM +0000, Derrick Stolee via GitGitGadget wrote:
Show 8 quoted lines
> Updates in V4 > ============= > * Eric did an excellent job providing a patch that cleans up several parts > of my series. The most impressive is his mechanism for testing the > platform-specific Git logic in a way that is (mostly) platform-agnostic. > > * Windows doesn't have the 'id' command, so we cannot run the macOS > platform test on Windows.
This is easy to resolve. Drop in the following patch and then replace the `$(id -u)` invocation in the test with `$(test-tool getuid)`. This way, the test should work on any platform since both launchctl_get_uid() and `test-tool` will retrieve identical values for UID.
--- >8 --- From 84f623bcaec156082c0e7151f40aef18575e6f86 Mon Sep 17 00:00:00 2001 From: Eric Sunshine <sunshine@sunshineco.com> Date: Tue, 17 Nov 2020 18:30:10 -0500 Subject: [PATCH] test-helper: add `getuid` subcommand
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> --- Makefile | 1 + t/helper/test-getuid.c | 7 +++++++ t/helper/test-tool.c | 1 + t/helper/test-tool.h | 1 + 4 files changed, 10 insertions(+) create mode 100644 t/helper/test-getuid.c
diff --git a/Makefile b/Makefile index 790a883932..230aff5e5c 100644 --- a/Makefile +++ b/Makefile @@ -706,6 +706,7 @@ TEST_BUILTINS_OBJS += test-dump-untracked-cache.o TEST_BUILTINS_OBJS += test-example-decorate.o TEST_BUILTINS_OBJS += test-genrandom.o TEST_BUILTINS_OBJS += test-genzeros.o +TEST_BUILTINS_OBJS += test-getuid.o TEST_BUILTINS_OBJS += test-hash-speed.o TEST_BUILTINS_OBJS += test-hash.o TEST_BUILTINS_OBJS += test-hashmap.o diff --git a/t/helper/test-getuid.c b/t/helper/test-getuid.c new file mode 100644 index 0000000000..d741302461 --- /dev/null +++ b/t/helper/test-getuid.c @@ -0,0 +1,7 @@ +#include "test-tool.h" + +int cmd__getuid(int argc, const char **argv) +{ + printf("%d\n", getuid()); + return 0; +} diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index a0d3966b29..ab206541df 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -30,6 +30,7 @@ static struct test_cmd cmds[] = { { "example-decorate", cmd__example_decorate }, { "genrandom", cmd__genrandom }, { "genzeros", cmd__genzeros }, + { "getuid", cmd__getuid }, { "hashmap", cmd__hashmap }, { "hash-speed", cmd__hash_speed }, { "index-version", cmd__index_version }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index 07034d3f38..caee0a3667 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -20,6 +20,7 @@ int cmd__dump_untracked_cache(int argc, const char **argv); int cmd__example_decorate(int argc, const char **argv); int cmd__genrandom(int argc, const char **argv); int cmd__genzeros(int argc, const char **argv); +int cmd__getuid(int argc, const char **argv); int cmd__hashmap(int argc, const char **argv); int cmd__hash_speed(int argc, const char **argv); int cmd__index_version(int argc, const char **argv);
-- 2.29.2.454.gaff20da3a2