@@ -4,146 +4,146 @@ Class Test.PM.Integration.DependencyResolution Extends Test.PM.Integration.Base
44Method 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
127127Method 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
142142Method 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