Skip to content

Commit 2036453

Browse files
committed
Add stub generation tests
1 parent 0645f62 commit 2036453

File tree

9 files changed

+45
-0
lines changed

9 files changed

+45
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
noGeneratedStubs
2+
multipleGeneratedStubs
3+
#select
4+
| 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 |
5+
| 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 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
utils/stub-generator/MinimalStubsFromSource.ql
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import org.test.SampleAnnotationType;
2+
import org.test.SampleType;
3+
4+
public class Test {
5+
6+
@SampleAnnotationType
7+
public void test() {
8+
new SampleType().sampleField = null;
9+
new SampleType().sampleMethod();
10+
}
11+
12+
}
13+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/testlib.jar
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# testlib
2+
3+
Library for testing stub generation (we need a binary dependency because normal stubs are source files, and thus are excluded by the stub generator).
4+
5+
Run `generate.sh` to update `testlib.jar` in the test directory.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#/bin/bash
2+
javac org/test/*.java
3+
jar cf ../Minimal/testlib.jar org/test/*.class
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.test;
2+
3+
import java.lang.annotation.Target;
4+
import java.lang.annotation.ElementType;
5+
6+
@Target(ElementType.METHOD)
7+
public @interface SampleAnnotationType {
8+
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.test;
2+
3+
public class SampleType {
4+
5+
public Object sampleField;
6+
7+
public void sampleMethod() {}
8+
}

0 commit comments

Comments
 (0)