Skip Analysis tests when test data not found. Rather than fail when the JSON files containing test data cannot be found, skip the tests.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/874d4a38 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/874d4a38 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/874d4a38 Branch: refs/heads/master Commit: 874d4a38077286f1e41391d257051f641b0ecb7c Parents: 4f37426 Author: Marvin Humphrey <[email protected]> Authored: Wed Sep 30 12:02:15 2015 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Wed Sep 30 19:13:30 2015 -0700 ---------------------------------------------------------------------- core/Lucy/Test/Analysis/TestNormalizer.c | 5 +++ core/Lucy/Test/Analysis/TestSnowballStemmer.c | 5 +++ core/Lucy/Test/Analysis/TestStandardTokenizer.c | 33 +++++++++++--------- core/Lucy/Test/TestUtils.c | 3 +- core/Lucy/Test/TestUtils.cfh | 4 ++- 5 files changed, 33 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/874d4a38/core/Lucy/Test/Analysis/TestNormalizer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestNormalizer.c b/core/Lucy/Test/Analysis/TestNormalizer.c index 3c0c618..ab68930 100644 --- a/core/Lucy/Test/Analysis/TestNormalizer.c +++ b/core/Lucy/Test/Analysis/TestNormalizer.c @@ -74,6 +74,11 @@ test_Dump_Load_and_Equals(TestBatchRunner *runner) { static void test_normalization(TestBatchRunner *runner) { FSFolder *modules_folder = TestUtils_modules_folder(); + if (modules_folder == NULL) { + SKIP(runner, 13, "Can't locate test data"); + return; + } + String *path = Str_newf("unicode/utf8proc/tests.json"); Vector *tests = (Vector*)Json_slurp_json((Folder*)modules_folder, path); if (!tests) { RETHROW(Err_get_error()); } http://git-wip-us.apache.org/repos/asf/lucy/blob/874d4a38/core/Lucy/Test/Analysis/TestSnowballStemmer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestSnowballStemmer.c b/core/Lucy/Test/Analysis/TestSnowballStemmer.c index 87b88c9..1a066ab 100644 --- a/core/Lucy/Test/Analysis/TestSnowballStemmer.c +++ b/core/Lucy/Test/Analysis/TestSnowballStemmer.c @@ -64,6 +64,11 @@ test_Dump_Load_and_Equals(TestBatchRunner *runner) { static void test_stemming(TestBatchRunner *runner) { FSFolder *modules_folder = TestUtils_modules_folder(); + if (modules_folder == NULL) { + SKIP(runner, 150, "Can't locate test data"); + return; + } + String *path = Str_newf("analysis/snowstem/source/test/tests.json"); Hash *tests = (Hash*)Json_slurp_json((Folder*)modules_folder, path); if (!tests) { RETHROW(Err_get_error()); } http://git-wip-us.apache.org/repos/asf/lucy/blob/874d4a38/core/Lucy/Test/Analysis/TestStandardTokenizer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Analysis/TestStandardTokenizer.c b/core/Lucy/Test/Analysis/TestStandardTokenizer.c index 2676549..5ada7ec 100644 --- a/core/Lucy/Test/Analysis/TestStandardTokenizer.c +++ b/core/Lucy/Test/Analysis/TestStandardTokenizer.c @@ -95,22 +95,27 @@ test_tokenizer(TestBatchRunner *runner) { DECREF(got); FSFolder *modules_folder = TestUtils_modules_folder(); - String *path = Str_newf("unicode/ucd/WordBreakTest.json"); - Vector *tests = (Vector*)Json_slurp_json((Folder*)modules_folder, path); - if (!tests) { RETHROW(Err_get_error()); } - - for (uint32_t i = 0, max = Vec_Get_Size(tests); i < max; i++) { - Hash *test = (Hash*)Vec_Fetch(tests, i); - String *text = (String*)Hash_Fetch_Utf8(test, "text", 4); - Vector *wanted = (Vector*)Hash_Fetch_Utf8(test, "words", 5); - Vector *got = StandardTokenizer_Split(tokenizer, text); - TEST_TRUE(runner, Vec_Equals(wanted, (Obj*)got), "UCD test #%d", i + 1); - DECREF(got); + if (modules_folder == NULL) { + SKIP(runner, 1372, "Can't locate test data"); } + else { + String *path = Str_newf("unicode/ucd/WordBreakTest.json"); + Vector *tests = (Vector*)Json_slurp_json((Folder*)modules_folder, path); + if (!tests) { RETHROW(Err_get_error()); } + + for (uint32_t i = 0, max = Vec_Get_Size(tests); i < max; i++) { + Hash *test = (Hash*)Vec_Fetch(tests, i); + String *text = (String*)Hash_Fetch_Utf8(test, "text", 4); + Vector *wanted = (Vector*)Hash_Fetch_Utf8(test, "words", 5); + Vector *got = StandardTokenizer_Split(tokenizer, text); + TEST_TRUE(runner, Vec_Equals(wanted, (Obj*)got), "UCD test #%d", i + 1); + DECREF(got); + } - DECREF(tests); - DECREF(modules_folder); - DECREF(path); + DECREF(tests); + DECREF(modules_folder); + DECREF(path); + } DECREF(tokenizer); } http://git-wip-us.apache.org/repos/asf/lucy/blob/874d4a38/core/Lucy/Test/TestUtils.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/TestUtils.c b/core/Lucy/Test/TestUtils.c index 4534a28..68171dc 100644 --- a/core/Lucy/Test/TestUtils.c +++ b/core/Lucy/Test/TestUtils.c @@ -180,7 +180,6 @@ TestUtils_modules_folder() { DECREF(modules_folder); } - THROW(ERR, "Can't open modules folder"); - UNREACHABLE_RETURN(FSFolder*); + return NULL; } http://git-wip-us.apache.org/repos/asf/lucy/blob/874d4a38/core/Lucy/Test/TestUtils.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/TestUtils.cfh b/core/Lucy/Test/TestUtils.cfh index 5960283..0d3e15c 100644 --- a/core/Lucy/Test/TestUtils.cfh +++ b/core/Lucy/Test/TestUtils.cfh @@ -66,8 +66,10 @@ inert class Lucy::Test::TestUtils { Vector *expected, const char *message); /** Return the "modules" folder. + * + * If the folder cannot be found, return NULL. */ - inert FSFolder* + inert incremented nullable FSFolder* modules_folder(); }
