- /* This links back to the module's test dir. */
- testlink = tal_fmt(NULL, "%s/test", temp_dir());
-
- /* Defaults to pwd. */
- if (argc == 1) {
- i = 1;
- goto got_dir;
- }
-
- for (i = 1; i < argc; i++) {
- dir = argv[i];
-
- if (dir[0] != '/')
- dir = tal_fmt(NULL, "%s/%s", base_dir, dir);
- while (strends(dir, "/"))
- dir[strlen(dir)-1] = '\0';
-
- got_dir:
- /* We assume there's a ccan/ in there somewhere... */
- if (i == 1) {
- ccan_dir = find_ccan_dir(dir);
- if (!ccan_dir)
- errx(1, "Cannot find ccan/ base directory in %s",
- dir);
- config_header = read_config_header(ccan_dir,
- &compiler, &cflags,
- verbose > 1);
+ if (argc == 1)
+ dir = cwd;
+ else
+ dir = path_join(NULL, cwd, argv[1]);
+
+ ccan_dir = find_ccan_dir(dir);
+ if (!ccan_dir)
+ errx(1, "Cannot find ccan/ base directory in %s", dir);
+ config_header = read_config_header(ccan_dir, &compiler, &cflags,
+ verbose > 1);
+
+ if (argc == 1)
+ pass = test_module(&all, cwd, "", summary);
+ else {
+ for (i = 1; i < argc; i++) {
+ dir = path_canon(NULL,
+ take(path_join(NULL, cwd, argv[i])));
+
+ prefix = path_join(NULL, ccan_dir, "ccan");
+ prefix = path_rel(NULL, take(prefix), dir);
+ prefix = tal_strcat(NULL, take(prefix), ": ");
+
+ pass &= test_module(&all, dir, prefix, summary);
+ reset_tests(&all);