From 3d21900c052feafe7ed6a8bd4895c80467bb3bc5 Mon Sep 17 00:00:00 2001 From: Oran Avraham Date: Fri, 14 Oct 2022 15:32:30 +0300 Subject: [PATCH] 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. --- __tests__/cache-restore.test.ts | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/__tests__/cache-restore.test.ts b/__tests__/cache-restore.test.ts index d483b5bdc..6f0caf0f6 100644 --- a/__tests__/cache-restore.test.ts +++ b/__tests__/cache-restore.test.ts @@ -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 ], @@ -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', @@ -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', @@ -213,8 +225,13 @@ 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', @@ -222,9 +239,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py 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) => {