Permalink
Browse files

port tools/run_tests.sh

  • Loading branch information...
1 parent a3522f0 commit e13fc32892a3be9bddb8868ba2ed7a13dace68ad @jasonsanjose jasonsanjose committed Mar 20, 2013
Showing with 3,161 additions and 83 deletions.
  1. +13 −0 Gruntfile.js
  2. +1 −1 package.json
  3. +3,046 −0 results.json
  4. +1 −1 src/config.json
  5. +1 −1 tasks/build.js
  6. +34 −5 tasks/lib/common.js
  7. +63 −0 tasks/test.js
  8. +1 −1 tasks/update-sprint-number.js
  9. +1 −1 tasks/write-config.js
  10. +0 −73 tools/run_tests.sh
View
13 Gruntfile.js
@@ -24,8 +24,11 @@
module.exports = function (grunt) {
'use strict';
+ var common = require("./tasks/lib/common")(grunt);
+
// Project configuration.
grunt.initConfig({
+ pkg : grunt.file.readJSON("package.json"),
meta : {
src : [
'src/**/*.js',
@@ -47,6 +50,10 @@ module.exports = function (grunt) {
'!test/temp/**',
'!test/thirdparty/**'
],
+ grunt: [
+ 'Gruntfile.js',
+ 'tasks/**/*.js'
+ ],
/* specs that can run in phantom.js */
specs : [
'test/spec/CommandManager-test.js',
@@ -103,10 +110,16 @@ module.exports = function (grunt) {
'<%= meta.src %>',
'<%= meta.test %>'
],
+ grunt: "<%= meta.grunt %>",
/* use strict options to mimic JSLINT until we migrate to JSHINT in Brackets */
options: {
jshintrc: '.jshintrc'
}
+ },
+ shell: {
+ repo: grunt.option("shell-repo") || "../brackets-shell",
+ mac: "<%= shell.repo %>/installer/mac/staging/<%= pkg.name %>.app",
+ win: "<%= shell.repo %>/installer/win/staging/<%= pkg.name %>.exe"
}
});
View
2 package.json
@@ -17,7 +17,7 @@
"grunt-cli": "~0.1.0",
"grunt-contrib-jshint": "~0.2.0",
"grunt-contrib-watch": "~0.2.0",
- "grunt-contrib-jasmine": "~0.3.0",
+ "grunt-contrib-jasmine": "~0.4.0",
"grunt-template-jasmine-requirejs": "~0.1.0",
"q": "~0.9.0"
},
View
3,046 results.json
3,046 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 src/config.json
@@ -32,7 +32,7 @@
"grunt-cli": "~0.1.0",
"grunt-contrib-jshint": "~0.2.0",
"grunt-contrib-watch": "~0.2.0",
- "grunt-contrib-jasmine": "~0.3.0",
+ "grunt-contrib-jasmine": "~0.4.0",
"grunt-template-jasmine-requirejs": "~0.1.0",
"q": "~0.9.0"
},
View
2 tasks/build.js
@@ -20,7 +20,7 @@
* DEALINGS IN THE SOFTWARE.
*
*/
-/*global module, require*/
+/*global module, require, process*/
module.exports = function (grunt) {
"use strict";
View
39 tasks/lib/common.js
@@ -20,10 +20,39 @@
* DEALINGS IN THE SOFTWARE.
*
*/
- /*global module, require*/
+ /*global module, require, process*/
+module.exports = function (grunt) {
+ "use strict";
-function writeJSON(grunt, path, obj) {
- grunt.file.write(path, JSON.stringify(obj, null, " "));
-}
+ var common = {},
+ path = require("path"),
+ _platform;
+
+ function writeJSON(grunt, path, obj) {
+ grunt.file.write(path, JSON.stringify(obj, null, " "));
+ }
-module.exports.writeJSON = writeJSON;
+ function resolve(relPath) {
+ return path.resolve(process.cwd(), relPath);
+ }
+
+ function platform() {
+ if (!_platform) {
+ if (process.platform === "darwin") {
+ _platform = "mac";
+ } else if (process.platform === "win32") {
+ _platform = "win";
+ } else {
+ _platform = "linux";
+ }
+ }
+
+ return _platform;
+ }
+
+ common.writeJSON = writeJSON;
+ common.resolve = resolve;
+ common.platform = platform;
+
+ return common;
+};
View
63 tasks/test.js
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+/*global module, require, process*/
+
+module.exports = function (grunt) {
+ "use strict";
+
+ var common = require("./lib/common")(grunt),
+ child_process = require("child_process"),
+ q = require("q"),
+ qexec = q.denodeify(child_process.exec);
+
+ // task: test-integration
+ grunt.registerTask("test-integration", "Run tests in brackets-shell", function () {
+ var done = this.async(),
+ platform = common.platform(),
+ opts = { cwd: process.cwd() },
+ cmd = common.resolve(grunt.option("shell") || grunt.config("shell." + platform)),
+ spec = grunt.option("spec") || "all",
+ results = grunt.option("results") || process.cwd() + "/results.json",
+ resultsPath = common.resolve(results),
+ specRunnerPath = common.resolve("test/SpecRunner.html");
+
+ if (platform === "win") {
+ cmd += " --startup-path=" + specRunnerPath + "?spec=" + spec + "^&resultsPath=" + encodeURIComponent(resultsPath);
+ } else if (platform === "mac") {
+ cmd = "open \"" + cmd + "\" --args --startup-path=" + specRunnerPath + "?spec=" + spec + "&resultsPath=" + encodeURIComponent(resultsPath);
+ }
+
+ grunt.log.writeln(cmd);
+
+ qexec(cmd, opts).then(function (stdout, stderr) {
+ done();
+ }, function (err) {
+ grunt.log.writeln(err);
+ done(false);
+ });
+ });
+
+ function execTest(task, platform) {
+ }
+
+};
View
2 tasks/update-sprint-number.js
@@ -25,7 +25,7 @@
module.exports = function (grunt) {
"use strict";
- var common = require("./lib/common");
+ var common = require("./lib/common")(grunt);
// task: update-sprint-number
// Updates the version property in package.json
View
2 tasks/write-config.js
@@ -24,7 +24,7 @@
module.exports = function (grunt) {
"use strict";
- var common = require("./lib/common");
+ var common = require("./lib/common")(grunt);
// task: write-config
grunt.registerTask("write-config", "Merge package.json and src/brackets.config.json into src/config.json", function () {
View
73 tools/run_tests.sh
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-# Make sure the appname was passed in and is valid
-if [[ ${1} == "" ]]; then
- echo "Usage: run_tests.sh <application> <results_path> <spec_name>"
- echo "Runs unit tests for Brackets"
- echo ""
- echo "Parameters: application - full path to the Brackets application"
- echo " results_path - path to output JSON results (defaults to results.json in current dir)"
- echo " ~ tilde will expand, use URL encoding otherwise. Slashes are ok."
- echo " spec_name - name of the suite or spec to run (default: all)"
- if [[ "$OSTYPE" == "msys"* ]]; then
- echo "Example: ./run_tests.sh /c/Program\ Files\ \(x86\)/Brackets\ Sprint\ 16/Brackets.exe /c/Brackets%20Results/results.json all"
- else
- echo "Example: ./run_tests.sh /Applications/Brackets\ Sprint\ 16.app ~/Desktop/Brackets%20Results/results.json all"
- fi
- exit;
-fi
-
-# Check for Brackets.exe file on windows, Brackets.app directory on mac
-if [[ "$OSTYPE" == "msys"* && ! -f "${1}" ]]; then
- echo "$1 not found."
- exit;
-elif [[ "$OSTYPE" == "darwin"* && ! -d "${1}" ]]; then
- echo "$1 not found."
- exit;
-fi
-
-# JSON results file path
-results_path="${PWD}/results.json"
-if [[ ${2} != "" ]]; then
- results_path="${2}"
-fi
-
-# Check if results.json file already exists
-if [[ -f "${results_path}" ]]; then
- echo "File $results_path already exists. Choose another results JSON file destination."
- exit;
-fi
-
-# Spec name filter
-spec_name="all"
-if [[ ${3} != "" ]]; then
- spec_name="${3}"
-fi
-
-# Get the full path of this script
-if [[ ${0} == /* ]]; then
- full_path="$0"
-else
- full_path="${PWD}/${0#./}"
-fi;
-
-# Remove /tools/run_tests.sh to get the root directory
-root_dir=${full_path%/*/*}
-
-# Fix drive letter
-# TODO regex match drive letter
-if [[ "$OSTYPE" == "msys"* ]]; then
- root_dir=${root_dir/\/c\//c:\\}
- results_path=${results_path/\/c\//c:\\}
-fi
-
-args="--startup-path=$root_dir/test/SpecRunner.html?spec=$spec_name&resultsPath=$results_path"
-
-if [[ "$OSTYPE" == "darwin"* ]]; then
- open "${1}" --args $args
-else
- # convert slashes
- args=${args//\//\\}
- echo $args
- "${1}" $args
-fi;

0 comments on commit e13fc32

Please sign in to comment.