Fix gerrit_common_test.pl
* Ensure we always load test cases, otherwise there is a false positive. * Fix the package to correctly be "gerrit". * Drop unnecessary quotes from Prolog package statements. The bare text is a valid symbol. Change-Id: I331ca90e050dc6d20e192c522f96893078102e59
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
%% See the License for the specific language governing permissions and
|
||||
%% limitations under the License.
|
||||
|
||||
:- package 'gerrit'.
|
||||
:- package gerrit.
|
||||
'$init' :- init.
|
||||
|
||||
|
||||
|
@@ -34,7 +34,7 @@ public class GerritCommonTest extends PrologTestCase {
|
||||
verifiedCategory()
|
||||
));
|
||||
|
||||
load("gerrit_common_test.pl", new AbstractModule() {
|
||||
load("gerrit", "gerrit_common_test.pl", new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ApprovalTypes.class).toInstance(types);
|
||||
|
@@ -43,7 +43,7 @@ public abstract class PrologTestCase extends TestCase {
|
||||
private List<Term> tests;
|
||||
protected PrologEnvironment env;
|
||||
|
||||
protected void load(String prologResource, Module... modules)
|
||||
protected void load(String pkg, String prologResource, Module... modules)
|
||||
throws FileNotFoundException, CompileException {
|
||||
ArrayList<Module> moduleList = new ArrayList<Module>();
|
||||
moduleList.add(new PrologModule());
|
||||
@@ -58,7 +58,7 @@ public abstract class PrologTestCase extends TestCase {
|
||||
|
||||
consult(getClass(), prologResource);
|
||||
|
||||
pkg = myPackage();
|
||||
this.pkg = pkg;
|
||||
hasSetup = has("setup");
|
||||
hasTeardown = has("teardown");
|
||||
|
||||
@@ -70,6 +70,7 @@ public abstract class PrologTestCase extends TestCase {
|
||||
for (Term[] pair : env.all(Prolog.BUILTIN, "clause", head, new VariableTerm())) {
|
||||
tests.add(pair[0]);
|
||||
}
|
||||
assertTrue("has tests", tests.size() > 0);
|
||||
}
|
||||
|
||||
protected void consult(Class<?> clazz, String prologResource)
|
||||
@@ -85,11 +86,6 @@ public abstract class PrologTestCase extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private String myPackage() {
|
||||
String pkg = getClass().getName();
|
||||
return pkg.substring(0, pkg.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
private boolean has(String name) {
|
||||
StructureTerm head = SymbolTerm.create(pkg, name, 0);
|
||||
return env.execute(Prolog.BUILTIN, "clause", head, new VariableTerm());
|
||||
|
@@ -12,7 +12,7 @@
|
||||
%% See the License for the specific language governing permissions and
|
||||
%% limitations under the License.
|
||||
|
||||
:- package 'gerrit'.
|
||||
:- package gerrit.
|
||||
|
||||
|
||||
%% not_same
|
||||
|
Reference in New Issue
Block a user