Skip to content

Commit 3107085

Browse files
committed
Fix dependency resolution bug with * version as dependency
1 parent a6aadec commit 3107085

File tree

3 files changed

+119
-101
lines changed

3 files changed

+119
-101
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [0.10.5] - Unreleased
99

1010
### Added
11-
- #938 Added flag -export-python-deps to package command
11+
- #938: Added flag -export-python-deps to package command
1212
- #462: The `repo` command for repository configuration now supports secret input terminal mode for passwords with the `-password-stdin` flag
1313
- #935: Adding a generic JFrog Artifactory tarball resource processor for bundling artifact with a package and deploying it to a final location on install.
1414
- #950: Added support for listing installed Python packages using `list -python`, `list -py` and `list-installed -python`
1515
- #822: The CPF resource processor now supports system expressions and macros in CPF merge files
16-
- #578 Added functionality to record and display IPM history of install, uninstall, load, and update
16+
- #578: Added functionality to record and display IPM history of install, uninstall, load, and update
1717
- #961: Adding creation of a lock file for a module by using the `-create-lockfile` flag on install.
1818

1919
### Changed
@@ -27,7 +27,7 @@ lock contention by bypassing IRIS compiler.
2727
- Have better caching of results for module searches by collapsing search expressions (reducing expressions that are intersections).
2828

2929
### Removed
30-
- #938 Removed secret flag NewVersion handling in %Publish()
30+
- #938: Removed secret flag NewVersion handling in %Publish()
3131

3232
### Fixed
3333
- #943: The `load` command when used with a GitHub repository URL accepts a `branch` argument again

src/cls/IPM/Storage/Module.cls

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,9 @@ Method ProcessSingleDependencyIterative(
11211121
set searchCriteria.Name = pDep.Name
11221122
set searchExprStr = searchExpr.ToResolvedString()
11231123
set searchCriteria.VersionExpression = searchExprStr
1124+
if searchExprStr = "" {
1125+
set searchExprStr = "*"
1126+
}
11241127

11251128
if '$data(pRepoSearchCache(pDep.Name, searchExprStr), qualifiedReferences) {
11261129
// Cache miss so search

tests/integration_tests/Test/PM/Integration/DependencyResolution.cls

Lines changed: 113 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -4,146 +4,146 @@ Class Test.PM.Integration.DependencyResolution Extends Test.PM.Integration.Base
44
Method TestEverything()
55
{
66
#dim tModule As %IPM.Storage.Module
7-
New $Namespace
8-
Set tOrigNS = $Namespace
9-
Try {
10-
If '$$$AssertStatusOK(..Setup()) || ..SkipTest {
11-
Quit
7+
new $namespace
8+
set tOrigNS = $namespace
9+
try {
10+
if '$$$AssertStatusOK(..Setup()) || ..SkipTest {
11+
quit
1212
}
13-
14-
Do ..PublishModules()
15-
13+
14+
do ..PublishModules()
15+
1616
#; // Get annotations for local module XDATA blocks; put into array by module (XDATA) name.
1717
#; If '$$$AssertStatusOK(##class(%IPM.PackageManager.Developer.Annotation.Utils).ExtractAnnotations($classname(),.tAnnotationList)) {
1818
#; Quit
1919
#; }
20-
21-
Kill tAssertArray
22-
20+
21+
kill tAssertArray
22+
2323
#; For i=1:1:tAnnotationList.Count() {
2424
#; #dim tAnnotation As %IPM.PackageManager.Developer.Annotation
2525
#; Set tAnnotation = tAnnotationList.GetAt(i)
2626
#; If (tAnnotation.MemberType = "XData") {
2727
#; Set tAssertArray(tAnnotation.MemberName,$i(tAssertArray(tAnnotation.MemberName))) = $ListBuild(tAnnotation.Tag,$$$lcase(tAnnotation.Value))
2828
#; }
2929
#; }
30-
30+
3131
// In client namespace:
32-
Write !,!,!
33-
Set $Namespace = ..#CLIENTNS
34-
32+
write !,!,!
33+
set $namespace = ..#CLIENTNS
34+
3535
// Create a module referring to the module in the remote repository
36-
Set tKey = ""
37-
For {
38-
Set tKey = $Order(tAssertArray(tKey),1,tAssertCount)
39-
Quit:tKey=""
40-
36+
set tKey = ""
37+
for {
38+
set tKey = $order(tAssertArray(tKey),1,tAssertCount)
39+
quit:tKey=""
40+
4141
// Have modules fail independently.
42-
Try {
42+
try {
4343
// If we're loading a module with dependencies, clear out things that might have conflicting dependencies first.
44-
Do ..UtilUninstallAll()
45-
46-
Continue:'$$$AssertStatusOK(..ReadXDataToModule(tOrigNS,tKey,.tModule),"Loaded module in "_tKey_" XData block.")
47-
48-
Continue:'$$$AssertStatusOK(tModule.Lifecycle.Clean(),"Removed existing dependency versions for module.")
49-
50-
For i=1:1:tAssertCount {
51-
Set $ListBuild(tAssertType,tAssertValue) = tAssertArray(tKey,i)
52-
If (tAssertType '= "AssertInstalledBefore") {
53-
Continue
44+
do ..UtilUninstallAll()
45+
46+
continue:'$$$AssertStatusOK(..ReadXDataToModule(tOrigNS,tKey,.tModule),"Loaded module in "_tKey_" XData block.")
47+
48+
continue:'$$$AssertStatusOK(tModule.Lifecycle.Clean(),"Removed existing dependency versions for module.")
49+
50+
for i=1:1:tAssertCount {
51+
set $listbuild(tAssertType,tAssertValue) = tAssertArray(tKey,i)
52+
if (tAssertType '= "AssertInstalledBefore") {
53+
continue
5454
}
55-
56-
Set tQualRef = ##class(%IPM.Storage.QualifiedModuleInfo).%New()
57-
Set tQualRef.ServerName = ..#REGISTRYNAME
58-
Set tQualRef.Name = $Piece(tAssertValue," ",1)
59-
Set tQualRef.VersionString = $Piece(tAssertValue," ",2)
60-
Set tSC = ##class(%IPM.Utils.Module).LoadQualifiedReference(tQualRef)
61-
Do $$$AssertStatusOK(tSC,"Installed "_tAssertValue)
55+
56+
set tQualRef = ##class(%IPM.Storage.QualifiedModuleInfo).%New()
57+
set tQualRef.ServerName = ..#REGISTRYNAME
58+
set tQualRef.Name = $piece(tAssertValue," ",1)
59+
set tQualRef.VersionString = $piece(tAssertValue," ",2)
60+
set tSC = ##class(%IPM.Utils.Module).LoadQualifiedReference(tQualRef)
61+
do $$$AssertStatusOK(tSC,"Installed "_tAssertValue)
6262
}
63-
64-
Kill tDependencyGraph
65-
Set tGraphStatus = tModule.BuildDependencyGraph(.tDependencyGraph)
66-
67-
For i=1:1:tAssertCount {
68-
Set $ListBuild(tAssertType,tAssertValue) = tAssertArray(tKey,i)
69-
If (tAssertType = "AssertUnresolvable") {
70-
If '$$$AssertStatusNotOK(tGraphStatus,"Could not build dependency graph.") {
71-
Set tDepKey = ""
72-
For {
73-
Set tDepKey = $Order(tDependencyGraph(tDepKey),1,tData)
74-
Quit:tDepKey=""
75-
Do $$$LogMessage("Resolved as depending on "_tDepKey_" "_$ListGet(tData,3))
63+
64+
kill tDependencyGraph
65+
set tGraphStatus = tModule.BuildDependencyGraph(.tDependencyGraph)
66+
67+
for i=1:1:tAssertCount {
68+
set $listbuild(tAssertType,tAssertValue) = tAssertArray(tKey,i)
69+
if (tAssertType = "AssertUnresolvable") {
70+
if '$$$AssertStatusNotOK(tGraphStatus,"Could not build dependency graph.") {
71+
set tDepKey = ""
72+
for {
73+
set tDepKey = $order(tDependencyGraph(tDepKey),1,tData)
74+
quit:tDepKey=""
75+
do $$$LogMessage("Resolved as depending on "_tDepKey_" "_$listget(tData,3))
7676
}
7777
}
78-
Continue
79-
} ElseIf (i = 1) {
80-
Do $$$AssertStatusOK(tGraphStatus,"Could build dependency graph.")
78+
continue
79+
} elseif (i = 1) {
80+
do $$$AssertStatusOK(tGraphStatus,"Could build dependency graph.")
8181
}
82-
83-
If (tAssertType = "AssertDependsOn") {
84-
Set tModuleName = $Piece(tAssertValue," ")
85-
Set tVersion = $Piece(tAssertValue," ",2)
86-
If '$$$AssertEquals($ListGet(tDependencyGraph(tModuleName),3),tVersion,"Depends on "_tModuleName_" "_tVersion) {
87-
Do $$$LogMessage("Actually depended on "_tModuleName_" "_$ListGet(tDependencyGraph(tModuleName),3))
82+
83+
if (tAssertType = "AssertDependsOn") {
84+
set tModuleName = $piece(tAssertValue," ")
85+
set tVersion = $piece(tAssertValue," ",2)
86+
if '$$$AssertEquals($listget(tDependencyGraph(tModuleName),3),tVersion,"Depends on "_tModuleName_" "_tVersion) {
87+
do $$$LogMessage("Actually depended on "_tModuleName_" "_$listget(tDependencyGraph(tModuleName),3))
8888
}
89-
} ElseIf (tAssertType = "AssertCompileOK") {
90-
Do $$$AssertStatusOK(tModule.%Compile("-d"),"Module compiled successfully.")
91-
} ElseIf (tAssertType = "AssertCompileNotOK") {
92-
Set tSC = tModule.%Compile("-d")
93-
Do $$$AssertStatusNotOK(tSC,"Module compiled with error: "_$System.Status.GetErrorText(tSC))
89+
} elseif (tAssertType = "AssertCompileOK") {
90+
do $$$AssertStatusOK(tModule.%Compile("-d"),"Module compiled successfully.")
91+
} elseif (tAssertType = "AssertCompileNotOK") {
92+
set tSC = tModule.%Compile("-d")
93+
do $$$AssertStatusNotOK(tSC,"Module compiled with error: "_$system.Status.GetErrorText(tSC))
9494
}
9595
}
96-
97-
For i=1:1:tAssertCount {
98-
Set $ListBuild(tAssertType,tAssertValue) = tAssertArray(tKey,i)
99-
If (tAssertType '= "AssertInstalledAfter") && (tAssertType '= "AssertInstallFailedAfter") {
100-
Continue
96+
97+
for i=1:1:tAssertCount {
98+
set $listbuild(tAssertType,tAssertValue) = tAssertArray(tKey,i)
99+
if (tAssertType '= "AssertInstalledAfter") && (tAssertType '= "AssertInstallFailedAfter") {
100+
continue
101101
}
102-
103-
Set tQualRef = ##class(%IPM.Storage.QualifiedModuleInfo).%New()
104-
Set tQualRef.ServerName = ..#REGISTRYNAME
105-
Set tQualRef.Name = $Piece(tAssertValue," ",1)
106-
Set tQualRef.VersionString = $Piece(tAssertValue," ",2)
107-
Set tSC = ##class(%IPM.Utils.Module).LoadQualifiedReference(tQualRef)
108-
If (tAssertType = "AssertInstalledAfter") {
109-
Do $$$AssertStatusOK(tSC,"Installed "_tAssertValue)
110-
} Else {
111-
Do $$$AssertStatusNotOK(tSC,"Refused (correctly) to install "_tAssertValue)
102+
103+
set tQualRef = ##class(%IPM.Storage.QualifiedModuleInfo).%New()
104+
set tQualRef.ServerName = ..#REGISTRYNAME
105+
set tQualRef.Name = $piece(tAssertValue," ",1)
106+
set tQualRef.VersionString = $piece(tAssertValue," ",2)
107+
set tSC = ##class(%IPM.Utils.Module).LoadQualifiedReference(tQualRef)
108+
if (tAssertType = "AssertInstalledAfter") {
109+
do $$$AssertStatusOK(tSC,"Installed "_tAssertValue)
110+
} else {
111+
do $$$AssertStatusNotOK(tSC,"Refused (correctly) to install "_tAssertValue)
112112
}
113113
}
114-
} Catch e {
115-
Do $$$AssertStatusOK(e.AsStatus(),"An exception occurred.")
114+
} catch e {
115+
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred.")
116116
}
117117
}
118-
} Catch e {
119-
Do $$$AssertStatusOK(e.AsStatus(),"An exception occurred.")
118+
} catch e {
119+
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred.")
120120
}
121-
121+
122122
// Cleanup
123-
Set $Namespace = tOrigNS
124-
Do $$$AssertStatusOK(..TearDown())
123+
set $namespace = tOrigNS
124+
do $$$AssertStatusOK(..TearDown())
125125
}
126126

127127
Method PublishModules()
128128
{
129-
Set tOrigNS = $Namespace
129+
set tOrigNS = $namespace
130130
// Publish modules
131-
For i=1:1:11,100:1:103 {
131+
for i=1:1:11,100:1:104 {
132132
// If we're loading a module with dependencies, clear out things that might have conflicting dependencies first.
133-
Do ..UtilUninstallAll()
134-
135-
Quit:'$$$AssertStatusOK(..ReadXDataToModule(tOrigNS,"ServerModule"_i,.tModule),"Loaded module from XData block ServerModule"_i)
136-
133+
do ..UtilUninstallAll()
134+
135+
quit:'$$$AssertStatusOK(..ReadXDataToModule(tOrigNS,"ServerModule"_i,.tModule),"Loaded module from XData block ServerModule"_i)
136+
137137
// Publish module
138-
Do $$$AssertStatusOK(tModule.Lifecycle.Publish(),"Published "_tModule.Name_" "_tModule.VersionString)
138+
do $$$AssertStatusOK(tModule.Lifecycle.Publish(),"Published "_tModule.Name_" "_tModule.VersionString)
139139
}
140140
}
141141

142142
Method UtilUninstallAll()
143143
{
144-
For tModName = "Demo","HS.REST","HS.MDM","HS.JSON" {
145-
If ##class(%IPM.Storage.Module).NameExists($$$lcase(tModName)) {
146-
Do $$$AssertStatusOK(##class(%IPM.Storage.Module).Uninstall(tModName))
144+
for tModName = "Demo","HS.REST","HS.MDM","HS.JSON" {
145+
if ##class(%IPM.Storage.Module).NameExists($$$lcase(tModName)) {
146+
do $$$AssertStatusOK(##class(%IPM.Storage.Module).Uninstall(tModName))
147147
}
148148
}
149149
}
@@ -307,6 +307,21 @@ XData ServerModule103 [ XMLNamespace = "http://www.intersystems.com/PackageManag
307307
</Module>
308308
}
309309

310+
XData ServerModule104 [ XMLNamespace = "http://www.intersystems.com/PackageManager" ]
311+
{
312+
<?xml version="1.0"?>
313+
<Module>
314+
<Name>HS.REST</Name>
315+
<Version>1.0.4</Version>
316+
<Dependencies>
317+
<ModuleReference>
318+
<Name>HS.JSON</Name>
319+
<Version>*</Version>
320+
</ModuleReference>
321+
</Dependencies>
322+
</Module>
323+
}
324+
310325
/// @AssertDependsOn("HS.MDM 1.0.1")
311326
/// @AssertDependsOn("HS.JSON 1.1.4")
312327
/// @AssertCompileOK
@@ -446,7 +461,7 @@ XData LocalModule7 [ XMLNamespace = "http://www.intersystems.com/PackageManager"
446461
<Name>HS.MDM</Name>
447462
<Version>1.*</Version>
448463
</ModuleReference>
449-
464+
450465
<!-- The below ModuleReference is required in order for the HS.REST/HS.MDM combination above to be resolved. Ideally it would not be, but with the same result. -->
451466
<ModuleReference>
452467
<Name>HS.JSON</Name>

0 commit comments

Comments
 (0)