From 6229e02806ee35fdb16cccb70defffac9b02acef Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 30 Dec 2015 16:31:37 -0600 Subject: [PATCH] Excuse `root._` export from coverage. --- .travis.yml | 1 + test/test.js | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ab8ef12c3..acf3f1424 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,7 @@ before_install: PATTERN[5]="|\bindex,\s*iterable\)\s*===\s*false\)[^}]+?(break;)|" PATTERN[6]="|\s*if\s*\(!lodashFunc\)\s*\{\s*return;\s*\}|" PATTERN[7]="|\s*define\([\s\S]+?\);|" + PATTERN[8]="|\s*root\._\s*=\s*_;|" if [ $ISTANBUL == true ]; then set -e diff --git a/test/test.js b/test/test.js index a3b629fa8..3e8e131d4 100644 --- a/test/test.js +++ b/test/test.js @@ -206,6 +206,11 @@ (_.runInContext ? _.runInContext(root) : _) )); + /** Used to detect instrumented istanbul code coverage runs. */ + var coverage = root.__coverage__ || root[lodashStable.findKey(root, function(value, key) { + return /^(?:\$\$cov_\d+\$\$)$/.test(key); + })]; + /** Used to restore the `_` reference. */ var oldDash = root._; @@ -13972,12 +13977,12 @@ QUnit.test('should work with a `root` of `this`', function(assert) { assert.expect(2); - if (!isModularize && !document && realm.object) { + if (!isModularize && !coverage && (!document && realm.object)) { var fs = require('fs'), vm = require('vm'), expected = {}, context = vm.createContext({ '_': expected, 'console': console }), - source = fs.readFileSync(filePath); + source = fs.readFileSync(filePath, 'utf8'); vm.runInContext(source + '\nthis.lodash = this._.noConflict()', context);