The Trunk: Tests-ar.53.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Tests-ar.53.mcz

commits-2
Andreas Raab uploaded a new version of Tests to project The Trunk:
http://source.squeak.org/trunk/Tests-ar.53.mcz

==================== Summary ====================

Name: Tests-ar.53
Author: ar
Time: 2 March 2010, 8:22:31.19 pm
UUID: 485253c5-ac9d-364d-b950-bdac21bc4cd3
Ancestors: Tests-ar.52

Improved PackageDependencyTest now prints out dependencies upon failure so that we can see what the dependencies are and what we need to fix.

=============== Diff against Tests-ar.52 ===============

Item was changed:
+ ----- Method: PackageDependencyTest>>testPackage:dependsOnlyOn: (in category 'utilities') -----
- ----- Method: PackageDependencyTest>>testPackage:dependsOnlyOn: (in category 'tests') -----
  testPackage: pkgName dependsOnlyOn: pkgList
+ "Ensure that the package with the given name depends only on the packages in pkgList.
+ NOTE: If you use this for fixing dependencies, classDeps includes the classes
+ and users from the package(s) not declared as dependents. Basically, you need
+ to fix all the references in classDeps to make the test pass."
+ | classDeps pi pkgDeps |
+ classDeps := IdentityDictionary new.
- "Ensure that the package with the given name depends only on the packages in pkgList"
- | classes pi deps |
- classes := IdentitySet new.
  pi := PackageOrganizer default packageNamed: pkgName ifAbsent:[^self]. "unloaded"
+ pi classes do:[:pkgClass|
+ (classDeps at: (pkgClass superclass ifNil:[ProtoObject])
+ ifAbsentPut:[OrderedCollection new]) add: pkgClass name, ' superclass'.
+ ].
- pi classes do:[:pkgClass| classes add: (pkgClass superclass ifNil:[ProtoObject])].
  pi methods do:[:mref| | cm |
  cm := mref compiledMethod.
  1 to: cm numLiterals do:[:i| | lit |
  ((lit := cm literalAt: i) isVariableBinding
+ and:[lit value isBehavior]) ifTrue:[(classDeps at: lit value ifAbsentPut:[OrderedCollection new]) add: cm methodClass asString, '>>', cm selector]]].
+ pkgDeps := Dictionary new.
+ classDeps keys do:[:aClass| | pkg |
- and:[lit value isBehavior]) ifTrue:[classes add: lit value]]].
- deps := Dictionary new.
- classes do:[:aClass| | pkg |
  pkg := PackageOrganizer default packageOfClass: aClass ifNone:[nil].
  pkg ifNil:[
+ Transcript cr; show: 'WARNING: No package for ', aClass.
+ (classDeps removeKey: aClass) do:[:each| Transcript crtab; show: each].
- Transcript cr; show: 'WARNING: No package for ', pkg.
  ] ifNotNil:[
+ (pkgDeps at: pkg name ifAbsentPut:[OrderedCollection new]) add: aClass.
- (deps at: pkg name ifAbsentPut:[OrderedCollection new]) add: aClass.
  ].
  ].
+ (pkgDeps removeKey: pkgName ifAbsent:[#()])
+ do:[:aClass| classDeps removeKey: aClass ifAbsent:[]].
- deps removeKey: pkgName ifAbsent:[].
  pkgList do:[:pkg|
+ self assert: (pkgDeps includesKey: pkg).
+ (pkgDeps removeKey: pkg ifAbsent:[#()])
+ do:[:aClass| classDeps removeKey: aClass ifAbsent:[]].
- self assert: (deps includesKey: pkg).
- deps removeKey: pkg.
  ].
+ classDeps keysAndValuesDo:[:class :deps|
+ Transcript cr; show: class name, ' dependencies:'.
+ deps do:[:each| Transcript crtab; show: each].
+ ].
+ self assert: pkgDeps isEmpty.
+ !
- self assert: deps isEmpty.!