From a0997e206f6fca084e50159e9f5a394a9599eaad Mon Sep 17 00:00:00 2001 From: Marcin Martinez Date: Fri, 11 Feb 2022 01:57:08 +0100 Subject: [PATCH 1/6] fix: Convert deprecated CLI arguments to env vars in tests --- test.js | 16 +++++++++++++++- tests/base/serverless.yml | 22 +++++++++++----------- tests/individually/serverless.yml | 2 +- tests/pipenv/serverless.yml | 8 ++++---- tests/poetry/serverless.yml | 8 ++++---- 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/test.js b/test.js index ccd1920c..d543264b 100644 --- a/test.js +++ b/test.js @@ -22,12 +22,25 @@ const initialWorkingDir = process.cwd(); const mkCommand = (cmd) => (args, options = {}) => { + let envVars = { SLS_DEBUG: 't' }; + if (cmd == 'sls') { + // convert deprecated CLI arguments to env vars + const argsCopy = [...args]; + args = []; + for (let i = 0; i < argsCopy.length; i++) { + if (argsCopy[i].includes('--')) { + envVars[argsCopy[i].slice(2)] = argsCopy[i].split('=')[1]; + } else { + args.push(argsCopy[i]); + } + } + } const { error, stdout, stderr, status } = crossSpawn.sync( cmd, args, Object.assign( { - env: Object.assign({}, process.env, { SLS_DEBUG: 't' }), + env: Object.assign({}, process.env, envVars), }, options ) @@ -45,6 +58,7 @@ const mkCommand = } return stdout && stdout.toString().trim(); }; + const sls = mkCommand('sls'); const git = mkCommand('git'); const npm = mkCommand('npm'); diff --git a/tests/base/serverless.yml b/tests/base/serverless.yml index 0b360e9b..37238158 100644 --- a/tests/base/serverless.yml +++ b/tests/base/serverless.yml @@ -2,22 +2,22 @@ service: sls-py-req-test provider: name: aws - runtime: ${opt:runtime, 'python3.6'} + runtime: ${env:runtime, 'python3.6'} plugins: - serverless-python-requirements custom: pythonRequirements: - zip: ${opt:zip, self:custom.defaults.zip} - dockerizePip: ${opt:dockerizePip, self:custom.defaults.dockerizePip} - slim: ${opt:slim, self:custom.defaults.slim} + zip: ${env:zip, self:custom.defaults.zip} + dockerizePip: ${env:dockerizePip, self:custom.defaults.dockerizePip} + slim: ${env:slim, self:custom.defaults.slim} slimPatterns: ${file(./slimPatterns.yml):slimPatterns, self:custom.defaults.slimPatterns} - slimPatternsAppendDefaults: ${opt:slimPatternsAppendDefaults, self:custom.defaults.slimPatternsAppendDefaults} - vendor: ${opt:vendor, ''} - fileName: ${opt:fileName, 'requirements.txt'} - useStaticCache: ${opt:useStaticCache, self:custom.defaults.useStaticCache} - useDownloadCache: ${opt:useDownloadCache, self:custom.defaults.useDownloadCache} - cacheLocation: ${opt:cacheLocation, ''} + slimPatternsAppendDefaults: ${env:slimPatternsAppendDefaults, self:custom.defaults.slimPatternsAppendDefaults} + vendor: ${env:vendor, ''} + fileName: ${env:fileName, 'requirements.txt'} + useStaticCache: ${env:useStaticCache, self:custom.defaults.useStaticCache} + useDownloadCache: ${env:useDownloadCache, self:custom.defaults.useDownloadCache} + cacheLocation: ${env:cacheLocation, ''} defaults: slim: false slimPatterns: false @@ -29,7 +29,7 @@ custom: useDownloadCache: true package: - individually: ${opt:individually, self:custom.defaults.individually} + individually: ${env:individually, self:custom.defaults.individually} patterns: - '!**/*' - 'handler.py' diff --git a/tests/individually/serverless.yml b/tests/individually/serverless.yml index 121bd89d..a83ac7e0 100644 --- a/tests/individually/serverless.yml +++ b/tests/individually/serverless.yml @@ -10,7 +10,7 @@ package: - '!node_modules/**' custom: pythonRequirements: - dockerizePip: ${opt:dockerizePip, self:custom.defaults.dockerizePip} + dockerizePip: ${env:dockerizePip, self:custom.defaults.dockerizePip} defaults: dockerizePip: false diff --git a/tests/pipenv/serverless.yml b/tests/pipenv/serverless.yml index dd93e290..4b343bfc 100644 --- a/tests/pipenv/serverless.yml +++ b/tests/pipenv/serverless.yml @@ -8,11 +8,11 @@ plugins: - serverless-python-requirements custom: pythonRequirements: - zip: ${opt:zip, self:custom.defaults.zip} - slim: ${opt:slim, self:custom.defaults.slim} + zip: ${env:zip, self:custom.defaults.zip} + slim: ${env:slim, self:custom.defaults.slim} slimPatterns: ${file(./slimPatterns.yml):slimPatterns, self:custom.defaults.slimPatterns} - slimPatternsAppendDefaults: ${opt:slimPatternsAppendDefaults, self:custom.defaults.slimPatternsAppendDefaults} - dockerizePip: ${opt:dockerizePip, self:custom.defaults.dockerizePip} + slimPatternsAppendDefaults: ${env:slimPatternsAppendDefaults, self:custom.defaults.slimPatternsAppendDefaults} + dockerizePip: ${env:dockerizePip, self:custom.defaults.dockerizePip} defaults: zip: false slimPatterns: false diff --git a/tests/poetry/serverless.yml b/tests/poetry/serverless.yml index dd93e290..4b343bfc 100644 --- a/tests/poetry/serverless.yml +++ b/tests/poetry/serverless.yml @@ -8,11 +8,11 @@ plugins: - serverless-python-requirements custom: pythonRequirements: - zip: ${opt:zip, self:custom.defaults.zip} - slim: ${opt:slim, self:custom.defaults.slim} + zip: ${env:zip, self:custom.defaults.zip} + slim: ${env:slim, self:custom.defaults.slim} slimPatterns: ${file(./slimPatterns.yml):slimPatterns, self:custom.defaults.slimPatterns} - slimPatternsAppendDefaults: ${opt:slimPatternsAppendDefaults, self:custom.defaults.slimPatternsAppendDefaults} - dockerizePip: ${opt:dockerizePip, self:custom.defaults.dockerizePip} + slimPatternsAppendDefaults: ${env:slimPatternsAppendDefaults, self:custom.defaults.slimPatternsAppendDefaults} + dockerizePip: ${env:dockerizePip, self:custom.defaults.dockerizePip} defaults: zip: false slimPatterns: false From f14e1682e16a7cfdd7116f0d170382fcd7861743 Mon Sep 17 00:00:00 2001 From: Marcin Martinez Date: Fri, 11 Feb 2022 11:07:31 +0100 Subject: [PATCH 2/6] Fix argument parsing --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index d543264b..22cf73c0 100644 --- a/test.js +++ b/test.js @@ -29,7 +29,7 @@ const mkCommand = args = []; for (let i = 0; i < argsCopy.length; i++) { if (argsCopy[i].includes('--')) { - envVars[argsCopy[i].slice(2)] = argsCopy[i].split('=')[1]; + envVars[argsCopy[i].slice(2).split('=')[0]] = argsCopy[i].split('=')[1]; } else { args.push(argsCopy[i]); } From 661c1276958b16f88874904cf93e06a9afe2a4d9 Mon Sep 17 00:00:00 2001 From: Marcin Martinez Date: Fri, 11 Feb 2022 18:46:35 +0100 Subject: [PATCH 3/6] Prettify test.js --- test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test.js b/test.js index 22cf73c0..eabf70bc 100644 --- a/test.js +++ b/test.js @@ -29,7 +29,8 @@ const mkCommand = args = []; for (let i = 0; i < argsCopy.length; i++) { if (argsCopy[i].includes('--')) { - envVars[argsCopy[i].slice(2).split('=')[0]] = argsCopy[i].split('=')[1]; + envVars[argsCopy[i].slice(2).split('=')[0]] = + argsCopy[i].split('=')[1]; } else { args.push(argsCopy[i]); } From 5aeee22b173069a2e5a3256f824218e5248a28c8 Mon Sep 17 00:00:00 2001 From: Marcin Martinez Date: Sat, 12 Feb 2022 13:06:02 +0100 Subject: [PATCH 4/6] Parse sls commands to input deprecated arguments as options --- test.js | 345 +++++++++++++++++++++++--------------------------------- 1 file changed, 143 insertions(+), 202 deletions(-) diff --git a/test.js b/test.js index eabf70bc..e58434c4 100644 --- a/test.js +++ b/test.js @@ -22,30 +22,9 @@ const initialWorkingDir = process.cwd(); const mkCommand = (cmd) => (args, options = {}) => { - let envVars = { SLS_DEBUG: 't' }; - if (cmd == 'sls') { - // convert deprecated CLI arguments to env vars - const argsCopy = [...args]; - args = []; - for (let i = 0; i < argsCopy.length; i++) { - if (argsCopy[i].includes('--')) { - envVars[argsCopy[i].slice(2).split('=')[0]] = - argsCopy[i].split('=')[1]; - } else { - args.push(argsCopy[i]); - } - } - } - const { error, stdout, stderr, status } = crossSpawn.sync( - cmd, - args, - Object.assign( - { - env: Object.assign({}, process.env, envVars), - }, - options - ) - ); + const { error, stdout, stderr, status } = crossSpawn.sync(cmd, args, { + env: Object.assign({ SLS_DEBUG: 't' }, process.env, options), + }); if (error) { console.error(`Error running: ${quote([cmd, ...args])}`); // eslint-disable-line no-console throw error; @@ -220,7 +199,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -235,9 +214,9 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const fileHash = sha256File('.serverless/sls-py-req-test.zip'); - sls(['package']); + sls(['package'], {}); t.equal( sha256File('.serverless/sls-py-req-test.zip'), fileHash, @@ -254,7 +233,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([`--pythonBin=${getPythonBin(3)}`, 'package']); + sls(['package'], { pythonBin: getPythonBin(3) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -269,11 +248,10 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(3)}`, - '--fileName=requirements-w-hashes.txt', - 'package', - ]); + sls(['package'], { + fileName: 'requirements-w-hashes.txt', + pythonBin: getPythonBin(3), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.end(); @@ -287,11 +265,10 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(3)}`, - '--fileName=requirements-w-nested.txt', - 'package', - ]); + sls(['package'], { + fileName: 'requirements-w-nested.txt', + pythonBin: getPythonBin(3), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -306,7 +283,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([`--pythonBin=${getPythonBin(3)}`, '--zip=true', 'package']); + sls(['package'], { zip: 'true', pythonBin: getPythonBin(3) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -331,7 +308,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([`--pythonBin=${getPythonBin(3)}`, '--slim=true', 'package']); + sls(['package'], { slim: 'true', pythonBin: getPythonBin(3) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -356,7 +333,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--slim=true', 'package']); + sls(['package'], { slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -387,7 +364,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls([`--pythonBin=${getPythonBin(3)}`, 'package']); + sls(['package'], { pythonBin: getPythonBin(3) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.false(zipfiles.includes(`bottle.py`), 'bottle is NOT packaged'); @@ -402,11 +379,10 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(3)}`, - '--fileName=requirements-w-editable.txt', - 'package', - ]); + sls(['package'], { + fileName: 'requirements-w-editable.txt', + pythonBin: getPythonBin(3), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); t.true( @@ -424,8 +400,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', 'package']); - + sls(['package'], { dockerizePip: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -440,7 +415,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', '--slim=true', 'package']); + sls(['package'], { dockerizePip: 'true', slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -465,7 +440,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', '--slim=true', 'package']); + sls(['package'], { dockerizePip: 'true', slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -489,8 +464,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', '--zip=true', 'package']); - + sls(['package'], { dockerizePip: 'true', zip: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( '.serverless/sls-py-req-test.zip' @@ -522,8 +496,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', '--zip=true', '--slim=true', 'package']); - + sls(['package'], { dockerizePip: 'true', zip: 'true', slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( '.serverless/sls-py-req-test.zip' @@ -555,7 +528,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([`--pythonBin=${getPythonBin(2)}`, '--runtime=python2.7', 'package']); + sls(['package'], { runtime: 'python2.7', pythonBin: getPythonBin(2) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -570,12 +543,11 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(2)}`, - '--runtime=python2.7', - '--slim=true', - 'package', - ]); + sls(['package'], { + runtime: 'python2.7', + slim: 'true', + pythonBin: getPythonBin(2), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -599,12 +571,11 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(2)}`, - '--runtime=python2.7', - '--zip=true', - 'package', - ]); + sls(['package'], { + runtime: 'python2.7', + zip: 'true', + pythonBin: getPythonBin(2), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -631,13 +602,12 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(2)}`, - '--runtime=python2.7', - '--dockerizePip=true', - '--slim=true', - 'package', - ]); + sls(['package'], { + runtime: 'python2.7', + dockerizePip: 'true', + slim: 'true', + pythonBin: getPythonBin(2), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -668,7 +638,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls([`--pythonBin=${getPythonBin(2)}`, '--runtime=python2.7', 'package']); + sls(['package'], { runtime: 'python2.7', pythonBin: getPythonBin(2) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.false(zipfiles.includes(`bottle.py`), 'bottle is NOT packaged'); @@ -683,14 +653,12 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(2)}`, - '--runtime=python2.7', - '--dockerizePip=true', - '--zip=true', - 'package', - ]); - + sls(['package'], { + runtime: 'python2.7', + dockerizePip: 'true', + zip: 'true', + pythonBin: getPythonBin(2), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( '.serverless/sls-py-req-test.zip' @@ -722,15 +690,13 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(2)}`, - '--runtime=python2.7', - '--dockerizePip=true', - '--zip=true', - '--slim=true', - 'package', - ]); - + sls(['package'], { + runtime: 'python2.7', + dockerizePip: 'true', + zip: 'true', + slim: 'true', + pythonBin: getPythonBin(2), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( '.serverless/sls-py-req-test.zip' @@ -762,13 +728,11 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(2)}`, - '--runtime=python2.7', - '--dockerizePip=true', - 'package', - ]); - + sls(['package'], { + runtime: 'python2.7', + dockerizePip: 'true', + pythonBin: getPythonBin(2), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -783,13 +747,12 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(2)}`, - '--runtime=python2.7', - '--dockerizePip=true', - '--slim=true', - 'package', - ]); + sls(['package'], { + runtime: 'python2.7', + dockerizePip: 'true', + slim: 'true', + pythonBin: getPythonBin(2), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -815,13 +778,12 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - `--pythonBin=${getPythonBin(2)}`, - '--runtime=python2.7', - '--dockerizePip=true', - '--slim=true', - 'package', - ]); + sls(['package'], { + runtime: 'python2.7', + dockerizePip: 'true', + slim: 'true', + pythonBin: getPythonBin(2), + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -845,7 +807,7 @@ test( process.chdir('tests/pipenv'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -864,7 +826,7 @@ test( process.chdir('tests/pipenv'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--slim=true', 'package']); + sls(['package'], { slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -890,7 +852,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--slim=true', 'package']); + sls(['package'], { slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -914,7 +876,7 @@ test( process.chdir('tests/pipenv'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([`--pythonBin=${getPythonBin(3)}`, '--zip=true', 'package']); + sls(['package'], { zip: 'true', pythonBin: getPythonBin(3) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -946,7 +908,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls(['package']); + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.false(zipfiles.includes(`bottle.py`), 'bottle is NOT packaged'); @@ -961,7 +923,7 @@ test( process.chdir('tests/non_build_pyproject'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -976,7 +938,7 @@ test( process.chdir('tests/non_poetry_pyproject'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`handler.py`), 'handler is packaged'); t.end(); @@ -990,7 +952,7 @@ test( process.chdir('tests/poetry'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`bottle.py`), 'bottle is packaged'); @@ -1006,7 +968,7 @@ test( process.chdir('tests/poetry'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--slim=true', 'package']); + sls(['package'], { slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -1032,7 +994,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--slim=true', 'package']); + sls(['package'], { slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -1056,7 +1018,7 @@ test( process.chdir('tests/poetry'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([`--pythonBin=${getPythonBin(3)}`, '--zip=true', 'package']); + sls(['package'], { zip: 'true', pythonBin: getPythonBin(3) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -1088,7 +1050,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls(['package']); + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.false(zipfiles.includes(`bottle.py`), 'bottle is NOT packaged'); @@ -1105,7 +1067,7 @@ test( npm(['i', path]); perl(['-p', '-i.bak', '-e', 's/include://', 'serverless.yml']); perl(['-p', '-i.bak', '-e', 's/^.*handler.py.*$//', 'serverless.yml']); - sls(['--zip=true', 'package']); + sls(['package'], { zip: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -1130,7 +1092,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([`--vendor=./vendor`, 'package']); + sls(['package'], { vendor: './vendor' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -1160,8 +1122,7 @@ test( ]); writeFileSync(`foobar`, ''); chmodSync(`foobar`, perm); - sls(['--vendor=./vendor', 'package']); - + sls(['package'], { vendor: './vendor' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -1199,7 +1160,7 @@ test( process.chdir('tests/base with a space'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -1215,7 +1176,7 @@ test( process.chdir('tests/base with a space'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', 'package']); + sls(['package'], { dockerizePip: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -1231,7 +1192,7 @@ test( const path = npm(['pack', '../..']); writeFileSync('puck', 'requests'); npm(['i', path]); - sls(['--fileName=puck', 'package']); + sls(['package'], { fileName: 'puck' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes(`requests${sep}__init__.py`), @@ -1263,7 +1224,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls([`--pythonBin=${getPythonBin(3)}`, '--zip=true', 'package']); + sls(['package'], { zip: 'true', pythonBin: getPythonBin(3) }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( '.serverless/sls-py-req-test.zip' @@ -1300,8 +1261,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--slim=true', '--slimPatternsAppendDefaults=false', 'package']); - + sls(['package'], { slim: 'true', slimPatternsAppendDefaults: 'false' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1325,13 +1285,11 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - '--dockerizePip=true', - '--slim=true', - '--slimPatternsAppendDefaults=false', - 'package', - ]); - + sls(['package'], { + dockerizePip: 'true', + slim: 'true', + slimPatternsAppendDefaults: 'false', + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1355,13 +1313,11 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - '--runtime=python2.7', - '--slim=true', - '--slimPatternsAppendDefaults=false', - 'package', - ]); - + sls(['package'], { + runtime: 'python2.7', + slim: 'true', + slimPatternsAppendDefaults: 'false', + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1385,13 +1341,12 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - '--dockerizePip=true', - '--runtime=python2.7', - '--slim=true', - '--slimPatternsAppendDefaults=false', - 'package', - ]); + sls(['package'], { + dockerizePip: 'true', + runtime: 'python2.7', + slim: 'true', + slimPatternsAppendDefaults: 'false', + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1416,7 +1371,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--slim=true', '--slimPatternsAppendDefaults=false', 'package']); + sls(['package'], { slim: 'true', slimPatternsAppendDefaults: 'false' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1441,7 +1396,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--slim=true', '--slimPatternsAppendDefaults=false', 'package']); + sls(['package'], { slim: 'true', slimPatternsAppendDefaults: 'false' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1464,8 +1419,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--individually=true', 'package']); - + sls(['package'], { individually: 'true' }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.false( zipfiles_hello.includes(`fn2${sep}__init__.py`), @@ -1551,8 +1505,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--individually=true', '--slim=true', 'package']); - + sls(['package'], { individually: 'true', slim: 'true' }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.true( zipfiles_hello.includes('handler.py'), @@ -1638,8 +1591,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--individually=true', '--runtime=python2.7', 'package']); - + sls(['package'], { individually: 'true', runtime: 'python2.7' }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.true( zipfiles_hello.includes('handler.py'), @@ -1709,13 +1661,11 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - '--individually=true', - '--runtime=python2.7', - '--slim=true', - 'package', - ]); - + sls(['package'], { + individually: 'true', + runtime: 'python2.7', + slim: 'true', + }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.true( zipfiles_hello.includes('handler.py'), @@ -1800,8 +1750,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--individually=true', '--runtime=python2.7', 'package']); - + sls(['package'], { individually: 'true', runtime: 'python2.7' }); t.true( pathExistsSync('.serverless/hello.zip'), 'function hello is packaged' @@ -1834,8 +1783,7 @@ test( process.chdir('tests/individually'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); - + sls(['package'], {}); const zipfiles_hello = await listZipFiles( '.serverless/module1-sls-py-req-test-indiv-dev-hello1.zip' ); @@ -1895,8 +1843,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--individually=true', '--vendor=./vendor', 'package']); - + sls(['package'], { individually: 'true', vendor: './vendor' }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.true( zipfiles_hello.includes('handler.py'), @@ -1981,8 +1928,7 @@ test( chmodSync(`module1${sep}foobar`, perm); npm(['i', path]); - sls(['package']); - + sls(['package'], {}); const zipfiles_hello1 = await listZipFilesWithMetaData( '.serverless/hello1.zip' ); @@ -2021,8 +1967,7 @@ test( chmodSync(`module1${sep}foobar`, perm); npm(['i', path]); - sls(['--dockerizePip=true', 'package']); - + sls(['package'], { dockerizePip: 'true' }); const zipfiles_hello = await listZipFilesWithMetaData( '.serverless/hello1.zip' ); @@ -2057,7 +2002,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const cachepath = getUserCachePath(); t.true( pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`), @@ -2074,7 +2019,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--cacheLocation=.requirements-cache', 'package']); + sls(['package'], { cacheLocation: '.requirements-cache' }); t.true( pathExistsSync(`.requirements-cache${sep}downloadCacheslspyc${sep}http`), 'cache directory exists' @@ -2090,7 +2035,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', 'package']); + sls(['package'], { dockerizePip: 'true' }); const cachepath = getUserCachePath(); t.true( pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`), @@ -2107,11 +2052,10 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls([ - '--dockerizePip=true', - '--cacheLocation=.requirements-cache', - 'package', - ]); + sls(['package'], { + dockerizePip: 'true', + cacheLocation: '.requirements-cache', + }); t.true( pathExistsSync(`.requirements-cache${sep}downloadCacheslspyc${sep}http`), 'cache directory exists' @@ -2127,7 +2071,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const cachepath = getUserCachePath(); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; @@ -2152,7 +2096,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', 'package']); + sls(['package'], { dockerizePip: 'true' }); const cachepath = getUserCachePath(); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; @@ -2177,7 +2121,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package']); + sls(['package'], {}); const cachepath = getUserCachePath(); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; @@ -2199,8 +2143,7 @@ test( `${cachepath}${sep}${cacheFolderHash}_${arch}_slspyc${sep}injected_file_is_bad_form`, 'injected new file into static cache folder' ); - sls(['package']); - + sls(['package'], {}); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('injected_file_is_bad_form'), @@ -2219,7 +2162,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); const cachepath = '.requirements-cache'; - sls([`--cacheLocation=${cachepath}`, 'package']); + sls(['package'], { cacheLocation: cachepath }); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; t.true( @@ -2245,7 +2188,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', '--slim=true', 'package']); + sls(['package'], { dockerizePip: 'true', slim: 'true' }); const cachepath = getUserCachePath(); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; @@ -2267,8 +2210,7 @@ test( `${cachepath}${sep}${cacheFolderHash}_${arch}_slspyc${sep}injected_file_is_bad_form`, 'injected new file into static cache folder' ); - sls(['--dockerizePip=true', '--slim=true', 'package']); - + sls(['package'], { dockerizePip: 'true', slim: 'true' }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('injected_file_is_bad_form'), @@ -2291,7 +2233,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--dockerizePip=true', '--slim=true', 'package']); + sls(['package'], { dockerizePip: 'true', slim: 'true' }); const cachepath = getUserCachePath(); t.true( pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`), @@ -2317,8 +2259,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['--individually=true', 'package']); - + sls(['package'], { individually: 'true' }); t.true( pathExistsSync('.serverless/hello.zip'), 'function hello is packaged' From 64d37e32232c6c2ca937e7fc1060760acdba57bc Mon Sep 17 00:00:00 2001 From: Marcin Martinez Date: Sat, 12 Feb 2022 14:04:27 +0100 Subject: [PATCH 5/6] Enable passing options other than env --- test.js | 258 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 147 insertions(+), 111 deletions(-) diff --git a/test.js b/test.js index e58434c4..a42cbf6b 100644 --- a/test.js +++ b/test.js @@ -22,9 +22,16 @@ const initialWorkingDir = process.cwd(); const mkCommand = (cmd) => (args, options = {}) => { - const { error, stdout, stderr, status } = crossSpawn.sync(cmd, args, { - env: Object.assign({ SLS_DEBUG: 't' }, process.env, options), - }); + options['env'] = Object.assign( + { SLS_DEBUG: 't' }, + process.env, + options['env'] + ); + const { error, stdout, stderr, status } = crossSpawn.sync( + cmd, + args, + options + ); if (error) { console.error(`Error running: ${quote([cmd, ...args])}`); // eslint-disable-line no-console throw error; @@ -199,7 +206,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -214,9 +221,9 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const fileHash = sha256File('.serverless/sls-py-req-test.zip'); - sls(['package'], {}); + sls(['package'], { env: {} }); t.equal( sha256File('.serverless/sls-py-req-test.zip'), fileHash, @@ -233,7 +240,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { pythonBin: getPythonBin(3) }); + sls(['package'], { env: { pythonBin: getPythonBin(3) } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -249,8 +256,10 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - fileName: 'requirements-w-hashes.txt', - pythonBin: getPythonBin(3), + env: { + fileName: 'requirements-w-hashes.txt', + pythonBin: getPythonBin(3), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -266,8 +275,10 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - fileName: 'requirements-w-nested.txt', - pythonBin: getPythonBin(3), + env: { + fileName: 'requirements-w-nested.txt', + pythonBin: getPythonBin(3), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -283,7 +294,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { zip: 'true', pythonBin: getPythonBin(3) }); + sls(['package'], { env: { zip: 'true', pythonBin: getPythonBin(3) } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -308,7 +319,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true', pythonBin: getPythonBin(3) }); + sls(['package'], { env: { slim: 'true', pythonBin: getPythonBin(3) } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -333,7 +344,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true' }); + sls(['package'], { env: { slim: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -364,7 +375,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls(['package'], { pythonBin: getPythonBin(3) }); + sls(['package'], { env: { pythonBin: getPythonBin(3) } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.false(zipfiles.includes(`bottle.py`), 'bottle is NOT packaged'); @@ -380,8 +391,10 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - fileName: 'requirements-w-editable.txt', - pythonBin: getPythonBin(3), + env: { + fileName: 'requirements-w-editable.txt', + pythonBin: getPythonBin(3), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -400,7 +413,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true' }); + sls(['package'], { env: { dockerizePip: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -415,7 +428,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true', slim: 'true' }); + sls(['package'], { env: { dockerizePip: 'true', slim: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -440,7 +453,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true', slim: 'true' }); + sls(['package'], { env: { dockerizePip: 'true', slim: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -464,7 +477,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true', zip: 'true' }); + sls(['package'], { env: { dockerizePip: 'true', zip: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( '.serverless/sls-py-req-test.zip' @@ -496,7 +509,9 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true', zip: 'true', slim: 'true' }); + sls(['package'], { + env: { dockerizePip: 'true', zip: 'true', slim: 'true' }, + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( '.serverless/sls-py-req-test.zip' @@ -528,7 +543,9 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { runtime: 'python2.7', pythonBin: getPythonBin(2) }); + sls(['package'], { + env: { runtime: 'python2.7', pythonBin: getPythonBin(2) }, + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -544,9 +561,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - slim: 'true', - pythonBin: getPythonBin(2), + env: { runtime: 'python2.7', slim: 'true', pythonBin: getPythonBin(2) }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -572,9 +587,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - zip: 'true', - pythonBin: getPythonBin(2), + env: { runtime: 'python2.7', zip: 'true', pythonBin: getPythonBin(2) }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( @@ -603,10 +616,12 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - dockerizePip: 'true', - slim: 'true', - pythonBin: getPythonBin(2), + env: { + runtime: 'python2.7', + dockerizePip: 'true', + slim: 'true', + pythonBin: getPythonBin(2), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -638,7 +653,9 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls(['package'], { runtime: 'python2.7', pythonBin: getPythonBin(2) }); + sls(['package'], { + env: { runtime: 'python2.7', pythonBin: getPythonBin(2) }, + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.false(zipfiles.includes(`bottle.py`), 'bottle is NOT packaged'); @@ -654,10 +671,12 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - dockerizePip: 'true', - zip: 'true', - pythonBin: getPythonBin(2), + env: { + runtime: 'python2.7', + dockerizePip: 'true', + zip: 'true', + pythonBin: getPythonBin(2), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( @@ -691,11 +710,13 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - dockerizePip: 'true', - zip: 'true', - slim: 'true', - pythonBin: getPythonBin(2), + env: { + runtime: 'python2.7', + dockerizePip: 'true', + zip: 'true', + slim: 'true', + pythonBin: getPythonBin(2), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( @@ -729,9 +750,11 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - dockerizePip: 'true', - pythonBin: getPythonBin(2), + env: { + runtime: 'python2.7', + dockerizePip: 'true', + pythonBin: getPythonBin(2), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -748,10 +771,12 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - dockerizePip: 'true', - slim: 'true', - pythonBin: getPythonBin(2), + env: { + runtime: 'python2.7', + dockerizePip: 'true', + slim: 'true', + pythonBin: getPythonBin(2), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -779,10 +804,12 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - dockerizePip: 'true', - slim: 'true', - pythonBin: getPythonBin(2), + env: { + runtime: 'python2.7', + dockerizePip: 'true', + slim: 'true', + pythonBin: getPythonBin(2), + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -807,7 +834,7 @@ test( process.chdir('tests/pipenv'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -826,7 +853,7 @@ test( process.chdir('tests/pipenv'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true' }); + sls(['package'], { env: { slim: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -852,7 +879,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true' }); + sls(['package'], { env: { slim: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -876,7 +903,7 @@ test( process.chdir('tests/pipenv'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { zip: 'true', pythonBin: getPythonBin(3) }); + sls(['package'], { env: { zip: 'true', pythonBin: getPythonBin(3) } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -908,7 +935,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.false(zipfiles.includes(`bottle.py`), 'bottle is NOT packaged'); @@ -923,7 +950,7 @@ test( process.chdir('tests/non_build_pyproject'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -938,7 +965,7 @@ test( process.chdir('tests/non_poetry_pyproject'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`handler.py`), 'handler is packaged'); t.end(); @@ -952,7 +979,7 @@ test( process.chdir('tests/poetry'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`bottle.py`), 'bottle is packaged'); @@ -968,7 +995,7 @@ test( process.chdir('tests/poetry'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true' }); + sls(['package'], { env: { slim: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -994,7 +1021,7 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true' }); + sls(['package'], { env: { slim: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.deepEqual( @@ -1018,7 +1045,7 @@ test( process.chdir('tests/poetry'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { zip: 'true', pythonBin: getPythonBin(3) }); + sls(['package'], { env: { zip: 'true', pythonBin: getPythonBin(3) } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -1050,7 +1077,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.false(zipfiles.includes(`bottle.py`), 'bottle is NOT packaged'); @@ -1067,7 +1094,7 @@ test( npm(['i', path]); perl(['-p', '-i.bak', '-e', 's/include://', 'serverless.yml']); perl(['-p', '-i.bak', '-e', 's/^.*handler.py.*$//', 'serverless.yml']); - sls(['package'], { zip: 'true' }); + sls(['package'], { env: { zip: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('.requirements.zip'), @@ -1092,7 +1119,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { vendor: './vendor' }); + sls(['package'], { env: { vendor: './vendor' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -1122,7 +1149,7 @@ test( ]); writeFileSync(`foobar`, ''); chmodSync(`foobar`, perm); - sls(['package'], { vendor: './vendor' }); + sls(['package'], { env: { vendor: './vendor' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -1160,7 +1187,7 @@ test( process.chdir('tests/base with a space'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -1176,7 +1203,7 @@ test( process.chdir('tests/base with a space'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true' }); + sls(['package'], { env: { dockerizePip: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true(zipfiles.includes(`boto3${sep}__init__.py`), 'boto3 is packaged'); @@ -1192,7 +1219,7 @@ test( const path = npm(['pack', '../..']); writeFileSync('puck', 'requests'); npm(['i', path]); - sls(['package'], { fileName: 'puck' }); + sls(['package'], { env: { fileName: 'puck' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes(`requests${sep}__init__.py`), @@ -1224,7 +1251,7 @@ test( 's/(pythonRequirements:$)/\\1\\n noDeploy: [bottle]/', 'serverless.yml', ]); - sls(['package'], { zip: 'true', pythonBin: getPythonBin(3) }); + sls(['package'], { env: { zip: 'true', pythonBin: getPythonBin(3) } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); const zippedReqs = await listRequirementsZipFiles( '.serverless/sls-py-req-test.zip' @@ -1261,7 +1288,9 @@ test( copySync('_slimPatterns.yml', 'slimPatterns.yml'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true', slimPatternsAppendDefaults: 'false' }); + sls(['package'], { + env: { slim: 'true', slimPatternsAppendDefaults: 'false' }, + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1286,9 +1315,11 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - dockerizePip: 'true', - slim: 'true', - slimPatternsAppendDefaults: 'false', + env: { + dockerizePip: 'true', + slim: 'true', + slimPatternsAppendDefaults: 'false', + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -1314,9 +1345,11 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - runtime: 'python2.7', - slim: 'true', - slimPatternsAppendDefaults: 'false', + env: { + runtime: 'python2.7', + slim: 'true', + slimPatternsAppendDefaults: 'false', + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -1342,10 +1375,12 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - dockerizePip: 'true', - runtime: 'python2.7', - slim: 'true', - slimPatternsAppendDefaults: 'false', + env: { + dockerizePip: 'true', + runtime: 'python2.7', + slim: 'true', + slimPatternsAppendDefaults: 'false', + }, }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); @@ -1371,7 +1406,9 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true', slimPatternsAppendDefaults: 'false' }); + sls(['package'], { + env: { slim: 'true', slimPatternsAppendDefaults: 'false' }, + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1396,7 +1433,9 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { slim: 'true', slimPatternsAppendDefaults: 'false' }); + sls(['package'], { + env: { slim: 'true', slimPatternsAppendDefaults: 'false' }, + }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true(zipfiles.includes(`flask${sep}__init__.py`), 'flask is packaged'); t.true( @@ -1419,7 +1458,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { individually: 'true' }); + sls(['package'], { env: { individually: 'true' } }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.false( zipfiles_hello.includes(`fn2${sep}__init__.py`), @@ -1505,7 +1544,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { individually: 'true', slim: 'true' }); + sls(['package'], { env: { individually: 'true', slim: 'true' } }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.true( zipfiles_hello.includes('handler.py'), @@ -1591,7 +1630,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { individually: 'true', runtime: 'python2.7' }); + sls(['package'], { env: { individually: 'true', runtime: 'python2.7' } }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.true( zipfiles_hello.includes('handler.py'), @@ -1662,9 +1701,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - individually: 'true', - runtime: 'python2.7', - slim: 'true', + env: { individually: 'true', runtime: 'python2.7', slim: 'true' }, }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.true( @@ -1750,7 +1787,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { individually: 'true', runtime: 'python2.7' }); + sls(['package'], { env: { individually: 'true', runtime: 'python2.7' } }); t.true( pathExistsSync('.serverless/hello.zip'), 'function hello is packaged' @@ -1783,7 +1820,7 @@ test( process.chdir('tests/individually'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles_hello = await listZipFiles( '.serverless/module1-sls-py-req-test-indiv-dev-hello1.zip' ); @@ -1843,7 +1880,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { individually: 'true', vendor: './vendor' }); + sls(['package'], { env: { individually: 'true', vendor: './vendor' } }); const zipfiles_hello = await listZipFiles('.serverless/hello.zip'); t.true( zipfiles_hello.includes('handler.py'), @@ -1928,7 +1965,7 @@ test( chmodSync(`module1${sep}foobar`, perm); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles_hello1 = await listZipFilesWithMetaData( '.serverless/hello1.zip' ); @@ -1967,7 +2004,7 @@ test( chmodSync(`module1${sep}foobar`, perm); npm(['i', path]); - sls(['package'], { dockerizePip: 'true' }); + sls(['package'], { env: { dockerizePip: 'true' } }); const zipfiles_hello = await listZipFilesWithMetaData( '.serverless/hello1.zip' ); @@ -2002,7 +2039,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const cachepath = getUserCachePath(); t.true( pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`), @@ -2019,7 +2056,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { cacheLocation: '.requirements-cache' }); + sls(['package'], { env: { cacheLocation: '.requirements-cache' } }); t.true( pathExistsSync(`.requirements-cache${sep}downloadCacheslspyc${sep}http`), 'cache directory exists' @@ -2035,7 +2072,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true' }); + sls(['package'], { env: { dockerizePip: 'true' } }); const cachepath = getUserCachePath(); t.true( pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`), @@ -2053,8 +2090,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); sls(['package'], { - dockerizePip: 'true', - cacheLocation: '.requirements-cache', + env: { dockerizePip: 'true', cacheLocation: '.requirements-cache' }, }); t.true( pathExistsSync(`.requirements-cache${sep}downloadCacheslspyc${sep}http`), @@ -2071,7 +2107,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const cachepath = getUserCachePath(); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; @@ -2096,7 +2132,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true' }); + sls(['package'], { env: { dockerizePip: 'true' } }); const cachepath = getUserCachePath(); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; @@ -2121,7 +2157,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], {}); + sls(['package'], { env: {} }); const cachepath = getUserCachePath(); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; @@ -2143,7 +2179,7 @@ test( `${cachepath}${sep}${cacheFolderHash}_${arch}_slspyc${sep}injected_file_is_bad_form`, 'injected new file into static cache folder' ); - sls(['package'], {}); + sls(['package'], { env: {} }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('injected_file_is_bad_form'), @@ -2162,7 +2198,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); const cachepath = '.requirements-cache'; - sls(['package'], { cacheLocation: cachepath }); + sls(['package'], { env: { cacheLocation: '${cachepath}' } }); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; t.true( @@ -2188,7 +2224,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true', slim: 'true' }); + sls(['package'], { env: { dockerizePip: 'true', slim: 'true' } }); const cachepath = getUserCachePath(); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; @@ -2210,7 +2246,7 @@ test( `${cachepath}${sep}${cacheFolderHash}_${arch}_slspyc${sep}injected_file_is_bad_form`, 'injected new file into static cache folder' ); - sls(['package'], { dockerizePip: 'true', slim: 'true' }); + sls(['package'], { env: { dockerizePip: 'true', slim: 'true' } }); const zipfiles = await listZipFiles('.serverless/sls-py-req-test.zip'); t.true( zipfiles.includes('injected_file_is_bad_form'), @@ -2233,7 +2269,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { dockerizePip: 'true', slim: 'true' }); + sls(['package'], { env: { dockerizePip: 'true', slim: 'true' } }); const cachepath = getUserCachePath(); t.true( pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`), @@ -2259,7 +2295,7 @@ test( process.chdir('tests/base'); const path = npm(['pack', '../..']); npm(['i', path]); - sls(['package'], { individually: 'true' }); + sls(['package'], { env: { individually: 'true' } }); t.true( pathExistsSync('.serverless/hello.zip'), 'function hello is packaged' From fe52dc117ed7b883039f30ce91a3163c8aef529e Mon Sep 17 00:00:00 2001 From: Marcin Martinez Date: Sat, 12 Feb 2022 14:08:30 +0100 Subject: [PATCH 6/6] Fix variable --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index a42cbf6b..11a7cce5 100644 --- a/test.js +++ b/test.js @@ -2198,7 +2198,7 @@ test( const path = npm(['pack', '../..']); npm(['i', path]); const cachepath = '.requirements-cache'; - sls(['package'], { env: { cacheLocation: '${cachepath}' } }); + sls(['package'], { env: { cacheLocation: cachepath } }); const cacheFolderHash = sha256Path('.serverless/requirements.txt'); const arch = 'x86_64'; t.true(