Closed Bug 1330071 Opened 8 years ago Closed 8 years ago

Add a couple of basic unit tests for eslint rules (not automatic)

Categories

(Developer Infrastructure :: Lint and Formatting, defect)

3 Branch
defect
Not set
normal

Tracking

(firefox53 fixed)

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: standard8, Assigned: standard8)

References

Details

Attachments

(1 file)

I've just put together some tests for a couple of the eslint custom rules we're now using - they are based around the RuleTester that eslint provides. I haven't hooked them up to infrastructure, but they can be run via: ``` cd tools/lint/eslint/eslint-plugin-mozilla npm run test ``` That gives us something very basic that allows us to have some outline to make writing and testing rules simpler and quicker. Although we can't easily test every rule this way (see bug 1219152 comment 1), we should be able to test some of them. I'm not doing this directly on bug 1219152, as I think there's other rules we can still write tests for (and potentially integrate with build/test systems), this is just to get something in the tree for future work.
Note: this is currently based on autoland, as it is waiting for bug 1329614 to land in central.
Comment on attachment 8825524 [details] Bug 1330071 - Add a couple of basic unit tests for our custom eslint rules. Currently these are not automatic. https://reviewboard.mozilla.org/r/103640/#review104312 ::: tools/lint/eslint/eslint-plugin-mozilla/tests/test-run-all.js:6 (Diff revision 1) > +/* Any copyright is dedicated to the Public Domain. > + * http://creativecommons.org/publicdomain/zero/1.0/ */ > + > +"use strict"; > + > +const RuleTester = require("../../node_modules/eslint/lib/testers/rule-tester.js"); You should just be able to require "eslint/lib/testers/rule-tester" ::: tools/lint/eslint/eslint-plugin-mozilla/tests/test-run-all.js:11 (Diff revision 1) > +const RuleTester = require("../../node_modules/eslint/lib/testers/rule-tester.js"); > +const fs = require('fs'); > + > +var ruleTester = new RuleTester(); > + > +fs.readdir("tests/", (err, files) => { Looks like this makes an assumption about cwd. Use __dirname instead
Attachment #8825524 - Flags: review?(dtownsend) → review+
Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f3dd4bce1fed Add a couple of basic unit tests for our custom eslint rules. Currently these are not automatic. r=mossop
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Product: Testing → Firefox Build System
Version: Version 3 → 3 Branch
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: