diff --git a/CHANGELOG.md b/CHANGELOG.md index 603408d3..8521b96f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - #870: When running tests for just a single suite or class, will only load and compile the relevant classes instead of all the tests - #843: Optionally include tests when packaging using either the `-include-tests` flag or `1` in module.xml - #1079: Add semantic sorting and shortcuts to list-installed +- #1152: Adds information about scoped dependencies in the output array of BuildDependencyGraph() ### Fixed - #1175: Fix issue parsing version for packages with both deployed and non-deployed versions diff --git a/src/cls/IPM/Storage/Module.cls b/src/cls/IPM/Storage/Module.cls index 6ba119bb..5d856329 100644 --- a/src/cls/IPM/Storage/Module.cls +++ b/src/cls/IPM/Storage/Module.cls @@ -879,6 +879,8 @@ ClassMethod HasScope( ///
  • Depth in the dependency tree (1 for direct dependencies, 2 for transitive, etc.)
  • ///
  • Repository from which the module will be obtained (empty if already installed)
  • ///
  • Version string of the module to be installed
  • +///
  • Display name of the module
  • +///
  • Scope of the module, or empty string if the dependency is not scoped
  • /// ///

    /// Parameters:
    @@ -1142,7 +1144,7 @@ Method ProcessSingleDependencyIterative( localObj.Version.Satisfies(searchExpr) && ((version = "") || (version = localObj.VersionString)) if installedVersionValid && '(localObj.Version.IsSnapshot() && pForceSnapshotReload) { - set pDependencyGraph(pDep.Name) = $listbuild(pDepth,"",localObj.VersionString,pDep.DisplayName) + set pDependencyGraph(pDep.Name) = $listbuild(pDepth,"",localObj.VersionString,pDep.DisplayName,pDep.Scope) set pDependencyGraph(pDep.Name,pParentInfo) = pDep.VersionString // Add to work queue for next depth @@ -1204,7 +1206,7 @@ Method ProcessSingleDependencyIterative( } set pDependencyGraph(pDep.Name) = $listbuild( - pDepth, qualifiedReference.ServerName, moduleObj.VersionString, qualifiedReference.Deployed, qualifiedReference.PlatformVersion,pDep.DisplayName + pDepth, qualifiedReference.ServerName, moduleObj.VersionString, qualifiedReference.Deployed, qualifiedReference.PlatformVersion,pDep.DisplayName,pDep.Scope ) set pDependencyGraph(pDep.Name,pParentInfo) = pDep.VersionString @@ -1239,7 +1241,7 @@ Method ProcessSingleDependencyIterative( // occurs if needed. set depth = $select(previousDepth=0:pDepth,previousDepth>pDepth:previousDepth,1:pDepth) set dependencyGraph(pDep.Name) = $listbuild( - depth,qualifiedReference.ServerName,moduleObj.VersionString,pDep.DisplayName + depth,qualifiedReference.ServerName,moduleObj.VersionString,pDep.DisplayName,pDep.Scope ) set dependencyGraph(pDep.Name,pParentInfo) = pDep.VersionString diff --git a/tests/integration_tests/Test/PM/Integration/BuildDependencyGraphScopedDeps.cls b/tests/integration_tests/Test/PM/Integration/BuildDependencyGraphScopedDeps.cls new file mode 100644 index 00000000..0221dba9 --- /dev/null +++ b/tests/integration_tests/Test/PM/Integration/BuildDependencyGraphScopedDeps.cls @@ -0,0 +1,56 @@ +Class Test.PM.Integration.BuildDependencyGraphScopedDeps Extends Test.PM.Integration.Base +{ + +Parameter REPONAME = "build-dependency-graph-scoped-dep"; + +Parameter MODNAME = "module-a"; + +Property RepoPath As %String; + +Method OnBeforeAllTests() As %Status +{ + // Set up the repo path - use GetModuleDir utility + set ..RepoPath = ..GetModuleDir(..#REPONAME) + + // Create filesystem repo pointing to test data + set sc = ##class(%IPM.Main).Shell("repo -n "_..#REPONAME_" -fs -path "_..RepoPath) + do $$$AssertStatusOK(sc,"Created"_..#REPONAME_"repo successfully.") + quit sc +} + +Method OnAfterAllTests() As %Status +{ + // Remove test repository + set sc = ##class(%IPM.Main).Shell("repo -delete -name "_..#REPONAME) + do $$$AssertStatusOK(sc,"Deleted "_..#REPONAME_"repo successfully.") + quit sc +} + +/// BuildDependencyGraph should include scope information for scoped transitive dependencies +Method TestDependencyGraphScopedDependency() +{ + do $$$AssertStatusOK(##class(%IPM.Utils.Module).LoadModuleFromDirectory(..RepoPath_..#MODNAME), "Successfully loaded module from directory.") + set module = ##class(%IPM.Storage.Module).NameOpen(..#MODNAME,,.sc) + do $$$AssertStatusOK(sc, "Successfully opened module object.") + + // Expected dependencyGraph format: dependencyGraph() = $listbuild(, , , , ) + set scopes = $listbuild("test", "verify") + set sc = module.BuildDependencyGraph(.dependencyGraph, , , ,scopes) + do $$$AssertStatusOK(sc, "BuildDependencyGraph() call was successful.") + + // Check non-scoped dependency + do $$$AssertTrue($data(dependencyGraph("module-b"))) + set $listbuild(,,,,moduleBScope) = dependencyGraph("module-b") + do $$$AssertEquals(moduleBScope, "", "module-b scope successfully checked to be empty.") + + // Check scoped dependencies + do $$$AssertTrue($data(dependencyGraph("module-c"))) + set $listbuild(,,,,moduleCScope) = dependencyGraph("module-c") + do $$$AssertEquals(moduleCScope, "test", "module-c scope successfully checked to be 'test'.") + + do $$$AssertTrue($data(dependencyGraph("module-d"))) + set $listbuild(,,,,moduleDScope) = dependencyGraph("module-d") + do $$$AssertEquals(moduleDScope, "verify", "module-d scope successfully checked to be 'verify'.") +} + +} diff --git a/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-a/module.xml b/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-a/module.xml new file mode 100644 index 00000000..05df32c5 --- /dev/null +++ b/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-a/module.xml @@ -0,0 +1,15 @@ + + + + + module-a + 1.0.0 + + + module-b + ^2.0.0 + + + + + diff --git a/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-b/module.xml b/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-b/module.xml new file mode 100644 index 00000000..011c8ce5 --- /dev/null +++ b/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-b/module.xml @@ -0,0 +1,19 @@ + + + + + module-b + 2.0.0 + + + module-c + ^3.0.0 + + + module-d + ^4.0.0 + + + + + diff --git a/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-c/module.xml b/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-c/module.xml new file mode 100644 index 00000000..322ddb92 --- /dev/null +++ b/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-c/module.xml @@ -0,0 +1,9 @@ + + + + + module-c + 3.0.0 + + + diff --git a/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-d/module.xml b/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-d/module.xml new file mode 100644 index 00000000..8da6b6ef --- /dev/null +++ b/tests/integration_tests/Test/PM/Integration/_data/build-dependency-graph-scoped-dep/module-d/module.xml @@ -0,0 +1,9 @@ + + + + + module-d + 4.0.0 + + +