Skip to content

Commit 9245b87

Browse files
committed
Fix ipmDir expression in Invoke Args
1 parent e607d7f commit 9245b87

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ lock contention by bypassing IRIS compiler.
3838
- #937: Publishing a module with a `<WebApplication>` containing a `Path` no longer errors out
3939
- #957: Improved error messages for OS command execution. Now, when a command fails, the error message includes the full command and its return code. Also fixed argument separation for the Windows `attrib` command and removed misleading error handling for missing commands.
4040
- #999, #1000: Installing IPM cleans up stale mappings used in old versions of IPM
41+
- #1007: The `${ipmDir}` expression now works in the `<Arg>` of an `<Invoke>`
4142

4243
### Deprecated
4344
- #828: The `CheckStatus` flag for `<Invoke>` action has been deprecated. Default behavior is now to always check the status of the method if and only if the method signature returns %Library.Status

src/cls/IPM/Storage/Module.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,7 @@ Method %Evaluate(
17771777
set customParams("packagename") = ..Name
17781778
set customParams("version") = ..VersionString
17791779
set customParams("verbose") = +$get(pParams("Verbose"))
1780+
set customParams("ipmDir") = ##class(%Library.File).NormalizeDirectory($system.Util.DataDirectory() _ "ipm/" _ ..Name _ "/" _ ..VersionString)
17801781
set tAttrValue = ##class(%IPM.Utils.Module).%EvaluateMacro(tAttrValue)
17811782
set tAttrValue = ##class(%IPM.Storage.ModuleSetting.Default).EvaluateAttribute(tAttrValue,.customParams)
17821783
set attrValue = ##class(%IPM.Utils.Module).%EvaluateSystemExpression(tAttrValue)

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,37 @@ Method TestInvokeCheckStatus()
2424
}
2525
}
2626

27+
Method TestInvokeIpmDirExpression()
28+
{
29+
set sc = $$$OK
30+
try {
31+
// Clear any previous test data
32+
kill ^IRIS.Temp.Test.IpmDir
33+
34+
// Load module that invokes with ${ipmdir} argument
35+
set moduleDir = ..GetModuleDir("invoke-ipmdir")
36+
set sc = ##class(%IPM.Main).Shell("load -verbose " _ moduleDir)
37+
do $$$AssertStatusOK(sc, "Module loaded successfully")
38+
39+
// Verify the invoke was called and stored the path
40+
do $$$AssertTrue($data(^IRIS.Temp.Test.IpmDir), "Invoke.IpmDirTest method was called")
41+
42+
// Verify the path is correct
43+
set receivedPath = $get(^IRIS.Temp.Test.IpmDir)
44+
set expectedPath = ##class(%Library.File).NormalizeDirectory(
45+
$system.Util.DataDirectory() _ "ipm/invoke-ipmdir-test/1.0.0/")
46+
do $$$AssertEquals(receivedPath, expectedPath, "ipmDir expression correctly evaluated to: " _ expectedPath)
47+
48+
// Clean up - uninstall module
49+
set sc = ##class(%IPM.Main).Shell("uninstall -verbose invoke-ipmdir-test")
50+
do $$$AssertStatusOK(sc, "Module uninstalled successfully")
51+
52+
// Clean up temp global
53+
kill ^IRIS.Temp.Test.IpmDir
54+
55+
} catch ex {
56+
do $$$AssertStatusOK(ex.AsStatus(), "Exception in TestInvokeIpmDirExpression")
57+
}
58+
}
59+
2760
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Export generator="Cache" version="25">
3+
<Document name="invoke-ipmdir-test.ZPM">
4+
<Module>
5+
<Name>invoke-ipmdir-test</Name>
6+
<Version>1.0.0</Version>
7+
<Packaging>module</Packaging>
8+
<SourcesRoot>src</SourcesRoot>
9+
<Resource Name="Invoke.IpmDirTest.CLS"/>
10+
<Invoke Class="Invoke.IpmDirTest" Method="ValidateIpmDir">
11+
<Arg>${ipmdir}</Arg>
12+
</Invoke>
13+
</Module>
14+
</Document>
15+
</Export>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Class Invoke.IpmDirTest
2+
{
3+
4+
/// Validates that the passed ipmDir argument matches the expected path
5+
ClassMethod ValidateIpmDir(ipmDir As %String) As %Status
6+
{
7+
set sc = $$$OK
8+
try {
9+
// Calculate expected path
10+
set expectedDir = ##class(%Library.File).NormalizeDirectory($system.Util.DataDirectory() _ "ipm/invoke-ipmdir-test/1.0.0/")
11+
12+
// Normalize received path for comparison
13+
set normalizedIpmDir = ##class(%Library.File).NormalizeDirectory(ipmDir)
14+
15+
// Store in temp global for test validation
16+
set ^IRIS.Temp.Test.IpmDir = normalizedIpmDir
17+
18+
// Validate the path matches
19+
if (normalizedIpmDir '= expectedDir) {
20+
set sc = $$$ERROR($$$GeneralError, "${ipmDir} mismatch: expected '" _ expectedDir _ "' but got '" _ normalizedIpmDir _ "'")
21+
}
22+
} catch ex {
23+
set sc = ex.AsStatus()
24+
}
25+
quit sc
26+
}
27+
28+
}

0 commit comments

Comments
 (0)