Add stub generation tests

This commit is contained in:
Tony Torralba
2022-09-02 10:48:11 +02:00
parent 0645f62a0d
commit 2036453176
9 changed files with 45 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
noGeneratedStubs
multipleGeneratedStubs
#select
| org.test.SampleAnnotationType | // Generated automatically from org.test.SampleAnnotationType for testing purposes\n\npackage org.test;\n\nimport java.lang.annotation.Annotation;\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Target;\n\n@Target(value={ElementType.METHOD})\npublic @interface SampleAnnotationType\n{\n}\n |
| org.test.SampleType | // Generated automatically from org.test.SampleType for testing purposes\n\npackage org.test;\n\n\npublic class SampleType\n{\n public Object sampleField = null;\n public SampleType(){}\n public void sampleMethod(){}\n}\n |

View File

@@ -0,0 +1 @@
utils/stub-generator/MinimalStubsFromSource.ql

View File

@@ -0,0 +1,13 @@
import org.test.SampleAnnotationType;
import org.test.SampleType;
public class Test {
@SampleAnnotationType
public void test() {
new SampleType().sampleField = null;
new SampleType().sampleMethod();
}
}

View File

@@ -0,0 +1 @@
//semmle-extractor-options: --javac-args -cp ${testdir}/testlib.jar

Binary file not shown.

View File

@@ -0,0 +1,5 @@
# testlib
Library for testing stub generation (we need a binary dependency because normal stubs are source files, and thus are excluded by the stub generator).
Run `generate.sh` to update `testlib.jar` in the test directory.

View File

@@ -0,0 +1,3 @@
#/bin/bash
javac org/test/*.java
jar cf ../Minimal/testlib.jar org/test/*.class

View File

@@ -0,0 +1,9 @@
package org.test;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Target(ElementType.METHOD)
public @interface SampleAnnotationType {
}

View File

@@ -0,0 +1,8 @@
package org.test;
public class SampleType {
public Object sampleField;
public void sampleMethod() {}
}