blob: 8a255abacc52335d047c57577134b50568fd25b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "test.h"
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
void test_errors(const char *test_dir) {
char *errors_dir = malloc(strlen(test_dir) + 30);
sprintf(errors_dir, "%s/errors", test_dir);
DIR *dir = opendir(errors_dir);
if (!dir) {
test_fail("Couldn't open test directory %s", errors_dir);
return;
}
struct dirent *ent;
while ((ent = readdir(dir))) {
const char *name = ent->d_name;
if (strlen(name) >= strlen("x.pom") &&
strcmp(name + strlen(name) - strlen(".pom"), ".pom") == 0) {
printf("Testing %s...\n",name);
char *conf_path = malloc(strlen(errors_dir) + strlen(name) + 30);
sprintf(conf_path, "%s/errors/%s", test_dir, name);
pom_error *error;
pom_conf *conf = pom_load_path(conf_path, &error);
if (error) {
free(error);
free(conf_path);
continue;
}
test_fail("Parsing %s didn't produce an error but it should have.",
conf_path);
pom_conf_free(conf);
free(conf_path);
}
}
free(errors_dir);
// pom_conf *conf = pom_load_path("../tests");
}
|