This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 953099 - Use mocha for integration test on build system
- Loading branch information
Showing
7 changed files
with
132 additions
and
102 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
var exec = require('child_process').exec; | ||
var assert = require('chai').assert; | ||
var rmrf = require('rimraf').sync; | ||
var download = require('download'); | ||
var async = require('async'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
function checkError(error, stdout, stderr) { | ||
if (error) { | ||
console.log('stdout: ' + stdout); | ||
console.log('stderr: ' + stderr); | ||
console.log('error: ' + error); | ||
} | ||
assert.equal(error, null); | ||
} | ||
|
||
suite('Build Integration tests', function() { | ||
var localesDir = 'tmplocales'; | ||
|
||
suiteSetup(function() { | ||
rmrf('profile'); | ||
rmrf('profile-debug'); | ||
rmrf(localesDir); | ||
}); | ||
|
||
test('make without rule & variable', function(done) { | ||
exec('make', function(error, stdout, stderr) { | ||
checkError(error, stdout, stderr); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('make with PRODUCTION=1', function(done) { | ||
exec('PRODUCTION=1 make', function(error, stdout, stderr) { | ||
checkError(error, stdout, stderr); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('make with SIMULATOR=1', function(done) { | ||
exec('SIMULATOR=1 make', function(error, stdout, stderr) { | ||
checkError(error, stdout, stderr); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('make with DEBUG=1', function(done) { | ||
exec('DEBUG=1 make', function(error, stdout, stderr) { | ||
checkError(error, stdout, stderr); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('make with MOZILLA_OFFICIAL=1', function(done) { | ||
exec('MOZILLA_OFFICIAL=1 make', function(error, stdout, stderr) { | ||
checkError(error, stdout, stderr); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('make with GAIA_DISTRIBUTION_DIR=distribution_tablet', function(done) { | ||
exec('GAIA_DISTRIBUTION_DIR=distribution_tablet make', | ||
function(error, stdout, stderr) { | ||
checkError(error, stdout, stderr); | ||
done(); | ||
} | ||
); | ||
}); | ||
|
||
test('make with l10n configuration', function(done) { | ||
var locales = ['en-US', 'zh-CN']; | ||
var localesFileObj = {}; | ||
var tasks = locales.map(function(locale) { | ||
localesFileObj[locale] = ''; | ||
return function (callback) { | ||
var dir = path.join(localesDir, locale); | ||
fs.mkdirSync(dir); | ||
var url = 'http://hg.mozilla.org/gaia-l10n/' + locale + | ||
'/archive/tip.tar.gz'; | ||
var dl = download(url, dir, {extract: true, strip: 1}); | ||
dl.once('close', function() { | ||
callback(); | ||
}); | ||
}; | ||
}); | ||
|
||
tasks.push(function(callback) { | ||
localesFilePath = path.join(localesDir, 'languages.json'); | ||
fs.writeFileSync(localesFilePath, JSON.stringify(localesFileObj)); | ||
command = 'LOCALES_FILE=' + localesFilePath + | ||
' LOCALE_BASEDIR=' + localesDir + | ||
' make'; | ||
exec(command, function(error, stdout, stderr) { | ||
checkError(error, stdout, stderr); | ||
callback(); | ||
}); | ||
}); | ||
fs.mkdirSync(localesDir); | ||
async.series(tasks, function() { | ||
rmrf(localesDir); | ||
done(); | ||
}); | ||
}); | ||
|
||
teardown(function() { | ||
rmrf('profile'); | ||
rmrf('profile-debug'); | ||
}); | ||
}); |
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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,101 +1,4 @@ | ||
#! /bin/bash | ||
|
||
# Exit if we encounter any bug | ||
set -e | ||
|
||
debugmessage='' | ||
|
||
gaia_clear () { | ||
make clean &> /dev/null | ||
} | ||
|
||
error_handler () { | ||
printf '\e[41;30m x ---- fail\e[40;37m \n' | ||
printf $debugmessage | ||
} | ||
|
||
pass_handler () { | ||
printf '\e[42;30m v ---- pass\e[40;37m \n' | ||
} | ||
|
||
unit_test () { | ||
REPORTER=dot | ||
testfiles=$(find build/test/*.test.js) | ||
echo $testfiles | ||
./node_modules/.bin/mocha \ | ||
--harmony \ | ||
--reporter $REPORTER \ | ||
--ui tdd \ | ||
$testfiles | ||
} | ||
|
||
|
||
trap error_handler ERR | ||
|
||
# Store all the distributions folder here | ||
distributions=(distribution_tablet) | ||
|
||
# Store locales test language | ||
locales=(en-US zh-CN) | ||
|
||
# Address of locale file | ||
locale_url=http://hg.mozilla.org/gaia-l10n/LOCALEURL/archive/tip.tar.gz | ||
|
||
printf 'Running unit test ...' | ||
unit_test | ||
pass_handler | ||
|
||
printf 'make ...' | ||
gaia_clear | ||
debugmessage=$(make) | ||
pass_handler | ||
|
||
printf 'PRODUCTION=1 make ... ' | ||
gaia_clear | ||
debugmessage=$(PRODUCTION=1 make) | ||
pass_handler | ||
|
||
printf 'SIMULATOR=1 make ...' | ||
gaia_clear | ||
debugmessage=$(SIMULATOR=1 make) | ||
pass_handler | ||
|
||
printf 'DEBUG=1 make ...' | ||
gaia_clear | ||
debugmessage=$(DEBUG=1 make) | ||
pass_handler | ||
|
||
printf 'GAIA_DISTRIBUTION_DIR=<distribution> make ...' | ||
for distribution in ${distributions[@]}; do | ||
gaia_clear | ||
printf '\n -DISTRIBUTION='$distribution' ... ' | ||
debugmessage=$(GAIA_DISTRIBUTION_DIR=$distribution make) | ||
pass_handler | ||
done | ||
|
||
printf 'MOZILLA_OFFICIAL=1 make ...' | ||
gaia_clear | ||
debugmessage=$(MOZILLA_OFFICIAL=1 make) | ||
pass_handler | ||
|
||
printf 'LOCALES_FILE=<PATH_OF_LOCALES_FILE> LOCALE_BASEDIR=<PATH_OF_LOCALE_BASEDIR> make ...\n' | ||
gaia_clear | ||
if [ -d 'templocale' ]; then | ||
rm -rf templocale/* | ||
else | ||
mkdir templocale | ||
fi | ||
|
||
pushd templocale &> /dev/null | ||
touch locale.json | ||
localeJSON='{' | ||
for locale in ${locales[@]}; do | ||
mkdir $locale | ||
localeJSON+="\"$locale\": \"$locale\"," | ||
curl -s ${locale_url/LOCALEURL/$locale} | tar xvz --strip-components=1 --directory=$locale &> /dev/null | ||
done | ||
localeJSON="${localeJSON%?}}" | ||
echo $localeJSON >> locale.json | ||
popd &> /dev/null | ||
debugmessage=$(LOCALES_FILE=templocale/locale.json LOCALE_BASEDIR=templocale make) | ||
pass_handler | ||
make build-test-unit | ||
make build-test-integration |