Skip to content

Commit 5e8680d

Browse files
committed
Pass in test_string arg to allow running one test out of suite
(manifest_testsuite_run_suite): Add test_string arg and use it to check for test name or test literal match. (manifest_manifests_run): Add test_string arg for above. (main): Add -t / --test arg for setting a test to run.
1 parent dfa506d commit 5e8680d

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

utils/manifest.c

+19-2
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,8 @@ manifest_test_run(manifest_test* t, const char* path)
12401240

12411241

12421242
manifest_test_result*
1243-
manifest_testsuite_run_suite(manifest_testsuite* ts, unsigned int indent,
1243+
manifest_testsuite_run_suite(manifest_testsuite* ts,
1244+
const char* test_string, unsigned int indent,
12441245
int dryrun, int verbose)
12451246
{
12461247
char* name = ts->name;
@@ -1263,6 +1264,17 @@ manifest_testsuite_run_suite(manifest_testsuite* ts, unsigned int indent,
12631264

12641265
column = indent;
12651266
for(i = 0; (t = (manifest_test*)raptor_sequence_get_at(ts->tests, i)); i++) {
1267+
if(test_string) {
1268+
int found = 0;
1269+
const char* s = RASQAL_GOOD_CAST(const char*, rasqal_literal_as_string(t->test_node));
1270+
1271+
found = (t->name && !strcmp(t->name, test_string)) ||
1272+
(s && !strcmp(s, test_string));
1273+
1274+
if(!found)
1275+
continue;
1276+
}
1277+
12661278
if(t->flags & (FLAG_IS_UPDATE | FLAG_IS_PROTOCOL)) {
12671279
RASQAL_DEBUG2("Ignoring test %s type UPDATE / PROTOCOL - not supported\n",
12681280
rasqal_literal_as_string(t->test_node));
@@ -1338,7 +1350,10 @@ manifest_testsuite_run_suite(manifest_testsuite* ts, unsigned int indent,
13381350
* @world: world
13391351
* @manifest_uris: sequence of #raptor_uri manifest URIs
13401352
* @base_uri: base URI for manifest
1353+
* @test_string: string for running just one test (by name or URI)
13411354
* @indent: indent size
1355+
* @dryrun: dryrun
1356+
* @verbose: verbose
13421357
*
13431358
* Run the given manifest testsuites returning a test result
13441359
*
@@ -1348,6 +1363,7 @@ manifest_test_result*
13481363
manifest_manifests_run(manifest_world* mw,
13491364
raptor_sequence* manifest_uris,
13501365
raptor_uri* base_uri,
1366+
const char* test_string,
13511367
unsigned int indent,
13521368
int dryrun, int verbose)
13531369
{
@@ -1377,7 +1393,8 @@ manifest_manifests_run(manifest_world* mw,
13771393
break;
13781394
}
13791395

1380-
result = manifest_testsuite_run_suite(ts, indent, dryrun, verbose);
1396+
result = manifest_testsuite_run_suite(ts, test_string,
1397+
indent, dryrun, verbose);
13811398

13821399
if(result) {
13831400
manifest_testsuite_result_format(stdout, result, ts->name,

utils/manifest.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ void manifest_free_world(manifest_world* mw);
158158
/* test */
159159
const char* manifest_test_get_query_language(manifest_test* t);
160160

161-
manifest_test_result* manifest_manifests_run(manifest_world* mw, raptor_sequence* manifest_uris, raptor_uri* base_uri, unsigned int indent, int dryrun, int verbose);
161+
manifest_test_result* manifest_manifests_run(manifest_world* mw, raptor_sequence* manifest_uris, raptor_uri* base_uri, const char* test_string, unsigned int indent, int dryrun, int verbose);
162162

163-
manifest_test_result* manifest_testsuite_run_suite(manifest_testsuite* ts, unsigned int indent, int dryrun, int verbose);
163+
manifest_test_result* manifest_testsuite_run_suite(manifest_testsuite* ts, const char* test_string, unsigned int indent, int dryrun, int verbose);
164164

165165
/* test results */
166166
void manifest_free_test_result(manifest_test_result* result);

utils/testrunner.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static char *program = NULL;
8282
#endif
8383

8484

85-
#define GETOPT_STRING "hnqv"
85+
#define GETOPT_STRING "hnqt:v"
8686

8787
#ifdef HAVE_GETOPT_LONG
8888

@@ -92,6 +92,7 @@ static struct option long_options[] =
9292
{"help", 0, 0, 'h'},
9393
{"dryrun", 0, 0, 'n'},
9494
{"quiet", 0, 0, 'q'},
95+
{"test", 1, 0, 't'},
9596
{"version", 0, 0, 'v'},
9697
{NULL, 0, 0, 0}
9798
};
@@ -145,7 +146,7 @@ static void
145146
print_help(rasqal_world* world, raptor_world* raptor_world_ptr)
146147
{
147148
printf(title_format_string, rasqal_version_string);
148-
puts("Run an RDF test suite.");
149+
puts("Run an RDF query test suite.");
149150
printf("Usage: %s [OPTIONS] <manifest URI> [base URI]\n", program);
150151

151152
fputs(rasqal_copyright_string, stdout);
@@ -158,6 +159,7 @@ print_help(rasqal_world* world, raptor_world* raptor_world_ptr)
158159
puts(HELP_TEXT("h", "help ", "Print this help, then exit"));
159160
puts(HELP_TEXT("n", "dryrun ", "Prepare but do not run the query"));
160161
puts(HELP_TEXT("q", "quiet ", "No extra information messages"));
162+
puts(HELP_TEXT("t TEST", "test TEST ", "Run just one TEST"));
161163
puts(HELP_TEXT("v", "version ", "Print the Rasqal version"));
162164
puts("\nReport bugs to http://bugs.librdf.org/");
163165
}
@@ -181,6 +183,7 @@ main(int argc, char *argv[])
181183
manifest_world* mw;
182184
raptor_sequence* seq;
183185
manifest_test_result* result;
186+
char* test_string = NULL;
184187

185188
program = argv[0];
186189
if((p = strrchr(program, '/')))
@@ -227,6 +230,11 @@ main(int argc, char *argv[])
227230
dryrun = 1;
228231
break;
229232

233+
case 't':
234+
if(optarg)
235+
test_string = optarg;
236+
break;
237+
230238
case 'q':
231239
quiet = 1;
232240
break;
@@ -300,6 +308,7 @@ main(int argc, char *argv[])
300308
raptor_sequence_push(seq, raptor_uri_copy(uri));
301309

302310
result = manifest_manifests_run(mw, seq, base_uri,
311+
test_string,
303312
/* indent */ 0,
304313
dryrun, !quiet);
305314
raptor_free_sequence(seq);

0 commit comments

Comments
 (0)