]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/ccanlint.c
ccanlint: -k should not pollute module directory.
[ccan] / tools / ccanlint / ccanlint.c
index 8acad9329e4c7280d0fef58eb8b833cf9ca7cd72..42da05afad85719a09ebe66f9bb0d9849608d96b 100644 (file)
@@ -292,12 +292,21 @@ 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;
 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;
+
+       /* Don't automatically destroy temporary dir. */
+       talloc_set_destructor(temp_dir(NULL), show_tmpdir);
        return NULL;
 }
 
        return NULL;
 }
 
@@ -495,6 +504,10 @@ int main(int argc, char *argv[])
                           " of CCAN modules.",
                           "This usage message");
 
                           " 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] != '/')
        opt_parse(&argc, argv, opt_log_stderr_exit);
 
        if (dir[0] != '/')
@@ -508,10 +521,6 @@ int main(int argc, char *argv[])
        if (verbose >= 4)
                tools_verbose = true;
 
        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. */
        m = get_manifest(talloc_autofree_context(), dir);
 
        /* Create a symlink from temp dir back to src dir's test directory. */