({ srcDir, install, rebuild, testArgs, logfile })
| 37 | } |
| 38 | |
| 39 | function runNPMPackageTests({ srcDir, install, rebuild, testArgs, logfile }) { |
| 40 | // Make sure we don't conflict with concurrent test runs |
| 41 | const srcHash = createHash('md5').update(srcDir).digest('hex'); |
| 42 | tmpDir.path = `${tmpDir.path}.npm.${srcHash}`; |
| 43 | tmpDir.refresh(); |
| 44 | |
| 45 | const npmCache = path.join(tmpDir.path, 'npm-cache'); |
| 46 | const npmPrefix = path.join(tmpDir.path, 'npm-prefix'); |
| 47 | const npmTmp = path.join(tmpDir.path, 'npm-tmp'); |
| 48 | const npmUserconfig = path.join(tmpDir.path, 'npm-userconfig'); |
| 49 | const pkgDir = path.join(tmpDir.path, 'pkg'); |
| 50 | |
| 51 | spawnCopyDeepSync(srcDir, pkgDir); |
| 52 | |
| 53 | const npmOptions = { |
| 54 | cwd: pkgDir, |
| 55 | env: Object.assign({}, process.env, { |
| 56 | 'npm_config_cache': npmCache, |
| 57 | 'npm_config_prefix': npmPrefix, |
| 58 | 'npm_config_tmp': npmTmp, |
| 59 | 'npm_config_userconfig': npmUserconfig, |
| 60 | }), |
| 61 | stdio: 'inherit', |
| 62 | }; |
| 63 | |
| 64 | if (common.isWindows) { |
| 65 | npmOptions.env.home = tmpDir.path; |
| 66 | npmOptions.env.Path = `${nodePath};${process.env.Path}`; |
| 67 | } else { |
| 68 | npmOptions.env.HOME = tmpDir.path; |
| 69 | npmOptions.env.PATH = `${nodePath}:${process.env.PATH}`; |
| 70 | } |
| 71 | |
| 72 | if (rebuild) { |
| 73 | spawnSync(process.execPath, [ |
| 74 | npmBin, |
| 75 | 'rebuild', |
| 76 | ], npmOptions); |
| 77 | } |
| 78 | |
| 79 | if (install) { |
| 80 | spawnSync(process.execPath, [ |
| 81 | npmBin, |
| 82 | 'install', |
| 83 | '--ignore-scripts', |
| 84 | '--no-save', |
| 85 | ], npmOptions); |
| 86 | } |
| 87 | |
| 88 | const testChild = spawn(process.execPath, [ |
| 89 | npmBin, |
| 90 | '--silent', |
| 91 | 'run', |
| 92 | ...testArgs, |
| 93 | ], Object.assign({}, npmOptions, { stdio: 'pipe' })); |
| 94 | |
| 95 | testChild.stdout.pipe(process.stdout); |
| 96 | testChild.stderr.pipe(process.stderr); |
no test coverage detected
searching dependent graphs…