@@ -3,43 +3,77 @@ Class Test.PM.Integration.BuildDependencyGraph Extends Test.PM.Integration.Base
33
44Method OnBeforeAllTests () As %Status
55{
6- kill ^IPMTest
7- set ^IPMTest (" BuildDependencyGraphCount" ) = 0
8-
96 set sc = ##class (%IPM.Main ).Shell (" repo -n build-dependency-graph -fs -path /home/irisowner/zpm/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-loop/" )
107 do $$$AssertStatusOK(sc , " Created build-dependency-graph repo successfully." )
11- return sc
8+
9+ // Reset counter to track BuildDependencyGraph() number of calls
10+ kill ^CacheTemp .BuildDependencyGraph ($job )
11+
12+ // Open method definition
13+ set methodDef = ##class (%Dictionary.MethodDefinition ).%OpenId (" %IPM.Storage.Module||BuildDependencyGraph" )
14+
15+ // Save original implementation so we can restore it
16+ set ^CacheTemp .BuildDependencyGraph (" orig" , $job ) = methodDef .Implementation .Read ()
17+
18+ // Build wrapped implementation
19+ set newImp = ##class (%Stream.TmpCharacter ).%New ()
20+
21+ do newImp .WriteLine (
22+ " set ^CacheTemp.BuildDependencyGraph($job)=$increment(^CacheTemp.BuildDependencyGraph($job))"
23+ )
24+
25+ // Rewind original and copy it
26+ do methodDef .Implementation .Rewind ()
27+ while 'methodDef .Implementation .AtEnd {
28+ do newImp .WriteLine (methodDef .Implementation .ReadLine ())
29+ }
30+
31+ // Replace implementation
32+ set methodDef .Implementation = newImp
33+ do methodDef .%Save ()
34+
35+ // Recompile the class
36+ do $system .OBJ .Compile (" %IPM.Storage.Module" , " cuk" )
37+ return $$$OK
1238}
1339
1440/// Counts the number of times that BuildDependencyGraph() gets invoked on test modules' installation to catch regressions
1541Method TestBuildDependencyGraphCount ()
1642{
17- // Install base module C
18- set moduleDir = ..GetModuleDir (" build-dependency-graph-loop/module-c" )
19- set status = ##class (%IPM.Main ).Shell (" load -verbose " _moduleDir )
20- do $$$AssertStatusOK(status ," Module module-c successfully installed" )
21-
22- // Install module A (which has dependencies B-snapshot-version and C) with hidden flags UpdateSnapshots and IgnoreInstalled
2343 kill params
24- set params (" UpdateSnapshots" ) = 1
2544 set params (" IgnoreInstalled" ) = 1
26- set params (" Verbose " ) = 1
45+ set params (" UpdateSnapshots " ) = 1
2746
28- set moduleDir = ..GetModuleDir (" build-dependency-graph-loop/module-a" )
29- set sc = ##class (%IPM.Utils.Module ).LoadNewModule (moduleDir , .params )
47+ write !, " TTTTT" , !
48+ zwrite $get (^CacheTemp .BuildDependencyGraph ($job ),0 )
49+
50+ set sc = ##class (%IPM.Utils.Module ).LoadNewModule (..GetModuleDir (" build-dependency-graph-loop/module-a" ), .params )
3051 do $$$AssertStatusOK(sc )
3152
32- // TODO: Note that this number 4 is just what the number of BuildDependencyGraphCount gets cut down to with the fix for #1011. Without #1011 the number is 5. This is just to ensure no regressions for the future, but will be an even lower number with #998.
33- do $$$AssertTrue(^IPMTest (" BuildDependencyGraphCount" ) <= 4 )
53+ write !, " SSSSSSS" , !
54+ zwrite $get (^CacheTemp .BuildDependencyGraph ($job ),0 )
55+
56+ do $$$AssertTrue($get (^CacheTemp .BuildDependencyGraph ($job ), 0 ) > 0 )
57+ do $$$AssertTrue($get (^CacheTemp .BuildDependencyGraph ($job ), 0 ) < 4 )
3458}
3559
3660Method OnAfterAllTests () As %Status
3761{
38- kill ^IPMTest
62+ set methodDef = ##class (%Dictionary.MethodDefinition ).%OpenId (" %IPM.Storage.Module||BuildDependencyGraph" )
63+
64+ if $data (^CacheTemp .BuildDependencyGraph (" orig" , $job )) {
65+ set imp = ##class (%Stream.TmpCharacter ).%New ()
66+ do imp .Write (^CacheTemp .BuildDependencyGraph (" orig" , $job ))
67+ set methodDef .Implementation = imp
68+ do methodDef .%Save ()
69+ do $system .OBJ .Compile (" %IPM.Storage.Module" , " cuk" )
70+ }
71+
72+ kill ^CacheTemp .BuildDependencyGraph ($job )
3973
4074 set sc = ##class (%IPM.Main ).Shell (" repo -delete -name build-dependency-graph" )
4175 do $$$AssertStatusOK(sc , " Deleted build-dependency-graph repo successfully." )
42- return sc
76+ return $$$OK
4377}
4478
4579}
0 commit comments