mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Ensure script/tests runs package tests with devDeps installed
This commit is contained in:
@@ -6,7 +6,7 @@ const cleanDependencies = require('./lib/clean-dependencies')
|
||||
const deleteMsbuildFromPath = require('./lib/delete-msbuild-from-path')
|
||||
const dependenciesFingerprint = require('./lib/dependencies-fingerprint')
|
||||
const installApm = require('./lib/install-apm')
|
||||
const installAtomDependencies = require('./lib/install-atom-dependencies')
|
||||
const runApmInstall = require('./lib/run-apm-install')
|
||||
const installScriptDependencies = require('./lib/install-script-dependencies')
|
||||
const verifyMachineRequirements = require('./lib/verify-machine-requirements')
|
||||
|
||||
@@ -25,6 +25,6 @@ if (process.platform === 'win32') deleteMsbuildFromPath()
|
||||
|
||||
installScriptDependencies()
|
||||
installApm()
|
||||
installAtomDependencies()
|
||||
runApmInstall(CONFIG.repositoryRootPath)
|
||||
|
||||
dependenciesFingerprint.write()
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
'use strict'
|
||||
|
||||
const childProcess = require('child_process')
|
||||
const path = require('path')
|
||||
|
||||
const CONFIG = require('../config')
|
||||
|
||||
module.exports = function () {
|
||||
module.exports = function (packagePath) {
|
||||
const installEnv = Object.assign({}, process.env)
|
||||
// Set resource path so that apm can load metadata related to Atom.
|
||||
installEnv.ATOM_RESOURCE_PATH = CONFIG.repositoryRootPath
|
||||
@@ -15,6 +13,6 @@ module.exports = function () {
|
||||
childProcess.execFileSync(
|
||||
CONFIG.getApmBinPath(),
|
||||
['--loglevel=error', 'install'],
|
||||
{env: installEnv, cwd: CONFIG.repositoryRootPath, stdio: 'inherit'}
|
||||
{env: installEnv, cwd: packagePath, stdio: 'inherit'}
|
||||
)
|
||||
}
|
||||
27
script/test
27
script/test
@@ -6,11 +6,12 @@ require('colors')
|
||||
const assert = require('assert')
|
||||
const async = require('async')
|
||||
const childProcess = require('child_process')
|
||||
const fs = require('fs')
|
||||
const fs = require('fs-extra')
|
||||
const glob = require('glob')
|
||||
const path = require('path')
|
||||
|
||||
const CONFIG = require('./config')
|
||||
const runApmInstall = require('./lib/run-apm-install')
|
||||
|
||||
const resourcePath = CONFIG.repositoryRootPath
|
||||
let executablePath
|
||||
@@ -62,19 +63,29 @@ function runCoreRenderProcessTests (callback) {
|
||||
// Build an array of functions, each running tests for a different bundled package
|
||||
const packageTestSuites = []
|
||||
for (let packageName in CONFIG.appMetadata.packageDependencies) {
|
||||
const packagePath = path.join(CONFIG.repositoryRootPath, 'node_modules', packageName)
|
||||
const packageSpecDirPath = ['spec', 'test']
|
||||
.map(folder => path.join(packagePath, folder))
|
||||
.find(fullPath => fs.existsSync(fullPath))
|
||||
if (!packageSpecDirPath) continue
|
||||
const repositoryPackagePath = path.join(CONFIG.repositoryRootPath, 'node_modules', packageName)
|
||||
const intermediatePackagePath = path.join(CONFIG.intermediateAppPath, 'node_modules', packageName)
|
||||
const testSubdir = ['spec', 'test'].find(subdir => fs.existsSync(path.join(intermediatePackagePath, subdir)))
|
||||
|
||||
if (!testSubdir) {
|
||||
console.log(`Skipping test for ${packageName} because no test folder was found`.bold.yellow)
|
||||
continue
|
||||
}
|
||||
|
||||
const sourceTestFolder = path.join(repositoryPackagePath, testSubdir)
|
||||
const targetTestFolder = path.join(intermediatePackagePath, testSubdir)
|
||||
|
||||
packageTestSuites.push(function (callback) {
|
||||
const testArguments = [
|
||||
'--resource-path', resourcePath,
|
||||
'--test', packageSpecDirPath
|
||||
'--test', targetTestFolder
|
||||
]
|
||||
|
||||
console.log(`Executing ${packageName} tests`.bold.green)
|
||||
fs.removeSync(targetTestFolder)
|
||||
fs.copySync(sourceTestFolder, targetTestFolder)
|
||||
console.log(`Installing dependencies for ${packageName}`.bold.green)
|
||||
runApmInstall(intermediatePackagePath)
|
||||
console.log(`Executing ${packageName} tests`.green)
|
||||
const cp = childProcess.spawn(executablePath, testArguments)
|
||||
let stderrOutput = ''
|
||||
cp.stderr.on('data', data => stderrOutput += data)
|
||||
|
||||
Reference in New Issue
Block a user