Merge pull request #14372 from atom/zhu-li-do-the-thing

🎉
This commit is contained in:
Michelle Tilley
2017-05-11 10:03:29 +02:00
committed by GitHub
6 changed files with 64 additions and 12 deletions

View File

@@ -104,6 +104,7 @@
"exception-reporting": "0.41.4",
"find-and-replace": "0.208.1",
"fuzzy-finder": "1.5.6",
"github": "0.0.6",
"git-diff": "1.3.6",
"go-to-line": "0.32.1",
"grammar-selector": "0.49.4",
@@ -127,7 +128,7 @@
"timecop": "0.36.0",
"tree-view": "0.217.0-7",
"update-package-dependencies": "0.11.0",
"welcome": "0.36.2",
"welcome": "0.36.3",
"whitespace": "0.36.2",
"wrap-guide": "0.40.2",
"language-c": "0.58.0",

View File

@@ -2,11 +2,12 @@
'use strict'
const CONFIG = require('./config')
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 +26,6 @@ if (process.platform === 'win32') deleteMsbuildFromPath()
installScriptDependencies()
installApm()
installAtomDependencies()
runApmInstall(CONFIG.repositoryRootPath)
dependenciesFingerprint.write()

View File

@@ -27,6 +27,7 @@ module.exports = function (packagedAppPath) {
modulePath.endsWith('.node') ||
coreModules.has(modulePath) ||
(relativePath.startsWith(path.join('..', 'src')) && relativePath.endsWith('-element.js')) ||
relativePath.startsWith(path.join('..', 'node_modules', 'dugite')) ||
relativePath == path.join('..', 'exports', 'atom.js') ||
relativePath == path.join('..', 'src', 'electron-shims.js') ||
relativePath == path.join('..', 'src', 'safe-clipboard.js') ||
@@ -37,16 +38,22 @@ module.exports = function (packagedAppPath) {
relativePath == path.join('..', 'node_modules', 'cson-parser', 'node_modules', 'coffee-script', 'lib', 'coffee-script', 'register.js') ||
relativePath == path.join('..', 'node_modules', 'decompress-zip', 'lib', 'decompress-zip.js') ||
relativePath == path.join('..', 'node_modules', 'debug', 'node.js') ||
relativePath == path.join('..', 'node_modules', 'fs-extra', 'lib', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'git-utils', 'lib', 'git.js') ||
relativePath == path.join('..', 'node_modules', 'glob', 'glob.js') ||
relativePath == path.join('..', 'node_modules', 'graceful-fs', 'graceful-fs.js') ||
relativePath == path.join('..', 'node_modules', 'htmlparser2', 'lib', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'markdown-preview', 'node_modules', 'htmlparser2', 'lib', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'roaster', 'node_modules', 'htmlparser2', 'lib', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'task-lists', 'node_modules', 'htmlparser2', 'lib', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'iconv-lite', 'encodings', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'less', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'less', 'lib', 'less', 'fs.js') ||
relativePath == path.join('..', 'node_modules', 'less', 'lib', 'less-node', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'less', 'node_modules', 'graceful-fs', 'graceful-fs.js') ||
relativePath == path.join('..', 'node_modules', 'minimatch', 'minimatch.js') ||
relativePath == path.join('..', 'node_modules', 'node-fetch', 'lib', 'fetch-error.js') ||
relativePath == path.join('..', 'node_modules', 'nsfw', 'node_modules', 'fs-extra', 'lib', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'superstring', 'index.js') ||
relativePath == path.join('..', 'node_modules', 'oniguruma', 'src', 'oniguruma.js') ||
relativePath == path.join('..', 'node_modules', 'request', 'index.js') ||

View File

@@ -5,7 +5,7 @@ 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 +15,6 @@ module.exports = function () {
childProcess.execFileSync(
CONFIG.getApmBinPath(),
['--loglevel=error', 'install'],
{env: installEnv, cwd: CONFIG.repositoryRootPath, stdio: 'inherit'}
{env: installEnv, cwd: packagePath, stdio: 'inherit'}
)
}

View File

@@ -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
@@ -38,7 +39,10 @@ function runCoreMainProcessTests (callback) {
]
console.log('Executing core main process tests'.bold.green)
const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit'})
const cp = childProcess.spawn(executablePath, testArguments, {
stdio: 'inherit',
env: Object.assign({}, process.env, {ATOM_GITHUB_INLINE_GIT_EXEC: 'true'})
})
cp.on('error', error => { callback(error) })
cp.on('close', exitCode => { callback(null, exitCode) })
}
@@ -59,25 +63,63 @@ 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 packageSpecDirPath = path.join(CONFIG.repositoryRootPath, 'node_modules', packageName, 'spec')
if (!fs.existsSync(packageSpecDirPath)) continue
if (process.env.ATOM_PACKAGES_TO_TEST) {
const packagesToTest = process.env.ATOM_PACKAGES_TO_TEST.split(',').map(pkg => pkg.trim())
if (!packagesToTest.includes(packageName)) continue
}
const repositoryPackagePath = path.join(CONFIG.repositoryRootPath, 'node_modules', packageName)
const testSubdir = ['spec', 'test'].find(subdir => fs.existsSync(path.join(repositoryPackagePath, subdir)))
if (!testSubdir) {
packageTestSuites.push(function (callback) {
console.log(`Skipping tests for ${packageName} because no test folder was found`.bold.yellow)
callback(null, 0)
})
continue
}
const testFolder = path.join(repositoryPackagePath, testSubdir)
packageTestSuites.push(function (callback) {
const testArguments = [
'--resource-path', resourcePath,
'--test', packageSpecDirPath
'--test', testFolder
]
console.log(`Executing ${packageName} tests`.bold.green)
const pkgJsonPath = path.join(repositoryPackagePath, 'package.json')
const nodeModulesPath = path.join(repositoryPackagePath, 'node_modules')
const nodeModulesBackupPath = path.join(repositoryPackagePath, 'node_modules.bak')
let finalize = () => null
if (require(pkgJsonPath).atomTestRunner) {
console.log(`Installing test runner dependencies for ${packageName}`.bold.green)
if (fs.existsSync(nodeModulesPath)) {
fs.copySync(nodeModulesPath, nodeModulesBackupPath)
finalize = () => {
fs.removeSync(nodeModulesPath)
fs.renameSync(nodeModulesBackupPath, nodeModulesPath)
}
} else {
finalize = () => fs.removeSync(nodeModulesPath)
}
runApmInstall(repositoryPackagePath)
console.log(`Executing ${packageName} tests`.green)
} else {
console.log(`Executing ${packageName} tests`.bold.green)
}
const cp = childProcess.spawn(executablePath, testArguments)
let stderrOutput = ''
cp.stderr.on('data', data => stderrOutput += data)
cp.on('error', error => { callback(error) })
cp.on('error', error => {
finalize()
callback(error)
})
cp.on('close', exitCode => {
if (exitCode !== 0) {
console.log(`Package tests failed for ${packageName}:`.red)
console.log(stderrOutput)
}
finalize()
callback(null, exitCode)
})
})

View File

@@ -29,6 +29,7 @@ if global.isGeneratingSnapshot
require('dalek')
require('find-and-replace')
require('fuzzy-finder')
require('github')
require('git-diff')
require('go-to-line')
require('grammar-selector')