Skip to content

Commit eb4b9c7

Browse files
author
Owen Jones
committed
Squashed 'benchmarks/LIBRARIES/models/' changes from cc8db21..67c80fc
67c80fc Merge pull request diffblue#394 from diffblue/jeannie/LinkedHashMapIterators 6667484 Tests that the iteration order is correct. 38301ea Tests other methods and constructor in LinkedHashMap f795b3d Models other methods in LinkedHashMap. 25773a6 Tests entrySet(), keySet() and values() in LinkedHashMap ee8cfad Models keySet(), entrySet() and values() in LinkedHashMap. 02c8271 Merge pull request diffblue#393 from diffblue/jeannie/UpdateReadMeForSpec 81460d3 Update readme.md to include new style for specs 9efcce3 Merge pull request diffblue#396 from diffblue/antonia/clean-up-for-TG-1081 c902c03 Merge pull request diffblue#397 from diffblue/jeannie/ForgotAppendObjectDocs 772a977 Merge pull request diffblue#390 from diffblue/antonia/enable-fixed-tests 5bef2ff Merge pull request diffblue#398 from diffblue/antonia/ticket-references-bugfix ed1dca2 Merge pull request diffblue#395 from diffblue/allredj/disable-tests-failing-on-tg2717 c07841d Add more tests for String.getBytes(Charset) d568e47 Fix array index bug in String.getBytesUTF_16 2218407 Model String.getBytes(Charset) 9c3a8bc Clarify difference of String.getBytes from JDK cf1c23b Merge the two active scenarios in String.spec dd5d2d9 Remove support_v1 tag from String specs 5f9a7e1 Split String tests into Level 0 and Level 1+ f2877b9 Enable Class test that was blocked by TG-1081 034f3e0 Remove reference to TG-1081 from File model 43afde7 Force static initialiser for File model d95ff9e Remove reference to fixed bug from Date model 0807806 Remove references to fixed bugs from Arrays model cde4085 Remove references to fixed bugs from HashMap model d85fe5b Update RaceTimes references to TG-1404 and TG-1523 0e925e5 Update ticket number in HashMap.spec 03a5186 Enable TG-1404 tests fa051dd Delete ArrayList CustomType test file b0e853b Enable HashMap test previously blocked by TG-1877 44bfe0a Merge pull request diffblue#392 from diffblue/lajw/TG-2389-enable-tests 595dd5d Changes CProver helped methods in HashMap to protected. c52771c Merge pull request diffblue#385 from diffblue/jeannie/UpdateTestRunner de0abdc Enable tests fixed by recent test-gen fixes b64357a Remove ticket numbers from resolved bugfix tests 53eca00 Documents StringBuilder and StringBuffer append(Object) baec23f Merge pull request diffblue#389 from diffblue/antonia/enable-TG-2666-test b2f0258 Enable LinkedList test that was blocked by TG-2666 57e79e5 Add knownbug tests for TG-2717 80fa433 Merge pull request diffblue#387 from diffblue/forejtv/unsupportedcharsetexception 990129c Merge pull request diffblue#391 from diffblue/allredj/disable-html-report 97f32f6 Don't write to the Html report 4cb5996 Merge pull request diffblue#382 from diffblue/antonia/address-ArrayList-todos 6749702 Merge pull request diffblue#386 from diffblue/antonia/gauge-telemetry-off 546dfdc Move legacy style tests into main Gauge step 5be886f Mark UnsupportedCharsetException as untested 1c17838 Add regression test for side effects 8c836ab Add tests for ArrayLists w. (non-default) capacity 34a141d Address bugfix TODOs in ArrayList 563b631 Correct bug description in comment 3e7603d Merge pull request diffblue#383 from diffblue/antonia/reformat-HashSet-tests 5d4e013 [TG-2751] Added UnsupportedCharsetException 11b28fb Reformat HashSet.spec f77c3c4 Rename HashSet_L2.spec to HashSet_L0.spec a16a1e7 Move all HashSet Maven tests into HashSet.spec f21a2da Merge pull request diffblue#376 from diffblue/jeannie/LinkedHashMap 820c5f7 Merge pull request diffblue#380 from diffblue/jeannie/AppendObject af65f4d Tests java.lang.StringBuffer append(Object) a554517 Reformat tests in java.util.StringBuilder dd6d3f6 Models append(Object) for StringBuilder and StringBuffer. 8920399 Tests toString() methods on existing models where possible 647f4fe Tests toString() methods on existing models where possible 978273b Documents and implements toString() methods in existing models. 78020ee Documents java.util.LinkedHashMap fb0cf92 Tests java.util.LinkedHashMap 7a9df4e Models java.util.LinkedHashMap 5a8af60 Marks all methods as notModelled() for java.util.LinkedHashMap 8d6b149 Initial commit for java.util.LinkedHashMap 34b7c54 Merge pull request diffblue#359 from diffblue/forejtv/throwable-no-static e2230de Cleanup of unused (mostly static) variables 255013e Merge pull request diffblue#384 from diffblue/jeannie/DisableBoundedGenericHashMap f374d5f Merge pull request diffblue#381 from diffblue/justin/TG2600-Correction ce6328b Turn off Gauge telemetry on Travis 6ab2864 Updates TestRunner.java to mimic platform parameters. 8ee75a4 Disables a HashMap test that depends on bounded generic type. 3677c3a [TG-2600] correct a mistake in the L1RemoveLast test 4511813 Merge pull request diffblue#378 from diffblue/antonia/LinkedList-first-model 6bda7ea Add tests for LinkedList b5d4cbe Model LinkedList methods specified in TG-2600 aa6e90a Empty models for new classes 3c25555 Copy LinkedList and related classes from jdk 5e4d410 Merge pull request diffblue#373 from diffblue/romain/tests/activate-arrays-hashset-test#TG-1404 a0d9289 Activate some Arrays test 27d06b4 Activate tests for Hashset fixed by TG-1404 224962a Merge pull request diffblue#371 from diffblue/romain/tests/activate-after-fix-1404 ed26b28 Activate level 2 tests fixed by TG-1404 b59c1e9 Relabel known-bug for Level2 HashMap test 5c0041b Activate tests for HashMap.values fixed by TG-1404 2777872 Activate tests for HashMap.entrySet 50d3f2c Activate tests for HashMap.keySet fixed by TG-1404 6146215 Activate ArrayList test fixed by TG-1404 bc09fd7 Merge pull request diffblue#365 from diffblue/jeannie/getTimeZone 29cf7e0 Merge pull request diffblue#372 from diffblue/forejtv/bump-up-gauge-v bdd500a Change Gauge Java Maven Plugin to 0.6.6 190aa18 Tests java.util.TimeZone 170a992 Documents java.util.TimeZone in javadocs 9e52664 Models java.util.TimeZone constructor, getID, setID and getTimeZone. eac578e Tests sun.util.calendar.ZoneInfo b4be728 Documents sun.util.calendar.ZoneInfo in javadocs e5ffa98 Models the sun.util.calendar.ZoneInfo constructor and getTimeZone() 6d704ad Marks methods as notModelled() for sun.util.calendar.ZoneInfo d249adb Marks methods as notModelled() for java.util.TimeZone 7f71d8d Initial commit for sun.util.calendar.ZoneInfo. b53d9c1 Initial commit for java.util.TimeZone 056aad2 Merge pull request diffblue#368 from diffblue/allredj/fix-hashtable-spec 8848414 Merge pull request diffblue#370 from diffblue/allredj/stringbuffer-spec-small-correction 1d947e5 Small correction to StringBuffer spec file 42f1a93 Fix typo in hashtable spec file git-subtree-dir: benchmarks/LIBRARIES/models git-subtree-split: 67c80fcdcf82418b5e7099ae63dec3360b153f90
1 parent cd4e69f commit eb4b9c7

File tree

214 files changed

+8950
-788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+8950
-788
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ install:
4646
- sudo apt-get update
4747
- sudo apt-get install gauge
4848
- gauge install java
49-
- gauge install html-report
49+
# Temporarily disable html-report (installing this plugin might not be required anyway)
50+
# gauge install html-report
5051
- gauge config plugin_kill_timeout 20000
52+
- gauge telemetry off
5153
- export MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
5254
- export DIFFBLUE_MODEL_TESTS_PROCESS_TIMEOUT="500"
5355

README.md

+75-24
Original file line numberDiff line numberDiff line change
@@ -196,76 +196,128 @@ the file on Google Cloud.
196196

197197
### Adding New Tests
198198

199+
#### Quick overview of testing
200+
201+
In models-library, there are three levels of tests:
202+
- Level 0 - verify model matching behaviour of JDK
203+
- Level 1 - small "unit" tests that verify tests can be generated, compile, run and pass for one configuration of one method or constructor
204+
- Level 2 - like Level 1 tests, but more typical use cases mimicking client code combining methods or classes.
205+
206+
When writing new models, we tend to focus on writing Level 1 tests. We aim
207+
to ensure that all possible branches are covered. For example, in `ArrayList`,
208+
to check test generation of the `get(int i)` method, which gets an element
209+
at a particular index, you might a make class file `L1Get.java` that
210+
contains three methods for the following tests:
211+
- `i >= 0` and there is an element at `i`
212+
- `i >= al.size()` where `al` is an ArrayList (throws exception)
213+
- `i < 0` (throws exception)
214+
215+
The Gauge spec file will take the class file, generate tests for it
216+
using models-library, verify that the tests give full coverage,
217+
compile the tests, run the tests using the JDK and
218+
verify that they pass, or throw an error.
219+
220+
#### Gauge spec files
221+
199222
You will probably want to supply test specifications alongside any new models.
200223
First, you should probably familiarise yourself with how Gauge works, using the
201224
official documentation [here](https://docs.getgauge.io/using.html).
202225
Generally, test specifications will look like this:
203226

204227
```
205-
# java.package.ClassName
228+
# java.<package>.<Class>
206229
207-
Tags: my-unique-tag
230+
* Setup Maven project "test_data/maven/java/<package>/<Class>"
208231
209-
Plain text here is interpreted as a comment. Tags here apply to the entire
210-
file, so if you add known-bug as a tag, *none of the tests in the file will run
211-
in CI*.
232+
## Level 1 <Class>
212233
213-
* Bullet points correspond to methods in the TestRunner.java
214-
* Bullets at the top of the file are run for each subsequent subheading
234+
Level 1 - <constructor or method>
235+
<Optional comments>
236+
* Set class file "target/classes/<ClassFileName1>.class"
237+
* Generate tests for "<ClassFileName1>.<TestName1>"
238+
* Generate tests for "<ClassFileName1>.<TestName2>"
215239
240+
Level 1 - <another constructor or method>
241+
<Optional comments>
242+
* Set class file "target/classes/<ClassFileName2>.class"
243+
* Generate tests for "<ClassFileName2>.<TestName1>"
244+
* Generate tests for "<ClassFileName2>.<TestName2>"
216245
217-
## method name or signature
246+
* Verify tests in Maven project
247+
* Unset class file
218248
219-
Tags: known-bug
220249
221-
This test is known to fail. Normally we'll put a link to a relevant
222-
github issue here.
250+
## Level 1 <Class> <tagname>
223251
224-
* This step runs the test
252+
Tags: <tagname>
225253
226-
## another method name or signature
254+
<Jira ticket if a known-bug or future>
255+
<Optional comments>
256+
* Set class file "target/classes/<ClassFileName1>.class"
257+
* Generate tests for "<ClassFileName1>.<TestName1>"
258+
* Generate tests for "<ClassFileName1>.<TestName2>"
227259
228-
Tags: support-v1
260+
* Verify tests in Maven project
261+
* Unset class file
262+
```
229263

230-
This test is known to pass, and is required for the support-v1 goal.
264+
where tags are:
265+
- `future`
266+
- `long`
267+
- `known-bug`
231268

232-
* This step runs the test
233-
```
269+
The `long` tag is used to prevent tests that take too long from running
270+
on CI. We rarely use the `future` tag, but occasionally we develop models
271+
before deeptest is ready for them. Anything tagged with `known-bug` should
272+
include the Jira ticket number.
234273

235-
Check in the `specs` directory to see what "real" specs look like. Some of the
236-
most important steps/bullet-points used specifically in the models tests
237-
follow.
274+
Some of the most important steps/bullet-points used specifically
275+
in the models tests follow.
238276

239277
#### Verification
240278

241279
```
242280
* Run "classname.class", expecting exit code "0" and output "VERIFICATION SUCCESSFUL"
243281
```
244282

283+
These are Level 0 tests.
284+
245285
This step will do a CBMC-style verification (using the test-generator
246286
executable) of the `main` method in the provided class. The second argument
247287
denotes the expected return code, and the final argument is a snippet that
248288
should be matched in the program's stdout.
249289

250290
#### Grouped Test Generation (recommended)
251291

252-
The process for generating tests and verfying them (compile, run, pass) in a
292+
These are Level 1 and 2 tests.
293+
294+
The process for generating tests and verifying them (compile, run, pass) in a
253295
specified maven directory is as follows:
254296

255297
Set the maven directory and clean all test files:
256298
```
257299
* Setup Maven project "path/to/directory"
258300
```
259-
Run test-generator to populate the Maven project with generated test:
301+
Run test-generator to populate the Maven project with generated test from
302+
methods in a class file:
303+
```
304+
* Set class file "target/classes/<ClassFileName1>.class"
305+
* Generate tests for "<ClassFileName1>.<TestName1>"
306+
* Generate tests for "<ClassFileName1>.<TestName2>"
307+
```
308+
for as many class files as required.
309+
310+
In older spec files you may also see this more cumbersome notation:
260311
```
261312
* Generate tests for "java.function.signature1" in "target/classes/test1.class"
262313
* Generate tests for "java.function.signature2" in "target/classes/test2.class"
263314
* Generate tests for "java.function.signature3" in "target/classes/test3.class"
264315
...
265316
```
266-
Run mvn test on the Maven project:
317+
Run mvn test on the Maven project and unset the class file:
267318
```
268319
* Verify tests in Maven project
320+
* Unset class file
269321
```
270322

271323
#### Standalone Test Generation (not recommended)
@@ -347,4 +399,3 @@ variables set by the test-gen superbuild.
347399

348400
[build_img]: https://travis-ci.com/diffblue/models-library.svg?token=i8KzPhcTpXyyoppmAEw1
349401
[travis]: https://travis-ci.com/diffblue/models-library
350-

model/modelTests/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<dependency>
1212
<groupId>com.thoughtworks.gauge</groupId>
1313
<artifactId>gauge-java</artifactId>
14-
<version>0.6.4</version>
14+
<version>0.6.6</version>
1515
<scope>test</scope>
1616
</dependency>
1717
<dependency>

model/modelTests/specs/bugs.spec

+15-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66

77
Tests that were previously disabled due to a bug that has now been fixed
88

9-
TG-1877 Types of elements of input arrays ignored by lazy methods
10-
causes TG-1712 Incorrect tests for comparison of primitive wrapper classes in array
119
* Generate tests for "tg1877.ArrayListElementsCustom.callMethodOnElement" in "target/classes/tg1877/ArrayListElementsCustom.class"
1210
* Generate tests for "tg1877.ArrayListElementsInteger.callLessOnElement" in "target/classes/tg1877/ArrayListElementsInteger.class"
1311
* Generate tests for "tg1877.ArrayListElementsInteger.callLessOnElementAndConst" in "target/classes/tg1877/ArrayListElementsInteger.class"
1412
* Generate tests for "tg1877.ArrayListElementsInteger.callPrimitiveLessOnElement" in "target/classes/tg1877/ArrayListElementsInteger.class"
1513
* Generate tests for "tg1877.ArrayListElementsBitSet.callMethodOnElement" in "target/classes/tg1877/ArrayListElementsBitSet.class"
1614

17-
TG-1245 Object.getClass not working for Objects that may be null
1815
* Generate tests for "tg1245.ObjectGetClassMaybeNull.test" in "target/classes/tg1245/ObjectGetClassMaybeNull.class"
1916

17+
* Generate tests for "tg1931.L1ToStringOnObject.toStringObject" in "target/classes/tg1931/L1ToStringOnObject.class"
18+
2019
* Verify tests in Maven project
2120

2221
## LONG
@@ -26,8 +25,19 @@ too long to be enabled on CI.
2625

2726
Tags: long
2827

29-
TG-1877 Types of elements of input arrays ignored by lazy methods
30-
causes TG-1712 Incorrect tests for comparison of primitive wrapper classes in array
3128
* Generate tests for "tg1877.CustomType.moreComplicatedCalls" in "target/classes/tg1877/CustomType.class"
3229

3330
* Verify tests in Maven project
31+
32+
33+
## KNOWN BUGS
34+
35+
Tests for which there is a known issue that has not yet been fixed
36+
37+
Tags: known-bug
38+
39+
TG-2717
40+
Specializing fields of a generic abstract class implementation does not work
41+
* Generate tests for "tg2717.GenericInterface.hashmapNdMap" in "target/classes/tg2717/GenericInterface.class"
42+
43+
* Verify tests in Maven project
+8-16
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
# java.io.File
22

3-
## Level 1+ tests - java.io.File
4-
53
* Setup Maven project "test_data/maven/java/io/File"
64

7-
TODO Review these tests and sort into level 1 and level 2
8-
* Generate tests for "FileConstructorPath.test" in "target/classes/FileConstructorPath.class"
9-
* Generate tests for "FileConstructorPC.test" in "target/classes/FileConstructorPC.class"
10-
* Generate tests for "FileConstructorFC.test" in "target/classes/FileConstructorFC.class"
11-
* Generate tests for "FileConstructor.test" in "target/classes/FileConstructor.class"
12-
13-
* Verify tests in Maven project
14-
15-
## Level 1 Known Bugs - java.io.File
16-
17-
Tags: known-bug
18-
19-
* Setup Maven project "test_data/maven/java/io/File"
5+
## Level 1+ tests - java.io.File
206

21-
TG-1081/ TG-1976 Static fields not initialised in test
7+
Level 1 public fields
228
* Set class file "target/classes/L1Fields.class"
239
* Generate tests for "L1Fields.fieldSeparatorChar"
2410
* Generate tests for "L1Fields.fieldSeparator"
2511
* Generate tests for "L1Fields.fieldPathSeparatorChar"
2612
* Generate tests for "L1Fields.fieldPathSeparator"
2713
* Unset class file
2814

15+
TODO Review these tests and sort into level 1 and level 2
16+
* Generate tests for "FileConstructorPath.test" in "target/classes/FileConstructorPath.class"
17+
* Generate tests for "FileConstructorPC.test" in "target/classes/FileConstructorPC.class"
18+
* Generate tests for "FileConstructorFC.test" in "target/classes/FileConstructorFC.class"
19+
* Generate tests for "FileConstructor.test" in "target/classes/FileConstructor.class"
20+
2921
* Verify tests in Maven project
+6-17
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,42 @@
11
# java.lang.Class
22

3-
## toString
3+
* Setup Maven project "test_data/maven/java/lang/Class"
44

5-
Tags: support-v1
5+
## toString
66

7-
* Setup Maven project "test_data/maven/java/lang/Class"
87
* Generate tests for "GetClassToString.test" in "target/classes/GetClassToString.class"
98
* Generate tests for "IntegerGetClassToString.test" in "target/classes/IntegerGetClassToString.class"
10-
* Verify tests in Maven project
11-
12-
## toString_KNOWNBUG
13-
14-
Tags: support-v1, known-bug
15-
* Setup Maven project "test_data/maven/java/lang/Class"
16-
17-
TG-1081: Integer.TYPE is always (erroneously) initialized to null
189
* Generate tests for "IntegerTypeToString.test" in "target/classes/IntegerTypeToString.class"
1910
* Verify tests in Maven project
2011

2112
## getName
2213

23-
Tags: support-v1
24-
2514
diffblue/models-library#111
2615
* Working directory is "test_data/functional/java/lang/Class"
2716
* Run "getName_Pass.class", expecting exit code "0" and output "VERIFICATION SUCCESSFUL"
2817

2918
## isAssignableFrom
3019

31-
Tags: support-v1, known-bug
20+
Tags: known-bug
3221
* Working directory is "test_data/functional/java/lang/Class"
3322
* Run "isAssignableFrom_Pass.class", expecting exit code "0" and output "VERIFICATION SUCCESSFUL"
3423

3524
## getMethod
3625

37-
Tags: support-v1, known-bug
26+
Tags: known-bug
3827

3928
diffblue/models-library#112
4029
* Working directory is "test_data/functional/java/lang/Class"
4130
* Run "getMethod_Pass.class", expecting exit code "0" and output "VERIFICATION SUCCESSFUL"
4231

4332
## getClassLoader
4433

45-
Tags: support-v1, known-bug
34+
Tags: known-bug
4635
* Working directory is "test_data/functional/java/lang/Class"
4736
* Run "getClassLoader_Pass.class", expecting exit code "0" and output "VERIFICATION SUCCESSFUL"
4837

4938
## getSimpleName
5039

51-
Tags: support-v1, known-bug
40+
Tags: known-bug
5241
* Working directory is "test_data/functional/java/lang/Class"
5342
* Run "getSimpleName_Pass.class", expecting exit code "0" and output "VERIFICATION SUCCESSFUL"

0 commit comments

Comments
 (0)