Skip to content

Commit

Permalink
Only run browserify tests if eval is available
Browse files Browse the repository at this point in the history
  • Loading branch information
davidje13 committed Mar 28, 2021
1 parent 51f1ef8 commit 3616cf8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion test/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var captureStderr = require('./support/capture-stderr')
var depd = null
var mylib = null
var path = require('path')
var run = browserify ? describe : describe.skip
var canEval = true
try { eval('1') } catch (e) { canEval = false }
var run = (browserify && canEval) ? describe : describe.skip

run('when browserified', function () {
before(function (done) {
Expand Down
14 changes: 6 additions & 8 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ var script = path.join(__dirname, 'fixtures', 'script.js')
var spawn = require('child_process').spawn
var strictlib = libs.strict

var canEval = true
try { eval('1') } catch (e) { canEval = false }

describe('depd(namespace)', function () {
it('creates deprecated function', function () {
assert.strictEqual(typeof depd('test'), 'function')
Expand Down Expand Up @@ -64,17 +67,12 @@ describe('deprecate(message)', function () {
})

it('should log call site within eval', function () {
function callold () { eval('mylib.old()') } // eslint-disable-line no-eval
var stderr;
try {
stderr = captureStderr(callold)
} catch (e) {
if (!(e instanceof EvalError)) {
throw e;
}
if (!canEval) {
// unable to test eval stack trace because eval is blocked in this test environment
this.skip();
}
function callold () { eval('mylib.old()') } // eslint-disable-line no-eval
var stderr = captureStderr(callold)
assert.ok(stderr.indexOf(basename(__filename)) !== -1)
assert.ok(stderr.indexOf('<anonymous>:1:') !== -1)
assert.ok(/\.js:[0-9]+:[0-9]+/.test(stderr))
Expand Down

0 comments on commit 3616cf8

Please sign in to comment.