X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Fccanlint.c;h=3ffe38b2cf5f3ff54629515e76dc4b2acf1850e0;hb=8ffd9b98c7f87177445a86e65334e5ad1d66a8af;hp=1b11803c220e7e38b5537cb3c4a065aecdfafbc0;hpb=7bb7cd58c2d9df126dd6072e5f3bec1eb4dc916b;p=ccan-lca-2011.git diff --git a/tools/ccanlint/ccanlint.c b/tools/ccanlint/ccanlint.c index 1b11803..3ffe38b 100644 --- a/tools/ccanlint/ccanlint.c +++ b/tools/ccanlint/ccanlint.c @@ -292,12 +292,31 @@ static void init_tests(void) } } +static int show_tmpdir(char *dir) +{ + printf("You can find ccanlint working files in '%s'\n", dir); + return 0; +} + static char *keep_test(const char *testname, void *unused) { - struct ccanlint *i = find_test(testname); - if (!i) - errx(1, "No test %s to --keep", testname); - i->keep_results = true; + struct ccanlint *i; + + if (streq(testname, "all")) { + struct list_head *list; + foreach_ptr(list, &compulsory_tests, &normal_tests) { + list_for_each(list, i, list) + i->keep_results = true; + } + } else { + i = find_test(testname); + if (!i) + errx(1, "No test %s to --keep", testname); + i->keep_results = true; + } + + /* Don't automatically destroy temporary dir. */ + talloc_set_destructor(temp_dir(NULL), show_tmpdir); return NULL; } @@ -477,7 +496,8 @@ int main(int argc, char *argv[]) opt_register_noarg("--test-dep-graph", test_dependency_graph, NULL, "print dependency graph of tests in Graphviz .dot format"); opt_register_arg("-k|--keep ", keep_test, NULL, NULL, - "keep results of (can be used multiple times)"); + "keep results of " + " (can be used multiple times, or 'all')"); opt_register_noarg("--summary|-s", opt_set_bool, &summary, "simply give one line summary"); opt_register_noarg("--verbose|-v", opt_inc_intval, &verbose, @@ -495,10 +515,16 @@ int main(int argc, char *argv[]) " of CCAN modules.", "This usage message"); + /* We move into temporary directory, so gcov dumps its files there. */ + if (chdir(temp_dir(talloc_autofree_context())) != 0) + err(1, "Error changing to %s temporary dir", temp_dir(NULL)); + opt_parse(&argc, argv, opt_log_stderr_exit); if (dir[0] != '/') dir = talloc_asprintf_append(NULL, "%s/%s", base_dir, dir); + while (strends(dir, "/")) + dir[strlen(dir)-1] = '\0'; if (dir != base_dir) prefix = talloc_append_string(talloc_basename(NULL, dir), ": "); if (verbose >= 3) @@ -506,10 +532,6 @@ int main(int argc, char *argv[]) if (verbose >= 4) tools_verbose = true; - /* We move into temporary directory, so gcov dumps its files there. */ - if (chdir(temp_dir(talloc_autofree_context())) != 0) - err(1, "Error changing to %s temporary dir", temp_dir(NULL)); - m = get_manifest(talloc_autofree_context(), dir); /* Create a symlink from temp dir back to src dir's test directory. */