Skip to content

Commit 0e51fb0

Browse files
kumar303rpl
authored andcommitted
fix: update addons-linter to version 0.26.1 and fix linting and functional tests (#1082)
* fix(package): update addons-linter to version 0.26.1(closes #1076) * fix: Add eslint 3.19.0 in the web-ext devDependencies (fix eslint linting errors on addons-linter 0.26.1) * fix: Run functional tests with production npm dependencies on CI
1 parent 177709b commit 0e51fb0

File tree

6 files changed

+59
-4
lines changed

6 files changed

+59
-4
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ before_script:
1111

1212
# Keep this in sync with appveyor.yml
1313
script:
14+
## run eslint, flow and the unit test suite.
1415
- COVERAGE=y NODE_ENV=production npm test
16+
17+
## run functional test suite in a npm production environment
18+
## (See #1082 for rationale).
19+
- npm run copy-dist-files-to-artifacts-dir
20+
- cd artifacts/production && npm install --production && cd -
21+
- TEST_WEB_EXT_BIN=./artifacts/production/bin/web-ext npm run test:functional
22+
23+
## lint the github PR title.
1524
- npm run travis-pr-title-lint
1625

1726
after_script: npm run publish-coverage

Gruntfile.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ module.exports = function(grunt) {
3030
'webpack:functional_tests',
3131
]);
3232

33-
grunt.registerTask('test', 'run linting and test suites', function() {
33+
grunt.registerTask('test', 'run linting and the unit test suite', function() {
3434
var tasks = [
3535
'lint',
3636
'flowbin:check',
3737
'build-tests',
3838
'mochaTest:unit',
39-
'mochaTest:functional',
4039
];
4140

4241
// TODO: enable the flowbin:check task on AppVeyor (mozilla/web-ext#773)
@@ -48,6 +47,27 @@ module.exports = function(grunt) {
4847
grunt.task.run(tasks);
4948
});
5049

50+
grunt.registerTask('test:functional', 'run functional test suites', [
51+
'build-tests',
52+
'mochaTest:functional',
53+
]);
54+
55+
grunt.registerTask('copy-dist-files-to-artifacts-dir', function() {
56+
const distFile = grunt.file.expand('./dist/**').filter((filename) => {
57+
return filename.endsWith('web-ext.js');
58+
});
59+
60+
if (distFile.length === 0) {
61+
// By default grunt will exit here, unless the `--force` grunt option has been
62+
// specified on the command line.
63+
grunt.fail.warn(
64+
'Required dist/ file missing. Run the build command first.'
65+
);
66+
}
67+
68+
grunt.task.run('copy:dist-files-to-artifacts-dir');
69+
});
70+
5171
grunt.registerTask('develop', [
5272
'flowbin:start',
5373
'watch:develop',

appveyor.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,13 @@ test_script:
2121
- set COVERAGE=y
2222
- set NODE_ENV=production
2323
- npm run test
24+
## install the eslint version needed by eslint and run functional test suite
25+
## (See #1082 for rationale).
26+
## run functional test suite in a npm production environment
27+
## (See #1082 for rationale).
28+
- npm run copy-dist-files-to-artifacts-dir
29+
- cd artifacts\production
30+
- npm install --production
31+
- cd ..\..
32+
- set TEST_WEB_EXT_BIN=artifacts\production\bin\web-ext
33+
- npm run test:functional

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"flow-check": "grunt flowbin:check",
1818
"lint": "grunt lint",
1919
"test": "grunt test",
20+
"test:functional": "grunt test:functional:run",
21+
"copy-dist-files-to-artifacts-dir": "grunt copy-dist-files-to-artifacts-dir",
2022
"publish-coverage": "grunt coveralls",
2123
"nsp-check": "nsp check -o summary",
2224
"changelog": "conventional-changelog -p angular -u",
@@ -46,7 +48,7 @@
4648
"opera"
4749
],
4850
"dependencies": {
49-
"addons-linter": "0.25.1",
51+
"addons-linter": "0.26.1",
5052
"babel-polyfill": "6.20.0",
5153
"babel-runtime": "6.25.0",
5254
"bunyan": "1.8.10",
@@ -96,6 +98,7 @@
9698
"coveralls": "2.13.1",
9799
"deepcopy": "0.6.3",
98100
"doctoc": "1.3.0",
101+
"eslint": "3.19.0",
99102
"eslint-plugin-async-await": "0.0.0",
100103
"eslint-plugin-flowtype": "2.35.0",
101104
"eslint-plugin-import": "2.3.0",

tasks/configs/copy.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
'dist-files-to-artifacts-dir': {
3+
files: [
4+
{
5+
expand: true,
6+
src: ['package.json', 'dist/**', 'bin/**'],
7+
dest: 'artifacts/production',
8+
},
9+
],
10+
},
11+
};

tests/functional/common.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export const withTempDir = tmpDirUtils.withTempDir;
1313

1414
export const functionalTestsDir = path.resolve(__dirname);
1515
export const projectDir = path.join(functionalTestsDir, '..', '..');
16-
export const webExt = path.join(projectDir, 'bin', 'web-ext');
16+
export const webExt = process.env.TEST_WEB_EXT_BIN ?
17+
path.resolve(process.env.TEST_WEB_EXT_BIN) :
18+
path.join(projectDir, 'bin', 'web-ext');
1719
export const fixturesDir = path.join(functionalTestsDir, '..', 'fixtures');
1820
export const minimalAddonPath = path.join(fixturesDir, 'minimal-web-ext');
1921
export const fakeFirefoxPath = path.join(

0 commit comments

Comments
 (0)