[Pkg-javascript-commits] [node-tap] 33/186: unit test for stack cleaning
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 1 16:40:41 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-tap.
commit c665e9793583484fc77159017d9a4b6666396a81
Author: isaacs <i at izs.me>
Date: Thu Sep 7 09:46:07 2017 -0700
unit test for stack cleaning
---
lib/stack.js | 5 +++--
unit/stack.js | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/lib/stack.js b/lib/stack.js
index f6faa36..fcd132f 100644
--- a/lib/stack.js
+++ b/lib/stack.js
@@ -10,11 +10,12 @@ const resc = str =>
// Ignore tap if it's a dependency, or anything
// in this lib folder.
// don't skip when developing on tap itself
-const skip = process.cwd() !== tapDir ||
- +process.env.TAP_DEV_SHORTSTACK === 1 &&
+const skip = (process.cwd() !== tapDir ||
+ +process.env.TAP_DEV_SHORTSTACK === 1) &&
+process.env.TAP_DEV_LONGSTACK !== 1
? [
/node_modules[\/\\]tap[\/\\]/,
+ new RegExp(resc(path.resolve(process.env.HOME, '.node-spawn-wrap-')) + '.*'),
new RegExp(resc(tapDir) + '\\b', 'i'),
new RegExp(resc(require.resolve('function-loop'))),
new RegExp(resc(path.dirname(require.resolve('bluebird/package.json'))))
diff --git a/unit/stack.js b/unit/stack.js
new file mode 100644
index 0000000..04e6fad
--- /dev/null
+++ b/unit/stack.js
@@ -0,0 +1,45 @@
+'use strict'
+const t = require('../')
+const path = require('path')
+
+t.test('in tapdir, no envs', t => {
+ delete require.cache[require.resolve('../lib/stack.js')]
+ process.chdir(path.resolve(__dirname, '..'))
+ process.env.TAP_DEV_LONGSTACK = 0
+ process.env.TAP_DEV_SHORTSTACK = 0
+ const stack = require('../lib/stack.js').captureString()
+ t.match(stack, /unit[\/\\]stack\.js:\w+:\w+\)\n/)
+ t.notMatch(stack, '\.node-spawn-wrap')
+ t.end()
+})
+
+t.test('in ~, no envs', t => {
+ delete require.cache[require.resolve('../lib/stack.js')]
+ process.chdir(process.env.HOME)
+ process.env.TAP_DEV_LONGSTACK = 0
+ process.env.TAP_DEV_SHORTSTACK = 0
+ const stack = require('../lib/stack.js').captureString()
+ t.equal(stack, '')
+ t.end()
+})
+
+t.test('in home, longstack', t => {
+ delete require.cache[require.resolve('../lib/stack.js')]
+ process.chdir(process.env.HOME)
+ process.env.TAP_DEV_LONGSTACK = 1
+ process.env.TAP_DEV_SHORTSTACK = 0
+ const stack = require('../lib/stack.js').captureString()
+ t.match(stack, /unit[\/\\]stack\.js:\w+:\w+\)\n/)
+ t.notMatch(stack, '\.node-spawn-wrap')
+ t.end()
+})
+
+t.test('in tapdir, shortstack', t => {
+ delete require.cache[require.resolve('../lib/stack.js')]
+ process.chdir(path.resolve(__dirname, '..'))
+ process.env.TAP_DEV_LONGSTACK = 0
+ process.env.TAP_DEV_SHORTSTACK = 1
+ const stack = require('../lib/stack.js').captureString()
+ t.equal(stack, '')
+ t.end()
+})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap.git
More information about the Pkg-javascript-commits
mailing list