[gnome-js-common] Tests: split directory enumeration and argument parsing into shared C file
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-js-common] Tests: split directory enumeration and argument parsing into shared C file
- Date: Wed, 27 May 2009 06:06:32 -0400 (EDT)
commit 25c3827644efcb66da76cf544f9bb9696b56045e
Author: Tim Horton <hortont424 gmail com>
Date: Wed May 27 06:04:56 2009 -0400
Tests: split directory enumeration and argument parsing into shared C file
---
tests/Makefile.am | 2 +-
tests/run-tests-seed.c | 44 +++++---------------------------------------
2 files changed, 6 insertions(+), 40 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 448a800..6937379 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,7 +8,7 @@ if HAVE_SEED
check_PROGRAMS += run-tests-seed
TESTS += run-tests-seed
-run_tests_seed_SOURCES = run-tests-seed.c
+run_tests_seed_SOURCES = run-tests-seed.c run-tests.c
run_tests_seed_CFLAGS = \
-Wall \
diff --git a/tests/run-tests-seed.c b/tests/run-tests-seed.c
index e96c0ef..23d3b0c 100644
--- a/tests/run-tests-seed.c
+++ b/tests/run-tests-seed.c
@@ -7,8 +7,8 @@
#include <stdlib.h>
#include <stdio.h>
-SeedEngine * eng;
-gboolean failure_flag = FALSE;
+SeedEngine * eng = NULL;
+extern gboolean failure_flag;
SeedValue js_assert(SeedContext ctx,
SeedObject function,
@@ -27,6 +27,9 @@ gboolean test_exec(gchar * filename)
SeedScript * script;
SeedException e;
gchar * buffer;
+
+ if(!eng)
+ eng = seed_init(NULL, NULL);
g_file_get_contents(filename, &buffer, 0, 0);
@@ -68,40 +71,3 @@ gboolean test_exec(gchar * filename)
return TRUE;
}
-void run_tests(gchar * tests_dir_name)
-{
- GDir * tests_dir;
- const gchar * test_name;
- const gchar * test_path;
-
- tests_dir = g_dir_open(tests_dir_name, 0, NULL);
- while((test_name = g_dir_read_name(tests_dir)) != NULL)
- {
- if(!g_str_has_suffix(test_name, ".js")) // TODO: casing problem
- continue;
-
- test_path = g_build_filename(tests_dir_name, test_name, NULL);
-
- if(test_exec((char*)test_path))
- printf("%s... OK\n", test_path);
- }
-
-}
-
-int main(int argc, char ** argv)
-{
- eng = seed_init(&argc, &argv);
-
- if(argc == 1)
- run_tests(".");
- else
- {
- int i;
-
- for(i = 1; i < argc; i++)
- run_tests(argv[i]);
- }
-
- return failure_flag;
-}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]