tests/cache-restore: Do not look for dependency files outside `data`

When the default dependency path is used for cache distributors, they
are looking for the dependency file in the project's root (including the
source code), which leads to tests taking a significant amount of time,
especially on Windows runners.  We thus hit sporadic test failures.

Change the test cases such that dependency files are always searched for
inside of `__tests__/data`, ignoring the rest of the project.
This commit is contained in:
Oran Avraham 2022-10-14 15:32:30 +03:00
parent 727a4d2ef2
commit 95696f7028
No known key found for this signature in database
GPG Key ID: 93535690AF9131E5
1 changed files with 25 additions and 8 deletions

View File

@ -102,11 +102,17 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
describe('Restore dependencies', () => { describe('Restore dependencies', () => {
it.each([ it.each([
['pip', '3.8.12', undefined, requirementsHash, undefined],
[ [
'pip', 'pip',
'3.8.12', '3.8.12',
'**/requirements-linux.txt', '__tests__/data/**/requirements.txt',
requirementsHash,
undefined
],
[
'pip',
'3.8.12',
'__tests__/data/**/requirements-linux.txt',
requirementsLinuxHash, requirementsLinuxHash,
undefined undefined
], ],
@ -124,7 +130,13 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
requirementsHash, requirementsHash,
undefined undefined
], ],
['pipenv', '3.9.1', undefined, pipFileLockHash, undefined], [
'pipenv',
'3.9.1',
'__tests__/data/**/Pipfile.lock',
pipFileLockHash,
undefined
],
[ [
'pipenv', 'pipenv',
'3.9.12', '3.9.12',
@ -135,7 +147,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
[ [
'poetry', 'poetry',
'3.9.1', '3.9.1',
undefined, '__tests__/data/**/poetry.lock',
poetryLockHash, poetryLockHash,
[ [
'/Users/patrick/Library/Caches/pypoetry/virtualenvs', '/Users/patrick/Library/Caches/pypoetry/virtualenvs',
@ -208,8 +220,13 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
describe('Dependencies changed', () => { describe('Dependencies changed', () => {
it.each([ it.each([
['pip', '3.8.12', undefined, pipFileLockHash], ['pip', '3.8.12', '__tests__/data/**/requirements.txt', pipFileLockHash],
['pip', '3.8.12', '**/requirements-linux.txt', pipFileLockHash], [
'pip',
'3.8.12',
'__tests__/data/**/requirements-linux.txt',
pipFileLockHash
],
[ [
'pip', 'pip',
'3.8.12', '3.8.12',
@ -217,9 +234,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
pipFileLockHash pipFileLockHash
], ],
['pip', '3.8.12', '__tests__/data/requirements.txt', pipFileLockHash], ['pip', '3.8.12', '__tests__/data/requirements.txt', pipFileLockHash],
['pipenv', '3.9.1', undefined, requirementsHash], ['pipenv', '3.9.1', '__tests__/data/**/Pipfile.lock', requirementsHash],
['pipenv', '3.9.12', '__tests__/data/requirements.txt', requirementsHash], ['pipenv', '3.9.12', '__tests__/data/requirements.txt', requirementsHash],
['poetry', '3.9.1', undefined, requirementsHash] ['poetry', '3.9.1', '__tests__/data/**/poetry.lock', requirementsHash]
])( ])(
'restored dependencies for %s by primaryKey', 'restored dependencies for %s by primaryKey',
async (packageManager, pythonVersion, dependencyFile, fileHash) => { async (packageManager, pythonVersion, dependencyFile, fileHash) => {