forked from mozilla-b2g/gaia
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 972160 - Run specific marionette tests for 30 times on Travis.
- Loading branch information
Showing
6 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
'use strict'; | ||
|
||
var request = require('request'), | ||
childProcess = require('child_process'); | ||
|
||
var PULL_REQUEST_URL_PATTERN = | ||
'https://api.github.com/repos/mozilla-b2g/gaia/pulls/[id]/files', | ||
MARIONETTE_TEST_FILE_NAME_PATTERN = | ||
/apps\/[a-z]+\/test\/marionette\/\w+_test.js/; | ||
|
||
/** | ||
* Get file name list of marionette test in the current pull request on Travis. | ||
*/ | ||
var PullRequestMarionetteTest = (function() { | ||
/** | ||
* Get files in a pull request. | ||
* | ||
* @param {String|Number} id The pull request id. | ||
* @param {Function} callback Function with the pull request files array. | ||
*/ | ||
function getPullRequestFiles(id, callback) { | ||
// Configure the request | ||
var options = { | ||
url: PULL_REQUEST_URL_PATTERN.replace('[id]', id), | ||
method: 'GET', | ||
headers: { 'User-Agent': 'FirefoxOS-Gaia-Travis' } | ||
}; | ||
|
||
request(options, function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
var json = JSON.parse(body), | ||
fileNames = []; | ||
|
||
json.forEach(function(file) { | ||
fileNames.push(file.filename); | ||
}); | ||
if (callback && typeof(callback) === 'function') { | ||
callback(fileNames); | ||
} | ||
} else { | ||
throw new Error('Cannot access GitHub API.'); | ||
} | ||
}); | ||
} | ||
|
||
// Main function. | ||
function execute() { | ||
// Pull request ID for the current Travis job. | ||
var pullRequestId = process.env.TRAVIS_PULL_REQUEST; | ||
|
||
getPullRequestFiles(pullRequestId, function(fileNames) { | ||
var testFileNames = [], | ||
returnString = ''; | ||
|
||
testFileNames = fileNames.filter(function getMarionetteTestFileNames(element) { | ||
return element.match(MARIONETTE_TEST_FILE_NAME_PATTERN); | ||
}); | ||
if (testFileNames.length > 0) { | ||
returnString = testFileNames.toString().split(',').join(' '); | ||
} | ||
console.log(returnString); | ||
}); | ||
} | ||
|
||
return { | ||
execute: execute | ||
}; | ||
})(); | ||
|
||
exports.execute = PullRequestMarionetteTest.execute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#! /bin/bash -ve | ||
|
||
echo "Downloading b2g-desktop" | ||
make b2g | ||
|
||
echo "Building test profile" | ||
PROFILE_FOLDER=profile-test make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /bin/bash -v | ||
|
||
############################################################################### | ||
# For stable marionette tests, # | ||
# we run specfic marionette tests for 30 times on Travis. # | ||
############################################################################### | ||
|
||
MARIONETTE_TEST_FILE_NAMES=$(make pull-request-marionette-test) | ||
|
||
if [ ${#MARIONETTE_TEST_FILE_NAMES} -gt 0 ]; then | ||
RUN_SPECIFIC_TESTS="make test-integration TEST_FILES=\"$MARIONETTE_TEST_FILE_NAMES\" REPORTER=spec" | ||
|
||
for i in {1..30} | ||
do | ||
eval ${RUN_SPECIFIC_TESTS} | ||
done | ||
else | ||
echo "The pull request has no marionette test to run." | ||
fi |