ali@0
|
1 |
#include <stdlib.h>
|
ali@0
|
2 |
#include <stdio.h>
|
ali@0
|
3 |
#include <string.h>
|
ali@6
|
4 |
#include <glib.h>
|
ali@5
|
5 |
#include <bl/bl.h>
|
ali@0
|
6 |
#include "testcase.h"
|
ali@0
|
7 |
#include "testcaseio.h"
|
ali@0
|
8 |
|
ali@96
|
9 |
static gboolean show_output;
|
ali@96
|
10 |
|
ali@96
|
11 |
static GOptionEntry options[]={
|
ali@96
|
12 |
{ "show-output", 'o', 0, G_OPTION_ARG_NONE, &show_output,
|
ali@96
|
13 |
"Show bookloupe output", NULL },
|
ali@96
|
14 |
{ NULL }
|
ali@96
|
15 |
};
|
ali@96
|
16 |
|
ali@0
|
17 |
/*
|
ali@0
|
18 |
* Returns FALSE if the test should be considered to have failed.
|
ali@0
|
19 |
* (returns TRUE on pass or expected-fail).
|
ali@0
|
20 |
*/
|
ali@6
|
21 |
gboolean run_test(const char *filename)
|
ali@0
|
22 |
{
|
ali@0
|
23 |
Testcase *testcase;
|
ali@6
|
24 |
gboolean retval;
|
ali@0
|
25 |
testcase=testcase_parse_file(filename);
|
ali@0
|
26 |
if (!testcase)
|
ali@0
|
27 |
return FALSE;
|
ali@96
|
28 |
if (show_output)
|
ali@96
|
29 |
retval=testcase_show_output(testcase);
|
ali@96
|
30 |
else
|
ali@96
|
31 |
retval=testcase_run(testcase);
|
ali@0
|
32 |
testcase_free(testcase);
|
ali@0
|
33 |
return retval;
|
ali@0
|
34 |
}
|
ali@0
|
35 |
|
ali@0
|
36 |
int main(int argc,char **argv)
|
ali@0
|
37 |
{
|
ali@0
|
38 |
int i;
|
ali@6
|
39 |
gboolean pass=TRUE;
|
ali@96
|
40 |
GError *err=NULL;
|
ali@96
|
41 |
GOptionContext *context;
|
ali@96
|
42 |
context=g_option_context_new("file - run a bookloupe testcase");
|
ali@96
|
43 |
g_option_context_add_main_entries(context,options,NULL);
|
ali@96
|
44 |
if (!g_option_context_parse(context,&argc,&argv,&err))
|
ali@96
|
45 |
{
|
ali@96
|
46 |
g_printerr("loupe-test: %s\n",err->message);
|
ali@96
|
47 |
g_printerr("Use \"%s --help\" for help\n",argv[0]);
|
ali@96
|
48 |
exit(1);
|
ali@96
|
49 |
}
|
ali@11
|
50 |
bl_set_print_handlers();
|
ali@102
|
51 |
g_setenv("BOOKLOUPE_CONFIG_PATH",".",TRUE);
|
ali@0
|
52 |
for(i=1;i<argc;i++)
|
ali@0
|
53 |
pass&=run_test(argv[i]);
|
ali@0
|
54 |
return pass?0:1;
|
ali@0
|
55 |
}
|