diff --git a/packages/kbn-test/src/index.ts b/packages/kbn-test/src/index.ts index cfbd1ee0fe64c..57cdc8ffd494f 100644 --- a/packages/kbn-test/src/index.ts +++ b/packages/kbn-test/src/index.ts @@ -58,3 +58,5 @@ export { export { runFailedTestsReporterCli } from './failed_tests_reporter'; export { makeJunitReportPath } from './junit_report_path'; + +export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix'; diff --git a/src/dev/build/tasks/nodejs/__tests__/download.js b/src/dev/build/tasks/nodejs/__tests__/download.js index c76ff15b89289..81ed7a6195ae7 100644 --- a/src/dev/build/tasks/nodejs/__tests__/download.js +++ b/src/dev/build/tasks/nodejs/__tests__/download.js @@ -18,27 +18,39 @@ */ import { createServer } from 'http'; -import { resolve } from 'path'; -import { readFileSync } from 'fs'; +import { join } from 'path'; +import { tmpdir } from 'os'; +import { mkdirp, readFileSync } from 'fs-extra'; import del from 'del'; import sinon from 'sinon'; +import { CI_PARALLEL_PROCESS_PREFIX } from '@kbn/test'; import expect from '@kbn/expect'; import Wreck from '@hapi/wreck'; import { ToolingLog } from '@kbn/dev-utils'; import { download } from '../download'; -const TMP_DESTINATION = resolve(__dirname, '__tmp__'); -beforeEach(async () => { - await del(TMP_DESTINATION); -}); -after(async () => { - await del(TMP_DESTINATION); -}); +const getTempFolder = async () => { + const dir = join(tmpdir(), CI_PARALLEL_PROCESS_PREFIX, 'download-js-test-tmp-dir'); + console.log(dir); + await mkdirp(dir); + return dir; +}; describe('src/dev/build/tasks/nodejs/download', () => { const sandbox = sinon.createSandbox(); + let TMP_DESTINATION; + let TMP_DIR; + + beforeEach(async () => { + TMP_DIR = await getTempFolder(); + TMP_DESTINATION = join(TMP_DIR, '__tmp_download_js_test_file__'); + }); + + afterEach(async () => { + await del(TMP_DIR, { force: true }); + }); afterEach(() => sandbox.reset()); const onLogLine = sandbox.stub();