Skip to content

Commit 424b1c4

Browse files
committed
make sure index is there before testing it
1 parent 0e292e2 commit 424b1c4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/analysis/text/search/LuceneTest.rsc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ Analyzer indexAnalyzer() = fieldsAnalyzer(an(), comments=commentAnalyzer(), extr
7070
// where we store the lucene index (may be any loc as long as its a directory)
7171
loc indexFolder = |tmp:///picoIndex|;
7272

73-
void picoIndex() {
73+
bool picoIndex() {
7474
// always start afresh (for testing purposes)
7575
remove(indexFolder);
7676

7777
docs = {document(p, comments=p, extra="<for (w <- extraWords) {><w> <}>"[..-1]) | p <- programs};
7878

7979
createIndex(indexFolder, docs, analyzer=indexAnalyzer());
80+
81+
return true;
8082
}
8183

8284
void picoSearch(str term) {
@@ -107,12 +109,12 @@ test bool extraTermsTest() = listTerms(indexFolder, "extra") == {
107109
<"lbu",1>
108110
};
109111

110-
test bool identifierTest() = document(loc l) <- searchIndex(indexFolder, "src:repnr") && l == |project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|;
111-
test bool analyzerTest1() = size(analyzeDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, analyzer=an())) == 25;
112-
test bool analyzerTest2() = size(analyzeDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, analyzer=commentAnalyzer())) == 7;
113-
test bool searchDocTest1() = size(searchDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, "repnr", analyzer=an())) == 5;
114-
test bool searchDocTest2() = size(searchDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, "repnr", analyzer=commentAnalyzer())) == 0;
115-
test bool searchDocTest3() = size(searchDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, "check", analyzer=commentAnalyzer())) == 1;
112+
test bool identifierTest() = picoIndex() && document(loc l) <- searchIndex(indexFolder, "src:repnr") && l == |project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|;
113+
test bool analyzerTest1() = picoIndex() && size(analyzeDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, analyzer=an())) == 25;
114+
test bool analyzerTest2() = picoIndex() && size(analyzeDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, analyzer=commentAnalyzer())) == 7;
115+
test bool searchDocTest1() = picoIndex() && size(searchDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, "repnr", analyzer=an())) == 5;
116+
test bool searchDocTest2() = picoIndex() && size(searchDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, "repnr", analyzer=commentAnalyzer())) == 0;
117+
test bool searchDocTest3() = picoIndex() && size(searchDocument(|project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|, "check", analyzer=commentAnalyzer())) == 1;
116118

117119
void main() {
118120
picoIndex();

0 commit comments

Comments
 (0)