Skip to content

Commit

Permalink
test: Added additional tests for impossible package pool optimisation…
Browse files Browse the repository at this point in the history
…, including scenarios not yet optimised
  • Loading branch information
driskell committed Dec 30, 2021
1 parent f572c9f commit ae7e8f3
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 0 deletions.
@@ -0,0 +1,58 @@
--TEST--
When filtering packages from the pool that cannot meet the fixed/locked requirements, ensure that the requirements for a package that is not required anywhere is not used to filter, as it will be ultimately be removed.
(Variant where the requirement is on a provided package, the locked third/pkg must not restrict the provider)
(NOTE: We are not optimising this scenario currently)

--REQUEST--
{
"require": {
"first/pkg": "*",
"second/pkg": "1.1.0",
"provider/pkg": "*"
},
"locked": [
{"name": "first/pkg", "version": "1.0.0", "require": {"second/pkg": "^1.0"}},
{"name": "second/pkg", "version": "1.0.0", "require": {"third/pkg": "1.0.0"}},
{"name": "third/pkg", "version": "1.0.0", "require": {"provided/pkg": "1.0.0"}},
{"name": "provider/pkg", "version": "1.0.0", "provide": {"provided/pkg": "1.0.0"}}
],
"allowList": [
"first/pkg",
"provider/pkg"
],
"allowTransitiveDeps": true
}

--FIXED--
[
]

--PACKAGE-REPOS--
[
[
{"name": "first/pkg", "version": "1.0.0", "require": {"second/pkg": "*"}},
{"name": "second/pkg", "version": "1.0.0", "require": {"third/pkg": "1.0.0"}},
{"name": "second/pkg", "version": "1.1.0", "require": {"provided/pkg": "2.0.0"}},
{"name": "third/pkg", "version": "1.0.0", "require": {"provided/pkg": "1.0.0"}},
{"name": "provider/pkg", "version": "1.0.0", "provide": {"provided/pkg": "1.0.0"}},
{"name": "provider/pkg", "version": "2.0.0", "provide": {"provided/pkg": "2.0.0"}}
]
]

--EXPECT--
[
"third/pkg-1.0.0.0 (locked)",
"first/pkg-1.0.0.0",
"provider/pkg-1.0.0.0",
"provider/pkg-2.0.0.0",
"second/pkg-1.1.0.0"
]

--EXPECT-OPTIMIZED--
[
"third/pkg-1.0.0.0 (locked)",
"first/pkg-1.0.0.0",
"provider/pkg-1.0.0.0",
"provider/pkg-2.0.0.0",
"second/pkg-1.1.0.0"
]
@@ -0,0 +1,57 @@
--TEST--
When filtering packages from the pool that cannot meet the fixed/locked requirements, ensure that the requirements for a package that is not required anywhere is not used to filter, as it will be ultimately be removed.
(Variant where the requirement is on a replaced package, the locked third/pkg must not restrict the replacer)
(NOTE: We are not optimising this scenario currently)

--REQUEST--
{
"require": {
"first/pkg": "*",
"second/pkg": "1.1.0",
"replacer/pkg": "*"
},
"locked": [
{"name": "first/pkg", "version": "1.0.0", "require": {"second/pkg": "^1.0"}},
{"name": "second/pkg", "version": "1.0.0", "require": {"third/pkg": "1.0.0"}},
{"name": "third/pkg", "version": "1.0.0", "require": {"replaced/pkg": "1.0.0"}},
{"name": "replacer/pkg", "version": "1.0.0", "replace": {"replaced/pkg": "1.0.0"}}
],
"allowList": [
"first/pkg"
],
"allowTransitiveDeps": true
}

--FIXED--
[
]

--PACKAGE-REPOS--
[
[
{"name": "first/pkg", "version": "1.0.0", "require": {"second/pkg": "*"}},
{"name": "second/pkg", "version": "1.0.0", "require": {"third/pkg": "1.0.0"}},
{"name": "second/pkg", "version": "1.1.0", "require": {"replaced/pkg": "2.0.0"}},
{"name": "third/pkg", "version": "1.0.0", "require": {"replaced/pkg": "1.0.0"}},
{"name": "replacer/pkg", "version": "1.0.0", "replace": {"replaced/pkg": "1.0.0"}},
{"name": "replacer/pkg", "version": "2.0.0", "replace": {"replaced/pkg": "2.0.0"}}
]
]

--EXPECT--
[
"third/pkg-1.0.0.0 (locked)",
"first/pkg-1.0.0.0",
"second/pkg-1.1.0.0",
"replacer/pkg-1.0.0.0",
"replacer/pkg-2.0.0.0"
]

--EXPECT-OPTIMIZED--
[
"third/pkg-1.0.0.0 (locked)",
"first/pkg-1.0.0.0",
"second/pkg-1.1.0.0",
"replacer/pkg-1.0.0.0",
"replacer/pkg-2.0.0.0"
]
@@ -1,5 +1,6 @@
--TEST--
When filtering packages from the pool that cannot meet the fixed/locked requirements, ensure that the requirements for a package that is not required anywhere is not used to filter, as it will be ultimately be removed.
(The locked third/pkg is not required by any package so will be removed, so should not restrict the versions of fourth/pkg)

--REQUEST--
{
Expand Down
@@ -0,0 +1,59 @@
--TEST--
Do not load packages into the pool that cannot meet the fixed/locked requirements, when a loose requirement is encountered during update
(Variant where requirement is on a provided package, the locked second package should restrict the provider to those that provide < 3.0.0)
(NOTE: We are not optimising this scenario currently)

--REQUEST--
{
"require": {
"first/pkg": "*",
"second/pkg": "*",
"provider/pkg": "*"
},
"locked": [
{"name": "first/pkg", "version": "1.0.0", "require": {"provided/pkg": "1.0.0"}},
{"name": "second/pkg", "version": "1.0.0", "require": {"provided/pkg": "< 3.0.0"}},
{"name": "provider/pkg", "version": "1.0.0", "provide": {"provided/pkg": "1.0.0"}}
],
"allowList": [
"first/pkg",
"provider/pkg"
],
"allowTransitiveDeps": true
}

--FIXED--
[
]

--PACKAGE-REPOS--
[
[
{"name": "first/pkg", "version": "1.0.0", "require": {"provided/pkg": "1.0.0"}},
{"name": "first/pkg", "version": "1.1.0", "require": {"provided/pkg": "2.0.0"}},
{"name": "second/pkg", "version": "1.0.0", "require": {"provided/pkg": "*"}},
{"name": "provider/pkg", "version": "1.0.0", "provide": {"provided/pkg": "1.0.0"}},
{"name": "provider/pkg", "version": "1.1.0", "provide": {"provided/pkg": "2.0.0"}},
{"name": "provider/pkg", "version": "1.2.0", "provide": {"provided/pkg": "3.0.0"}}
]
]

--EXPECT--
[
"second/pkg-1.0.0.0 (locked)",
"first/pkg-1.0.0.0",
"first/pkg-1.1.0.0",
"provider/pkg-1.0.0.0",
"provider/pkg-1.1.0.0",
"provider/pkg-1.2.0.0"
]

--EXPECT-OPTIMIZED--
[
"second/pkg-1.0.0.0 (locked)",
"first/pkg-1.0.0.0",
"first/pkg-1.1.0.0",
"provider/pkg-1.0.0.0",
"provider/pkg-1.1.0.0",
"provider/pkg-1.2.0.0"
]
@@ -0,0 +1,58 @@
--TEST--
Do not load packages into the pool that cannot meet the fixed/locked requirements, when a loose requirement is encountered during update
(Variant where requirement is on a replaced package, the locked second package should restrict the replacer to those that replace < 3.0.0)
(NOTE: We are not optimising this scenario currently)

--REQUEST--
{
"require": {
"first/pkg": "*",
"second/pkg": "*",
"replacer/pkg": "*"
},
"locked": [
{"name": "first/pkg", "version": "1.0.0", "require": {"replaced/pkg": "1.0.0"}},
{"name": "second/pkg", "version": "1.0.0", "require": {"replaced/pkg": "< 3.0.0"}},
{"name": "replacer/pkg", "version": "1.0.0", "replace": {"replaced/pkg": "1.0.0"}}
],
"allowList": [
"first/pkg"
],
"allowTransitiveDeps": true
}

--FIXED--
[
]

--PACKAGE-REPOS--
[
[
{"name": "first/pkg", "version": "1.0.0", "require": {"replaced/pkg": "1.0.0"}},
{"name": "first/pkg", "version": "1.1.0", "require": {"replaced/pkg": "2.0.0"}},
{"name": "second/pkg", "version": "1.0.0", "require": {"replaced/pkg": "*"}},
{"name": "replacer/pkg", "version": "1.0.0", "replace": {"replaced/pkg": "1.0.0"}},
{"name": "replacer/pkg", "version": "1.1.0", "replace": {"replaced/pkg": "2.0.0"}},
{"name": "replacer/pkg", "version": "1.2.0", "replace": {"replaced/pkg": "3.0.0"}}
]
]

--EXPECT--
[
"second/pkg-1.0.0.0 (locked)",
"first/pkg-1.0.0.0",
"first/pkg-1.1.0.0",
"replacer/pkg-1.0.0.0",
"replacer/pkg-1.1.0.0",
"replacer/pkg-1.2.0.0"
]

--EXPECT-OPTIMIZED--
[
"second/pkg-1.0.0.0 (locked)",
"first/pkg-1.0.0.0",
"first/pkg-1.1.0.0",
"replacer/pkg-1.0.0.0",
"replacer/pkg-1.1.0.0",
"replacer/pkg-1.2.0.0"
]
@@ -1,5 +1,6 @@
--TEST--
Do not load packages into the pool that cannot meet the fixed/locked requirements, when a loose requirement is encountered during update
(The locked root/req package should restrict dep/dep to only 2.* versions)

--REQUEST--
{
Expand Down

0 comments on commit ae7e8f3

Please sign in to comment.