nested `version:imports:` cause trouble #111

Closed
dalehenrich opened this Issue Aug 29, 2012 · 0 comments

1 participant

@dalehenrich
Owner

The ConfigurationOfSeaside30 for version 3.1 started using nested imports quite extensively:

baseline310welcome: spec
    <version: '3.1.0-welcome-baseline' imports: #('3.1.0-common-baseline' '3.1.0-adaptors-baseline' '3.1.0-rss-baseline' '3.1.0-jqueryui-baseline' '3.1.0-ob-baseline' '3.1.0-comet-baseline')>
baseline310adaptors: spec
    <version: '3.1.0-adaptors-baseline' imports: #('3.1.0-pharo-baseline')>
baseline310common: spec
    <version: '3.1.0-common-baseline'>

The algorithm for resolving imports was terminating early...and the following fixes the bug:

collectAllVersionsFromVersionImportPragmasInto: versionMap using: executionBlock satisfiedPragmas: pragmaDict
    | defined done completed count |
    done := false.
    completed := IdentitySet new.
    count := 0.
    [ 
    count := count + 1.
    count > 10000
        ifTrue: [ self error: 'Apparent loop in import expansion' ].
    done ]
        whileFalse: [ 
            done := true.
            pragmaDict
                keysAndValuesDo: [ :versionString :pragmaColl | 
                    | versionSpec |
                    versionSpec := nil.
                    defined := false.
                    [ 
                    pragmaColl
                        do: [ :pragma | 
                            (completed includes: pragma)
                                ifFalse: [ 
                                    | imports |
                                    done := false.
                                    imports := pragma argumentAt: 2.
                                    imports
                                        detect: [ :importedVersion | (versionMap includesKey: importedVersion) not ]
                                        ifNone: [ 
                                            imports
                                                do: [ :importedVersion | 
                                                    | version |
                                                    (version := versionMap at: importedVersion ifAbsent: [  ]) ~~ nil
                                                        ifTrue: [ 
                                                            defined := true.
                                                            completed add: pragma.
                                                            versionSpec == nil
                                                                ifTrue: [ versionSpec := version spec copy ]
                                                                ifFalse: [ versionSpec := versionSpec mergeSpec: version spec copy ].
                                                            versionSpec versionString: versionString.
                                                            executionBlock value: versionSpec value: pragma ] ] ] ] ] ]
                        on: Error
                        do: [ :ex | 
                            (MetacelloErrorInProjectConstructionNotification versionString: versionSpec versionString exception: ex)
                                ifTrue: [ ^ ex pass ]
                                ifFalse: [ 
                                    self errorMap at: versionSpec versionString put: ex.
                                    done := true.
                                    defined := false ] ].
                    defined
                        ifTrue: [ 
                            | version importedVersions |
                            importedVersions := OrderedCollection new.
                            version := versionSpec createVersion.
                            pragmaColl do: [ :pragma | importedVersions addAll: (pragma argumentAt: 2) ].
                            version importedVersions: importedVersions.
                            self validateVersionString: versionString againstSpec: versionSpec.
                            versionMap at: versionSpec versionString put: version ].
                    self reset ] ]
@dalehenrich dalehenrich pushed a commit that referenced this issue Sep 5, 2012
Dale Henrichs Issue #111: remove project refs ... still fails b8906aa
@dalehenrich dalehenrich pushed a commit that referenced this issue Sep 5, 2012
Dale Henrichs Issue #111: add test case bc46403
@dalehenrich dalehenrich pushed a commit that referenced this issue Sep 6, 2012
Dale Henrichs Merge branch 'master' into issue_111: Issue #111 ... 9da98ae
@dalehenrich dalehenrich pushed a commit that referenced this issue Sep 6, 2012
Dale Henrichs Issue #111: proposed bugfix
correctly process nested import statements
  original algorithm would only process one of the imports in the list
  before marking the version as complete ... can't process a version
  until all imports are defined ...
  implemented rudimentary loop detection
remove a Grease Core Reference in test configuration
66ba1b4
@dalehenrich dalehenrich closed this Sep 6, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment