Skip to content

Commit

Permalink
tests/cache-restore: Do not look for dependency files outside data
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oranav committed Nov 7, 2022
1 parent 9f8e66a commit 3d21900
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions __tests__/cache-restore.test.ts
Expand Up @@ -101,11 +101,17 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py

describe('Restore dependencies', () => {
it.each([
['pip', '3.8.12', undefined, requirementsHash, undefined],
[
'pip',
'3.8.12',
'**/requirements-linux.txt',
'__tests__/data/**/requirements.txt',
requirementsHash,
undefined
],
[
'pip',
'3.8.12',
'__tests__/data/**/requirements-linux.txt',
requirementsLinuxHash,
undefined
],
Expand All @@ -123,7 +129,13 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
requirementsHash,
undefined
],
['pipenv', '3.9.1', undefined, pipFileLockHash, undefined],
[
'pipenv',
'3.9.1',
'__tests__/data/**/Pipfile.lock',
pipFileLockHash,
undefined
],
[
'pipenv',
'3.9.12',
Expand All @@ -134,7 +146,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
[
'poetry',
'3.9.1',
undefined,
'__tests__/data/**/poetry.lock',
poetryLockHash,
[
'/Users/patrick/Library/Caches/pypoetry/virtualenvs',
Expand Down Expand Up @@ -213,18 +225,23 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py

describe('Dependencies changed', () => {
it.each([
['pip', '3.8.12', undefined, pipFileLockHash],
['pip', '3.8.12', '**/requirements-linux.txt', pipFileLockHash],
['pip', '3.8.12', '__tests__/data/**/requirements.txt', pipFileLockHash],
[
'pip',
'3.8.12',
'__tests__/data/**/requirements-linux.txt',
pipFileLockHash
],
[
'pip',
'3.8.12',
'__tests__/data/requirements-linux.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],
['poetry', '3.9.1', undefined, requirementsHash]
['poetry', '3.9.1', '__tests__/data/**/poetry.lock', requirementsHash]
])(
'restored dependencies for %s by primaryKey',
async (packageManager, pythonVersion, dependencyFile, fileHash) => {
Expand Down

0 comments on commit 3d21900

Please sign in to comment.