From e6e7530d10b74d763b4311ea93e0a831b810d6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 13 Apr 2016 20:22:42 +0700 Subject: test helpers: move test-* to t/helper/ subdirectory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This keeps top dir a bit less crowded. And because these programs are for testing purposes, it makes sense that they stay somewhere in t/ Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- test-run-command.c | 87 ------------------------------------------------------ 1 file changed, 87 deletions(-) delete mode 100644 test-run-command.c (limited to 'test-run-command.c') diff --git a/test-run-command.c b/test-run-command.c deleted file mode 100644 index 30a64a98dc..0000000000 --- a/test-run-command.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * test-run-command.c: test run command API. - * - * (C) 2009 Ilari Liusvaara - * - * This code is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include "git-compat-util.h" -#include "run-command.h" -#include "argv-array.h" -#include "strbuf.h" -#include -#include - -static int number_callbacks; -static int parallel_next(struct child_process *cp, - struct strbuf *err, - void *cb, - void **task_cb) -{ - struct child_process *d = cb; - if (number_callbacks >= 4) - return 0; - - argv_array_pushv(&cp->args, d->argv); - strbuf_addf(err, "preloaded output of a child\n"); - number_callbacks++; - return 1; -} - -static int no_job(struct child_process *cp, - struct strbuf *err, - void *cb, - void **task_cb) -{ - strbuf_addf(err, "no further jobs available\n"); - return 0; -} - -static int task_finished(int result, - struct strbuf *err, - void *pp_cb, - void *pp_task_cb) -{ - strbuf_addf(err, "asking for a quick stop\n"); - return 1; -} - -int main(int argc, char **argv) -{ - struct child_process proc = CHILD_PROCESS_INIT; - int jobs; - - if (argc < 3) - return 1; - proc.argv = (const char **)argv + 2; - - if (!strcmp(argv[1], "start-command-ENOENT")) { - if (start_command(&proc) < 0 && errno == ENOENT) - return 0; - fprintf(stderr, "FAIL %s\n", argv[1]); - return 1; - } - if (!strcmp(argv[1], "run-command")) - exit(run_command(&proc)); - - jobs = atoi(argv[2]); - proc.argv = (const char **)argv + 3; - - if (!strcmp(argv[1], "run-command-parallel")) - exit(run_processes_parallel(jobs, parallel_next, - NULL, NULL, &proc)); - - if (!strcmp(argv[1], "run-command-abort")) - exit(run_processes_parallel(jobs, parallel_next, - NULL, task_finished, &proc)); - - if (!strcmp(argv[1], "run-command-no-jobs")) - exit(run_processes_parallel(jobs, no_job, - NULL, task_finished, &proc)); - - fprintf(stderr, "check usage\n"); - return 1; -} -- cgit v1.2.1