From a996597d49ded9fac2e7c95dd48db0261961b726 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Wed, 13 Nov 2013 17:24:49 -0800 Subject: [PATCH 1/8] Call grunt.verbose.writeln instead of grunt.log.writeln --- tasks/prebuild-less-task.coffee | 6 +++--- tasks/publish-packages.coffee | 2 +- tasks/spec-task.coffee | 8 ++++---- tasks/task-helpers.coffee | 2 +- tasks/update-atom-shell-task.coffee | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tasks/prebuild-less-task.coffee b/tasks/prebuild-less-task.coffee index 636616f9b..c8cf33083 100644 --- a/tasks/prebuild-less-task.coffee +++ b/tasks/prebuild-less-task.coffee @@ -30,16 +30,16 @@ module.exports = (grunt) -> themeMains.push(mainPath) if grunt.file.isFile(mainPath) importPaths.unshift(stylesheetsDir) if grunt.file.isDir(stylesheetsDir) - grunt.log.writeln("Building LESS cache for #{configuration.join(', ').yellow}") + grunt.verbose.writeln("Building LESS cache for #{configuration.join(', ').yellow}") lessCache = new LessCache cacheDir: directory resourcePath: path.resolve('.') importPaths: importPaths for file in @filesSrc - grunt.log.writeln("File #{file.cyan} created in cache.") + grunt.verbose.writeln("File #{file.cyan} created in cache.") lessCache.readFileSync(file) for file in themeMains - grunt.log.writeln("File #{file.cyan} created in cache.") + grunt.verbose.writeln("File #{file.cyan} created in cache.") lessCache.readFileSync(file) diff --git a/tasks/publish-packages.coffee b/tasks/publish-packages.coffee index 765a927f1..b63b5a59b 100644 --- a/tasks/publish-packages.coffee +++ b/tasks/publish-packages.coffee @@ -84,7 +84,7 @@ module.exports = (grunt) -> for name, version of packageDependencies do (name, version) -> tasks.push (callback) -> - grunt.log.writeln("Publishing #{name}@#{version}") + grunt.verbose.writeln("Publishing #{name}@#{version}") tag = "v#{version}" packageExists name, token, (error, exists) -> if error? diff --git a/tasks/spec-task.coffee b/tasks/spec-task.coffee index a25ccc0d5..6d3760d86 100644 --- a/tasks/spec-task.coffee +++ b/tasks/spec-task.coffee @@ -23,9 +23,9 @@ module.exports = (grunt) -> opts: cwd: packagePath env: _.extend({}, process.env, ATOM_PATH: rootDir) - grunt.log.writeln("Launching #{path.basename(packagePath)} specs.") + grunt.verbose.writeln("Launching #{path.basename(packagePath)} specs.") spawn options, (error, results, code) -> - grunt.log.writeln() + grunt.verbose.writeln() passed = passed and not error and code is 0 callback() @@ -49,7 +49,7 @@ module.exports = (grunt) -> cmd: appPath args: ['--test', "--resource-path=#{resourcePath}", "--spec-directory=#{coreSpecsPath}"] spawn options, (error, results, code) -> - grunt.log.writeln() + grunt.verbose.writeln() packageSpecQueue.concurrency = 2 callback(null, not error and code is 0) @@ -59,5 +59,5 @@ module.exports = (grunt) -> async.parallel [runCoreSpecs, runPackageSpecs], (error, results) -> [coreSpecPassed, packageSpecsPassed] = results elapsedTime = Math.round((Date.now() - startTime) / 100) / 10 - grunt.log.writeln("Total spec time: #{elapsedTime}s") + grunt.verbose.writeln("Total spec time: #{elapsedTime}s") done(coreSpecPassed and packageSpecsPassed) diff --git a/tasks/task-helpers.coffee b/tasks/task-helpers.coffee index 89e4c65e5..0767a94fa 100644 --- a/tasks/task-helpers.coffee +++ b/tasks/task-helpers.coffee @@ -23,7 +23,7 @@ module.exports = (grunt) -> catch error grunt.fatal(error) - grunt.log.writeln("Copied #{source.cyan} to #{destination.cyan}.") + grunt.verbose.writeln("Copied #{source.cyan} to #{destination.cyan}.") mkdir: (args...) -> grunt.file.mkdir(args...) diff --git a/tasks/update-atom-shell-task.coffee b/tasks/update-atom-shell-task.coffee index 38358920f..cbbc98e04 100644 --- a/tasks/update-atom-shell-task.coffee +++ b/tasks/update-atom-shell-task.coffee @@ -112,7 +112,7 @@ module.exports = (grunt) -> # Manually handle redirection so headers would not be sent for S3. downloadAtomShell(version, response.headers.location, callback) else if response.statusCode is 200 - grunt.log.writeln("Downloading atom-shell version #{version.cyan}") + grunt.verbose.writeln("Downloading atom-shell version #{version.cyan}") cacheDirectory = getCachePath(version) rm(cacheDirectory) mkdir(cacheDirectory) @@ -146,7 +146,7 @@ module.exports = (grunt) -> downloadAtomShell version, url, callback unzipAtomShell = (zipPath, callback) -> - grunt.log.writeln('Unzipping atom-shell') + grunt.verbose.writeln('Unzipping atom-shell') directoryPath = path.dirname(zipPath) if process.platform is 'darwin' @@ -167,7 +167,7 @@ module.exports = (grunt) -> rebuildNativeModules = (previousVersion, callback) -> newVersion = getAtomShellVersion() if newVersion and newVersion isnt previousVersion - grunt.log.writeln("Rebuilding native modules for new atom-shell version #{newVersion.cyan}.") + grunt.verbose.writeln("Rebuilding native modules for new atom-shell version #{newVersion.cyan}.") cmd = path.join('node_modules', '.bin', 'apm') cmd += ".cmd" if process.platform is 'win32' spawn {cmd, args: ['rebuild']}, (error) -> callback(error) @@ -186,7 +186,7 @@ module.exports = (grunt) -> currentAtomShellVersion = getAtomShellVersion() if atomShellVersion isnt currentAtomShellVersion if isAtomShellVersionCached(atomShellVersion) - grunt.log.writeln("Installing cached atom-shell #{atomShellVersion.cyan}") + grunt.verbose.writeln("Installing cached atom-shell #{atomShellVersion.cyan}") installAtomShell(atomShellVersion) rebuildNativeModules(currentAtomShellVersion, done) else @@ -198,7 +198,7 @@ module.exports = (grunt) -> if error? done(error) else - grunt.log.writeln("Installing atom-shell #{atomShellVersion.cyan}") + grunt.verbose.writeln("Installing atom-shell #{atomShellVersion.cyan}") installAtomShell(atomShellVersion) rebuildNativeModules(currentAtomShellVersion, done) else From f67e9b6e03f3548ea4061942d2042ab7cf2aac57 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Wed, 13 Nov 2013 17:52:22 -0800 Subject: [PATCH 2/8] Treat all calls to grunt.log.writeln as grunt.verbose.writeln --- Gruntfile.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index ae0388930..eddda26b6 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -8,6 +8,9 @@ _ = require 'underscore-plus' packageJson = require './package.json' module.exports = (grunt) -> + if not grunt.option('verbose') + grunt.log.writeln = (args...) -> grunt.log + [major, minor, patch] = packageJson.version.split('.') if process.platform is 'win32' appName = 'Atom' From 8ea011597c3b6515f51466306351765530ec50fb Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 14 Nov 2013 09:01:54 -0800 Subject: [PATCH 3/8] Don't log start time when running specs --- src/browser/main.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/main.coffee b/src/browser/main.coffee index fddece1d4..5bce464ed 100644 --- a/src/browser/main.coffee +++ b/src/browser/main.coffee @@ -62,7 +62,7 @@ delegate.browserMainParts.preMainMessageLoopRun = -> AtomApplication = require './atom-application' AtomApplication.open(args) - console.log("App load time: #{Date.now() - startTime}ms") + console.log("App load time: #{Date.now() - startTime}ms") unless args.test global.devResourcePath = path.join(app.getHomeDir(), 'github', 'atom') From 389b2bd8d6c9897ca4e1a78e76b6213918902d8b Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 14 Nov 2013 09:03:58 -0800 Subject: [PATCH 4/8] Remove spec suite measuring. This may be a bit aggressive, so we can add it back if people think it has benifits. --- spec/spec-suite.coffee | 87 +++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/spec/spec-suite.coffee b/spec/spec-suite.coffee index 599cf1d7a..391dbfba7 100644 --- a/spec/spec-suite.coffee +++ b/spec/spec-suite.coffee @@ -1,54 +1,53 @@ -measure 'spec suite require time', -> - {_, fs, Git} = require 'atom' - path = require 'path' - require './spec-helper' +{_, fs, Git} = require 'atom' +path = require 'path' +require './spec-helper' - requireSpecs = (specDirectory, specType) -> - for specFilePath in fs.listTreeSync(specDirectory) when /-spec\.coffee$/.test specFilePath - require specFilePath +requireSpecs = (specDirectory, specType) -> + for specFilePath in fs.listTreeSync(specDirectory) when /-spec\.coffee$/.test specFilePath + require specFilePath - # Set spec directory on spec for setting up the project in spec-helper - setSpecDirectory(specDirectory) + # Set spec directory on spec for setting up the project in spec-helper + setSpecDirectory(specDirectory) - setSpecField = (name, value) -> - specs = jasmine.getEnv().currentRunner().specs() - return if specs.length is 0 - for index in [specs.length-1..0] - break if specs[index][name]? - specs[index][name] = value +setSpecField = (name, value) -> + specs = jasmine.getEnv().currentRunner().specs() + return if specs.length is 0 + for index in [specs.length-1..0] + break if specs[index][name]? + specs[index][name] = value - setSpecType = (specType) -> - setSpecField('specType', specType) +setSpecType = (specType) -> + setSpecField('specType', specType) - setSpecDirectory = (specDirectory) -> - setSpecField('specDirectory', specDirectory) +setSpecDirectory = (specDirectory) -> + setSpecField('specDirectory', specDirectory) - runAllSpecs = -> - # Only run core specs when resource path is the Atom repository - if Git.exists(window.resourcePath) - requireSpecs(path.join(window.resourcePath, 'spec')) - setSpecType('core') +runAllSpecs = -> + # Only run core specs when resource path is the Atom repository + if Git.exists(window.resourcePath) + requireSpecs(path.join(window.resourcePath, 'spec')) + setSpecType('core') - fixturesPackagesPath = path.join(__dirname, 'fixtures', 'packages') - packagePaths = atom.getAvailablePackageNames().map (packageName) -> atom.resolvePackagePath(packageName) - packagePaths = _.groupBy packagePaths, (packagePath) -> - if packagePath.indexOf("#{fixturesPackagesPath}#{path.sep}") is 0 - 'fixtures' - else if packagePath.indexOf("#{window.resourcePath}#{path.sep}") is 0 - 'bundled' - else - 'user' + fixturesPackagesPath = path.join(__dirname, 'fixtures', 'packages') + packagePaths = atom.getAvailablePackageNames().map (packageName) -> atom.resolvePackagePath(packageName) + packagePaths = _.groupBy packagePaths, (packagePath) -> + if packagePath.indexOf("#{fixturesPackagesPath}#{path.sep}") is 0 + 'fixtures' + else if packagePath.indexOf("#{window.resourcePath}#{path.sep}") is 0 + 'bundled' + else + 'user' - # Run bundled package specs - requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.bundled ? [] - setSpecType('bundled') + # Run bundled package specs + requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.bundled ? [] + setSpecType('bundled') - # Run user package specs - requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.user ? [] - setSpecType('user') + # Run user package specs + requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.user ? [] + setSpecType('user') - if specDirectory = atom.getLoadSettings().specDirectory - requireSpecs(specDirectory) - setSpecType('user') - else - runAllSpecs() +if specDirectory = atom.getLoadSettings().specDirectory + requireSpecs(specDirectory) + setSpecType('user') +else + runAllSpecs() From 53f5e9fbc63bbdbd9017ef694aeb3a72fe951a87 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 14 Nov 2013 10:53:19 -0800 Subject: [PATCH 5/8] Quite some grunt.log.write --- Gruntfile.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index eddda26b6..7e8b30bb2 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -10,6 +10,7 @@ packageJson = require './package.json' module.exports = (grunt) -> if not grunt.option('verbose') grunt.log.writeln = (args...) -> grunt.log + grunt.log.write = (args...) -> grunt.log [major, minor, patch] = packageJson.version.split('.') if process.platform is 'win32' From 6bb3a69410209c51c9d3b0c48b5900a69b674580 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 14 Nov 2013 10:54:25 -0800 Subject: [PATCH 6/8] Only show stderr if the process fails --- tasks/task-helpers.coffee | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tasks/task-helpers.coffee b/tasks/task-helpers.coffee index 0767a94fa..4362393d0 100644 --- a/tasks/task-helpers.coffee +++ b/tasks/task-helpers.coffee @@ -32,9 +32,18 @@ module.exports = (grunt) -> grunt.file.delete(args..., force: true) if grunt.file.exists(args...) spawn: (options, callback) -> - grunt.util.spawn options, (error, results, code) -> - grunt.log.errorlns results.stderr if results.stderr - callback(error, results, code) + childProcess = require 'child_process' + stdout = [] + stderr = [] + error = null + proc = childProcess.spawn(options.cmd, options.args, options.opts) + proc.stdout.on 'data', (data) -> stdout.push(data.toString()) + proc.stderr.on 'data', (data) -> stderr.push(data.toString()) + proc.on 'exit', (exitCode, signal) -> + error = new Error(signal) if exitCode != 0 + results = {stderr: stderr.join(''), stdout: stdout.join(''), code: exitCode} + grunt.log.error results.stderr if exitCode != 0 + callback(error, results, exitCode) isAtomPackage: (packagePath) -> try From ed030a54c38ecd1f175576629b3fd4239fa94948 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 14 Nov 2013 10:54:49 -0800 Subject: [PATCH 7/8] Output which package failed --- tasks/spec-task.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tasks/spec-task.coffee b/tasks/spec-task.coffee index 6d3760d86..23f4048db 100644 --- a/tasks/spec-task.coffee +++ b/tasks/spec-task.coffee @@ -23,10 +23,11 @@ module.exports = (grunt) -> opts: cwd: packagePath env: _.extend({}, process.env, ATOM_PATH: rootDir) - grunt.verbose.writeln("Launching #{path.basename(packagePath)} specs.") + grunt.verbose.writeln "Launching #{path.basename(packagePath)} specs." spawn options, (error, results, code) -> - grunt.verbose.writeln() - passed = passed and not error and code is 0 + if error + passed = false + grunt.log.error "#{path.basename(packagePath)} specs failed" callback() modulesDirectory = path.resolve('node_modules') @@ -49,13 +50,13 @@ module.exports = (grunt) -> cmd: appPath args: ['--test', "--resource-path=#{resourcePath}", "--spec-directory=#{coreSpecsPath}"] spawn options, (error, results, code) -> - grunt.verbose.writeln() packageSpecQueue.concurrency = 2 - callback(null, not error and code is 0) + callback(null, not error) grunt.registerTask 'run-specs', 'Run the specs', -> done = @async() startTime = Date.now() + async.parallel [runCoreSpecs, runPackageSpecs], (error, results) -> [coreSpecPassed, packageSpecsPassed] = results elapsedTime = Math.round((Date.now() - startTime) / 100) / 10 From 8bdc1d2418a0fe19f54fa3bcace1d4cafbe5ea25 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 14 Nov 2013 11:12:19 -0800 Subject: [PATCH 8/8] Better error messages --- tasks/spec-task.coffee | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tasks/spec-task.coffee b/tasks/spec-task.coffee index 23f4048db..f19b61478 100644 --- a/tasks/spec-task.coffee +++ b/tasks/spec-task.coffee @@ -2,6 +2,7 @@ fs = require 'fs' path = require 'path' _ = require 'underscore-plus' + async = require 'async' module.exports = (grunt) -> @@ -10,7 +11,7 @@ module.exports = (grunt) -> packageSpecQueue = null runPackageSpecs = (callback) -> - passed = true + failedPackages = [] rootDir = grunt.config.get('atom.shellAppDir') appDir = grunt.config.get('atom.appDir') atomPath = path.join(appDir, 'atom.sh') @@ -25,9 +26,8 @@ module.exports = (grunt) -> env: _.extend({}, process.env, ATOM_PATH: rootDir) grunt.verbose.writeln "Launching #{path.basename(packagePath)} specs." spawn options, (error, results, code) -> - if error - passed = false - grunt.log.error "#{path.basename(packagePath)} specs failed" + + failedPackages.push path.basename(packagePath) if error callback() modulesDirectory = path.resolve('node_modules') @@ -38,7 +38,7 @@ module.exports = (grunt) -> packageSpecQueue.push(packagePath) packageSpecQueue.concurrency = 1 - packageSpecQueue.drain = -> callback(null, passed) + packageSpecQueue.drain = -> callback(null, failedPackages) runCoreSpecs = (callback) -> contentsDir = grunt.config.get('atom.contentsDir') @@ -51,14 +51,19 @@ module.exports = (grunt) -> args: ['--test', "--resource-path=#{resourcePath}", "--spec-directory=#{coreSpecsPath}"] spawn options, (error, results, code) -> packageSpecQueue.concurrency = 2 - callback(null, not error) + callback(null, error) grunt.registerTask 'run-specs', 'Run the specs', -> done = @async() startTime = Date.now() async.parallel [runCoreSpecs, runPackageSpecs], (error, results) -> - [coreSpecPassed, packageSpecsPassed] = results + [coreSpecFailed, failedPackages] = results elapsedTime = Math.round((Date.now() - startTime) / 100) / 10 grunt.verbose.writeln("Total spec time: #{elapsedTime}s") - done(coreSpecPassed and packageSpecsPassed) + failures = failedPackages + failures.push "atom core" if coreSpecFailed + + grunt.log.error("[Error]".red + " #{failures.join(', ')} spec(s) failed") if failures.length > 0 + + done(!coreSpecFailed and failedPackages.length == 0)