Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #19704 from RickyChien/bug-1006357
Browse files Browse the repository at this point in the history
Bug 1006357 - make test agent to run tests from all apps locally and in travis r=@yurenju
  • Loading branch information
RickyChien committed May 28, 2014
2 parents d2bdf22 + 8acfd20 commit 8d5b09f
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 74 deletions.
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -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\}$$//'`"; \
Expand Down Expand Up @@ -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), \
Expand Down Expand Up @@ -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`; \
Expand Down
19 changes: 6 additions & 13 deletions build/preferences.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion build/test-agent-bootstrap.js
Expand Up @@ -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');
Expand Down
109 changes: 56 additions & 53 deletions build/test/unit/preference.test.js
Expand Up @@ -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
});
});

Expand Down Expand Up @@ -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 = {};
Expand Down
3 changes: 2 additions & 1 deletion tools/extensions/httpd/bootstrap.js
Expand Up @@ -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");
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions tools/extensions/httpd/content/httpd.js
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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];
},
Expand Down

0 comments on commit 8d5b09f

Please sign in to comment.