1 | 'use strict';
|
2 |
|
3 | module.exports = function (grunt) {
|
4 | var browsers = [
|
5 | { browserName: 'firefox', version: '19', platform: 'XP' },
|
6 | { browserName: 'firefox', platform: 'linux' },
|
7 | { browserName: 'firefox', platform: 'OS X 10.10' },
|
8 | { browserName: 'chrome', platform: 'linux' },
|
9 | { browserName: 'chrome', platform: 'OS X 10.9' },
|
10 | { browserName: 'chrome', platform: 'XP' },
|
11 | { browserName: 'internet explorer', platform: 'Windows 8.1', version: '11' },
|
12 | { browserName: 'internet explorer', platform: 'WIN8', version: '10' },
|
13 | { browserName: 'internet explorer', platform: 'VISTA', version: '9' },
|
14 | { browserName: 'safari', platform: 'OS X 10.6' },
|
15 | { browserName: 'safari', platform: 'OS X 10.8' },
|
16 | { browserName: 'safari', platform: 'OS X 10.9' },
|
17 | { browserName: 'safari', platform: 'OS X 10.10' },
|
18 | { browserName: 'iphone', platform: 'OS X 10.9', version: '7.1' },
|
19 | { browserName: 'android', platform: 'Linux', version: '4.4' },
|
20 | ];
|
21 | var extraBrowsers = [
|
22 | { browserName: 'firefox', platform: 'linux', version: '30' },
|
23 | { browserName: 'firefox', platform: 'linux', version: '25' },
|
24 | { browserName: 'iphone', platform: 'OS X 10.8', version: '6.1' },
|
25 | { browserName: 'iphone', platform: 'OS X 10.8', version: '5.1' },
|
26 | { browserName: 'android', platform: 'Linux', version: '4.2' },
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | ];
|
33 | if (grunt.option('extra')) {
|
34 | browsers = browsers.concat(extraBrowsers);
|
35 | }
|
36 | grunt.initConfig({
|
37 | connect: {
|
38 | server: {
|
39 | options: {
|
40 | base: '',
|
41 | port: 9999,
|
42 | useAvailablePort: true
|
43 | }
|
44 | }
|
45 | },
|
46 | 'saucelabs-mocha': {
|
47 | all: {
|
48 | options: {
|
49 | urls: (function () {
|
50 | var urls = ['http://localhost:9999/test/'];
|
51 | if (grunt.option('extra')) {
|
52 | urls.push('http://localhost:9999/test-sham/');
|
53 | }
|
54 | return urls;
|
55 | }()),
|
56 |
|
57 | build: process.env.TRAVIS_BUILD_NUMBER,
|
58 | tunneled: !process.env.SAUCE_HAS_TUNNEL,
|
59 | identifier: process.env.TRAVIS_JOB_NUMBER,
|
60 | sauceConfig: {
|
61 | 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
|
62 | },
|
63 |
|
64 | browsers: browsers,
|
65 | testname: (function () {
|
66 | var testname = 'mocha';
|
67 | if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
|
68 | testname += ' (PR ' + process.env.TRAVIS_PULL_REQUEST + ')';
|
69 | }
|
70 | if (process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH !== 'false') {
|
71 | testname += ' (branch ' + process.env.TRAVIS_BRANCH + ')';
|
72 | }
|
73 | return testname;
|
74 | }()),
|
75 | tags: (function () {
|
76 | var tags = [];
|
77 | if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
|
78 | tags.push('PR-' + process.env.TRAVIS_PULL_REQUEST);
|
79 | }
|
80 | if (process.env.TRAVIS_BRANCH && process.env.TRAVIS_BRANCH !== 'false') {
|
81 | tags.push(process.env.TRAVIS_BRANCH);
|
82 | }
|
83 | return tags;
|
84 | }())
|
85 | }
|
86 | }
|
87 | },
|
88 | watch: {}
|
89 | });
|
90 |
|
91 | for (var key in grunt.file.readJSON('package.json').devDependencies) {
|
92 | if (key !== 'grunt' && key.indexOf('grunt') === 0) {
|
93 | grunt.loadNpmTasks(key);
|
94 | }
|
95 | }
|
96 | grunt.registerTask('dev', ['connect', 'watch']);
|
97 | grunt.registerTask('sauce', ['connect', 'saucelabs-mocha']);
|
98 | };
|