Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
chore: use BINARY_PATH constant in tests (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Feb 8, 2022
1 parent 194a103 commit fe96bc0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 1 addition & 3 deletions tests/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ const { tmpName } = require('tmp-promise')

const { version } = require('../package.json')

const { FIXTURES_DIR } = require('./helpers/main')

const BINARY_PATH = join(__dirname, '..', 'dist', 'bin.js')
const { FIXTURES_DIR, BINARY_PATH } = require('./helpers/main')

const exec = (args, options) => execa('node', [BINARY_PATH, ...args], options)

Expand Down
2 changes: 2 additions & 0 deletions tests/helpers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { zipFunctions } = require('../..')
const { listImports } = require('../../dist/runtimes/node/bundlers/zisi/list_imports')

const FIXTURES_DIR = join(__dirname, '..', 'fixtures')
const BINARY_PATH = join(__dirname, '..', '..', 'dist', 'bin.js')

const zipNode = async function (t, fixture, { length, fixtureDir, opts } = {}) {
const { files, tmpDir } = await zipFixture(t, fixture, {
Expand Down Expand Up @@ -113,4 +114,5 @@ module.exports = {
unzipFiles,
zipCheckFunctions,
FIXTURES_DIR,
BINARY_PATH,
}
13 changes: 10 additions & 3 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ const { zipFunction, listFunctions, listFunctionsFiles, listFunction } = require
const { ESBUILD_LOG_LIMIT } = require('../dist/runtimes/node/bundlers/esbuild/bundler')
const { detectEsModule } = require('../dist/runtimes/node/utils/detect_es_module')

const { getRequires, zipNode, zipFixture, unzipFiles, zipCheckFunctions, FIXTURES_DIR } = require('./helpers/main')
const {
getRequires,
zipNode,
zipFixture,
unzipFiles,
zipCheckFunctions,
FIXTURES_DIR,
BINARY_PATH,
} = require('./helpers/main')
const { computeSha1 } = require('./helpers/sha')
const { makeTestMany } = require('./helpers/test_many')

Expand Down Expand Up @@ -1509,11 +1517,10 @@ testMany(

test('Limits the amount of log lines produced by esbuild', async (t) => {
const { path: tmpDir } = await getTmpDir({ prefix: 'zip-it-test' })
const binaryPath = resolve(__dirname, '../dist/bin.js')
const fixturePath = join(FIXTURES_DIR, 'esbuild-log-limit')

try {
await execa('node', [binaryPath, fixturePath, tmpDir, `--config.*.nodeBundler=esbuild`])
await execa('node', [BINARY_PATH, fixturePath, tmpDir, `--config.*.nodeBundler=esbuild`])

t.fail('Bundling should have thrown')
} catch (error) {
Expand Down

1 comment on commit fe96bc0

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

largeDepsEsbuild: 8.3s

largeDepsZisi: 1m 6.1s

Please sign in to comment.