From 8acfd20ea4fe6883fd32c8731bb72d2724cab5fe Mon Sep 17 00:00:00 2001 From: Ricky Chien Date: Thu, 15 May 2014 23:03:45 +0800 Subject: [PATCH] Bug 1006357 - make test agent to run tests from all apps locally and in travis --- Makefile | 5 +- build/preferences.js | 19 ++--- build/test-agent-bootstrap.js | 2 +- build/test/unit/preference.test.js | 109 ++++++++++++------------ tools/extensions/httpd/bootstrap.js | 3 +- tools/extensions/httpd/content/httpd.js | 11 +-- 6 files changed, 75 insertions(+), 74 deletions(-) diff --git a/Makefile b/Makefile index 1b993087867b..b6feaab661e4 100644 --- a/Makefile +++ b/Makefile @@ -360,6 +360,8 @@ GAIA_APP_CONFIG := /tmp/gaia-apps-temp.list $(warning GAIA_APP_SRCDIRS is deprecated, please use GAIA_APP_CONFIG) endif +GAIA_ALLAPPDIRS=$(shell find $(GAIA_DIR)$(SEP)apps $(GAIA_DIR)$(SEP)dev_apps -maxdepth 1 -mindepth 1 -type d | sed 's@[/\\]@$(SEP_FOR_SED)@g') + GAIA_APPDIRS=$(shell while read LINE; do \ if [ "$${LINE\#$${LINE%?}}" = "*" ]; then \ srcdir="`echo "$$LINE" | sed 's/.\{2\}$$//'`"; \ @@ -462,6 +464,7 @@ define BUILD_CONFIG "GAIA_ENGINE" : "xpcshell", \ "GAIA_DISTRIBUTION_DIR" : "$(GAIA_DISTRIBUTION_DIR)", \ "GAIA_APPDIRS" : "$(GAIA_APPDIRS)", \ + "GAIA_ALLAPPDIRS" : "$(GAIA_ALLAPPDIRS)", \ "NOFTU" : "$(NOFTU)", \ "REMOTE_DEBUGGER" : "$(REMOTE_DEBUGGER)", \ "HAIDA" : $(HAIDA), \ @@ -847,7 +850,7 @@ ifeq ($(BUILD_APP_NAME),*) @touch $(TEST_AGENT_CONFIG) @rm -f /tmp/test-agent-config; @# Build json array of all test files - @for d in ${GAIA_APPDIRS}; \ + @for d in ${GAIA_ALLAPPDIRS}; \ do \ parent="`dirname $$d`"; \ pathlen=`expr $${#parent} + 2`; \ diff --git a/build/preferences.js b/build/preferences.js index 0eb1876e734f..5acb0cbaca3b 100644 --- a/build/preferences.js +++ b/build/preferences.js @@ -45,12 +45,11 @@ PreferencesBuilder.prototype.preparePref = function() { this.prefs['browser.homescreenURL'] = this.system; this.prefs['b2g.system_startup_url'] = this.system; - this.domains = []; - this.domains.push(this.config.GAIA_DOMAIN); - - this.gaia.webapps.forEach(function(webapp) { - this.domains.push(webapp.domain); - }.bind(this)); + this.domains = [this.config.GAIA_DOMAIN]; + this.config.GAIA_ALLAPPDIRS.split(' ').forEach(function(appdir) { + this.domains.push(utils.getFile(appdir).leafName + '.' + + this.config.GAIA_DOMAIN); + }, this); this.prefs['network.http.max-connections-per-server'] = 15; this.prefs['dom.mozInputMethod.enabled'] = true; @@ -196,6 +195,7 @@ PreferencesBuilder.prototype.setDebugPref = function() { this.prefs['extensions.gaia.port'] = parseInt(this.config.GAIA_PORT.replace(/:/g, ''), 10); this.prefs['extensions.gaia.appdirs'] = this.config.GAIA_APPDIRS; + this.prefs['extensions.gaia.allappdirs'] = this.config.GAIA_ALLAPPDIRS; this.prefs['extensions.gaia.locales_debug_path'] = this.config.GAIA_LOCALES_PATH; this.prefs['extensions.gaia.official'] = Boolean(this.config.OFFICIAL); @@ -207,13 +207,6 @@ PreferencesBuilder.prototype.setDebugPref = function() { var suffix = this.config.GAIA_DEV_PIXELS_PER_PX === '1' ? '' : '@' + this.config.GAIA_DEV_PIXELS_PER_PX + 'x'; this.prefs['extensions.gaia.device_pixel_suffix'] = suffix; - - var appPathList = []; - this.gaia.webapps.forEach(function(webapp) { - appPathList.push(webapp.sourceAppDirectoryName + '/' + - webapp.sourceDirectoryName); - }); - this.prefs['extensions.gaia.app_relative_path'] = appPathList.join(' '); this.prefs['extensions.autoDisableScopes'] = 0; }; diff --git a/build/test-agent-bootstrap.js b/build/test-agent-bootstrap.js index 04b14a7d1755..6489079f2f91 100644 --- a/build/test-agent-bootstrap.js +++ b/build/test-agent-bootstrap.js @@ -21,7 +21,7 @@ exports.execute = function(options) { var sandboxFile = srcDir.clone(); sandboxFile.append('_sandbox.html'); - options.GAIA_APPDIRS.split(' ').forEach(function(appPath) { + options.GAIA_ALLAPPDIRS.split(' ').forEach(function(appPath) { var testDir = utils.getFile(appPath, 'test'); var unitDir = testDir.clone(); unitDir.append('unit'); diff --git a/build/test/unit/preference.test.js b/build/test/unit/preference.test.js index f181d4aeeeb1..ad9ffbfbfc17 100644 --- a/build/test/unit/preference.test.js +++ b/build/test/unit/preference.test.js @@ -199,59 +199,61 @@ suite('preferences.js', function() { 'font.name-list.sans-serif.x-western': 'Fira Sans, Roboto', 'extensions.autoDisableScopes': 0 }); + }); - test('editDebugPref', function () { - preferences.system = 'testSystem'; - preferences.config = { - GAIA_DIR: 'testGaiaDir', - GAIA_DOMAIN: 'testGaiaDomain', - GAIA_PORT: ':8080', - GAIA_APPDIRS: 'testAppDirs', - GAIA_LOCALES_PATH: 'testLocalesPath', - OFFICIAL: 1, - LOCALES_FILE: 'testLocaleFile', - LOCALE_BASEDIR: 'testLocaleBaseDir', - GAIA_DEV_PIXELS_PER_PX: 2 - }; - preferences.gaia = { - webapps: [ - { - sourceAppDirectoryName: 'testSourceName', - sourceDirectoryName: 'testDirName' - } - ] - }; - preferences.prefs = {}; - preferences.setDebugPref(); - assert.deepEqual(preferences.prefs, { - 'docshell.device_size_is_page_size': true, - 'marionette.defaultPrefs.enabled': true, - 'nglayout.debug.disable_xul_cache': true, - 'nglayout.debug.disable_xul_fastload': true, - 'javascript.options.showInConsole': true, - 'browser.dom.window.dump.enabled': true, - 'dom.report_all_js_exceptions': true, - 'dom.w3c_touch_events.enabled': 1, - 'dom.promise.enabled': true, - 'dom.wakelock.enabled': true, - 'image.mozsamplesize.enabled': true, - 'webgl.verbose': true, - 'dom.max_script_run_time': 0, - 'network.http.use-cache': false, - 'extensions.gaia.dir': preferences.config.GAIA_DIR, - 'extensions.gaia.domain': preferences.config.GAIA_DOMAIN, - 'extensions.gaia.port': 8080, - 'extensions.gaia.appdirs': preferences.config.GAIA_APPDIRS, - 'extensions.gaia.locales_debug_path': - preferences.config.GAIA_LOCALES_PATH, - 'extensions.gaia.official': true, - 'extensions.gaia.locales_file': preferences.config.LOCALES_FILE, - 'extensions.gaia.locale_basedir': preferences.config.LOCALE_BASEDIR, - 'extensions.gaia.device_pixel_suffix': - '@' + preferences.config.GAIA_DEV_PIXELS_PER_PX + 'x', - 'extensions.gaia.app_relative_path': 'testSourceName/testDirName', - 'extensions.autoDisableScopes': 0 - }); + test('editDebugPref', function () { + preferences.homescreen = 'testHomescreen'; + preferences.config = { + GAIA_DIR: 'testGaiaDir', + GAIA_DOMAIN: 'testGaiaDomain', + GAIA_PORT: ':8080', + GAIA_APPDIRS: 'testAppDirs', + GAIA_ALLAPPDIRS: 'testAppDir1 testAppDir2', + GAIA_LOCALES_PATH: 'testLocalesPath', + OFFICIAL: 1, + LOCALES_FILE: 'testLocaleFile', + LOCALE_BASEDIR: 'testLocaleBaseDir', + GAIA_DEV_PIXELS_PER_PX: 2 + }; + preferences.gaia = { + webapps: [ + { + sourceAppDirectoryName: 'testSourceName', + sourceDirectoryName: 'testDirName' + } + ] + }; + preferences.prefs = {}; + preferences.setDebugPref(); + assert.deepEqual(preferences.prefs, { + 'docshell.device_size_is_page_size': true, + 'marionette.defaultPrefs.enabled': true, + 'nglayout.debug.disable_xul_cache': true, + 'nglayout.debug.disable_xul_fastload': true, + 'javascript.options.showInConsole': true, + 'browser.dom.window.dump.enabled': true, + 'dom.report_all_js_exceptions': true, + 'dom.w3c_touch_events.enabled': 1, + 'dom.promise.enabled': true, + 'dom.wakelock.enabled': true, + 'image.mozsamplesize.enabled': true, + 'webgl.verbose': true, + 'dom.max_script_run_time': 0, + 'toolkit.identity.debug': true, + 'network.http.use-cache': false, + 'extensions.gaia.dir': preferences.config.GAIA_DIR, + 'extensions.gaia.domain': preferences.config.GAIA_DOMAIN, + 'extensions.gaia.port': 8080, + 'extensions.gaia.appdirs': preferences.config.GAIA_APPDIRS, + 'extensions.gaia.allappdirs': preferences.config.GAIA_ALLAPPDIRS, + 'extensions.gaia.locales_debug_path': + preferences.config.GAIA_LOCALES_PATH, + 'extensions.gaia.official': true, + 'extensions.gaia.locales_file': preferences.config.LOCALES_FILE, + 'extensions.gaia.locale_basedir': preferences.config.LOCALE_BASEDIR, + 'extensions.gaia.device_pixel_suffix': + '@' + preferences.config.GAIA_DEV_PIXELS_PER_PX + 'x', + 'extensions.autoDisableScopes': 0 }); }); @@ -301,7 +303,8 @@ suite('preferences.js', function() { preferences.config = { SYSTEM: 'app://system', GAIA_PORT: 8000, - GAIA_DOMAIN: 'domain' + GAIA_DOMAIN: 'domain', + GAIA_ALLAPPDIRS: 'testAppDir1 testAppDir2' }; preferences.prefs = {}; diff --git a/tools/extensions/httpd/bootstrap.js b/tools/extensions/httpd/bootstrap.js index 116ee230351e..6319308809e5 100644 --- a/tools/extensions/httpd/bootstrap.js +++ b/tools/extensions/httpd/bootstrap.js @@ -27,6 +27,7 @@ function startup(data, reason) { const LANG_EN = 'en-US'; const GAIA_DOMAIN = Services.prefs.getCharPref("extensions.gaia.domain"); const GAIA_APPDIRS = Services.prefs.getCharPref("extensions.gaia.appdirs"); + const GAIA_ALLAPPDIRS = Services.prefs.getCharPref("extensions.gaia.allappdirs"); const GAIA_DIR = Services.prefs.getCharPref("extensions.gaia.dir"); const GAIA_PORT = Services.prefs.getIntPref("extensions.gaia.port"); const GAIA_OFFICIAL = Services.prefs.getBoolPref("extensions.gaia.official"); @@ -73,7 +74,7 @@ function startup(data, reason) { let host = GAIA_DOMAIN; identity.add(scheme, host, port); - let directories = getDirectories(GAIA_APPDIRS.split(' ')); + let directories = getDirectories(GAIA_ALLAPPDIRS.split(' ')); directories.forEach(function appendDir(name) { // Some app names can cause a raise here, preventing other apps // from being added. diff --git a/tools/extensions/httpd/content/httpd.js b/tools/extensions/httpd/content/httpd.js index dd4f2737ab1e..aada08ea5d9c 100644 --- a/tools/extensions/httpd/content/httpd.js +++ b/tools/extensions/httpd/content/httpd.js @@ -43,7 +43,8 @@ // GAIA- Components.utils.import('resource://gre/modules/Services.jsm'); const GAIA_DOMAIN = Services.prefs.getCharPref("extensions.gaia.domain"); -const GAIA_APP_RELATIVEPATH = Services.prefs.getCharPref("extensions.gaia.app_relative_path"); +const GAIA_DIR = Services.prefs.getCharPref("extensions.gaia.dir"); +const GAIA_ALLAPPDIRS = Services.prefs.getCharPref("extensions.gaia.allappdirs"); const GAIA_LOCALES_PATH = Services.prefs.getCharPref("extensions.gaia.locales_debug_path"); const GAIA_DEVICE_PIXEL_SUFFIX = Services.prefs.getCharPref("extensions.gaia.device_pixel_suffix"); // -GAIA @@ -1523,7 +1524,6 @@ RequestReader.prototype = /** * Try to find out real path of apps, - * according to GAIA_APP_RELATIVEPATH provided by Makefile. */ _findRealPath: function(appName) { if (this._realPath) { @@ -1532,15 +1532,16 @@ RequestReader.prototype = this._realPath = {}; - var appPathList = GAIA_APP_RELATIVEPATH.trim().split(" "); + var appPathList = GAIA_ALLAPPDIRS.trim().split(" "); for (var i = 0; i < appPathList.length; i++) { - var currentAppName = appPathList[i].split("/")[1]; + var relativePath = appPathList[i].substr(GAIA_DIR.length + 1), + currentAppName = relativePath.split("/")[1]; if (!currentAppName) { continue; } - this._realPath[currentAppName] = appPathList[i]; + this._realPath[currentAppName] = relativePath; } return "/" + this._realPath[appName]; },