test: create test projects in OS temp dirs

This commit is contained in:
Zoltan Kochan
2019-11-19 23:10:46 +02:00
parent e97d957ec7
commit 0bd287c765
5 changed files with 8 additions and 7 deletions

View File

@@ -178,7 +178,7 @@
"lint": "tslint -c tslint.json src/**/*.ts test/**/*.ts",
"registry-mock": "registry-mock",
"test:tap": "ts-node test --type-check",
"pretest:e2e": "rimraf ../../../.tmp/ && rimraf node_modules/.bin/pnpm && registry-mock prepare",
"pretest:e2e": "rimraf node_modules/.bin/pnpm && registry-mock prepare",
"test:e2e": "cross-env PNPM_REGISTRY_MOCK_PORT=7772 run-p -r registry-mock test:tap",
"test": "npm run lint && npm run tsc && npm run test:e2e",
"tsc": "rimraf lib && tsc",

View File

@@ -156,7 +156,7 @@
"registry-mock": "registry-mock",
"test:tap": "ts-node test",
"test:e2e": "run-p -r registry-mock test:tap",
"pretest": "rimraf ../../../.tmp/ && registry-mock prepare",
"pretest": "registry-mock prepare",
"test-with-preview": "pnpm run lint && preview && pnpm run test:e2e",
"test": "pnpm run lint && pnpm run tsc && pnpm run test:e2e",
"tsc": "rimraf lib && tsc",

4
pnpm-lock.yaml generated
View File

@@ -1936,6 +1936,7 @@ importers:
'@types/mkdirp': 0.5.2
make-dir: 3.0.0
tape: 4.11.0
tempy: 0.3.0
write-json5-file: 2.1.2
write-pkg: 4.0.0
write-yaml-file: 3.0.1
@@ -1950,6 +1951,7 @@ importers:
make-dir: 3.0.0
rimraf: 3.0.0
tape: 4.11.0
tempy: 0.3.0
tslint-config-standard: 9.0.0
tslint-eslint-rules: 5.4.0
write-json5-file: 2.1.2
@@ -9764,7 +9766,6 @@ packages:
resolution:
integrity: sha512-G3I7QWUBSNWaekrJcDabydF6dcvy+vZ2PrX04JYq1p914TOLgpN+ryMtheGavs1LYVevTbTmwjQY8aeX8yLsyA==
/temp-dir/1.0.0:
dev: true
engines:
node: '>=4'
resolution:
@@ -9774,7 +9775,6 @@ packages:
temp-dir: 1.0.0
type-fest: 0.3.1
unique-string: 1.0.0
dev: true
engines:
node: '>=8'
resolution:

View File

@@ -10,6 +10,7 @@
"@types/mkdirp": "0.5.2",
"make-dir": "3.0.0",
"tape": "4.11.0",
"tempy": "0.3.0",
"write-json5-file": "2.1.2",
"write-pkg": "4.0.0",
"write-yaml-file": "3.0.1"

View File

@@ -3,6 +3,7 @@ import { ImporterManifest } from '@pnpm/types'
import makeDir = require('make-dir')
import path = require('path')
import { Test } from 'tape'
import tempy = require('tempy')
import { sync as writeJson5File } from 'write-json5-file'
import writePkg = require('write-pkg')
import { sync as writeYamlFile } from 'write-yaml-file'
@@ -11,8 +12,7 @@ export { Modules, Project }
export type ManifestFormat = 'JSON' | 'JSON5' | 'YAML'
// the testing folder should be outside of the project to avoid lookup in the project's node_modules
const tmpPath = path.join(__dirname, '..', '..', '..', '..', '.tmp')
makeDir.sync(tmpPath)
const tmpPath = tempy.directory()
let dirNumber = 0
@@ -22,7 +22,7 @@ export function tempDir (t: Test) {
const tmpDir = path.join(tmpPath, dirname)
makeDir.sync(tmpDir)
t.pass(`create testing dir ${dirname}`)
t.pass(`create testing dir ${path.join(tmpDir)}`)
process.chdir(tmpDir)