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:
Shawn O. Pearce
2011-06-16 13:56:25 -07:00
parent 793f7da6bf
commit 6262881882
4 changed files with 6 additions and 10 deletions

View File

@@ -12,7 +12,7 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
:- package 'gerrit'.
:- package gerrit.
'$init' :- init.

View File

@@ -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);

View File

@@ -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());

View File

@@ -12,7 +12,7 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.
:- package 'gerrit'.
:- package gerrit.
%% not_same