Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Use tap snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jun 5, 2019
1 parent 4633948 commit f656af8
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 73 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1 +1,3 @@
node_modules
/.nyc_output/
/coverage/
74 changes: 74 additions & 0 deletions tap-snapshots/test-basic.js-TAP.test.js
@@ -0,0 +1,74 @@
/* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/basic.js TAP deeproot > deeproot tree 1`] = `
root@1.2.3 test/fixtures/deeproot/root
├─┬ @scope/x@1.2.3 test/fixtures/deeproot/root/node_modules/@scope/x
│ └─┬ glob@4.0.5 test/fixtures/deeproot/root/node_modules/@scope/x/node_modules/glob
│ ├── graceful-fs@3.0.2 test/fixtures/deeproot/root/node_modules/@scope/x/node_modules/glob/node_modules/graceful-fs
│ ├── inherits@2.0.1 test/fixtures/deeproot/root/node_modules/@scope/x/node_modules/glob/node_modules/inherits
│ ├─┬ minimatch@1.0.0 test/fixtures/deeproot/root/node_modules/@scope/x/node_modules/glob/node_modules/minimatch
│ │ ├── lru-cache@2.5.0 test/fixtures/deeproot/root/node_modules/@scope/x/node_modules/glob/node_modules/minimatch/node_modules/lru-cache
│ │ └── sigmund@1.0.0 test/fixtures/deeproot/root/node_modules/@scope/x/node_modules/glob/node_modules/minimatch/node_modules/sigmund
│ └── once@1.3.0 test/fixtures/deeproot/root/node_modules/@scope/x/node_modules/glob/node_modules/once
├── @scope/y@1.2.3 test/fixtures/deeproot/root/node_modules/@scope/y
└── foo@1.2.3 test/fixtures/deeproot/root/node_modules/foo
`

exports[`test/basic.js TAP linkedroot > linkedroot tree 1`] = `
root@1.2.3 test/fixtures/linkedroot
├─┬ @scope/x@1.2.3 test/fixtures/linkedroot/node_modules/@scope/x
│ └─┬ glob@4.0.5 test/fixtures/linkedroot/node_modules/@scope/x/node_modules/glob
│ ├── graceful-fs@3.0.2 test/fixtures/linkedroot/node_modules/@scope/x/node_modules/glob/node_modules/graceful-fs
│ ├── inherits@2.0.1 test/fixtures/linkedroot/node_modules/@scope/x/node_modules/glob/node_modules/inherits
│ ├─┬ minimatch@1.0.0 test/fixtures/linkedroot/node_modules/@scope/x/node_modules/glob/node_modules/minimatch
│ │ ├── lru-cache@2.5.0 test/fixtures/linkedroot/node_modules/@scope/x/node_modules/glob/node_modules/minimatch/node_modules/lru-cache
│ │ └── sigmund@1.0.0 test/fixtures/linkedroot/node_modules/@scope/x/node_modules/glob/node_modules/minimatch/node_modules/sigmund
│ └── once@1.3.0 test/fixtures/linkedroot/node_modules/@scope/x/node_modules/glob/node_modules/once
├── @scope/y@1.2.3 test/fixtures/linkedroot/node_modules/@scope/y
└── foo@1.2.3 test/fixtures/linkedroot/node_modules/foo
`

exports[`test/basic.js TAP noname > noname tree 1`] = `
test/fixtures/noname
└── test/fixtures/noname/node_modules/foo
`

exports[`test/basic.js TAP other > other tree 1`] = `
test/fixtures/other
└── glob@4.0.5 test/fixtures/other/node_modules/glob (symlink)
`

exports[`test/basic.js TAP root > root tree 1`] = `
root@1.2.3 test/fixtures/root
├─┬ @scope/x@1.2.3 test/fixtures/root/node_modules/@scope/x
│ └─┬ glob@4.0.5 test/fixtures/root/node_modules/@scope/x/node_modules/glob
│ ├── graceful-fs@3.0.2 test/fixtures/root/node_modules/@scope/x/node_modules/glob/node_modules/graceful-fs
│ ├── inherits@2.0.1 test/fixtures/root/node_modules/@scope/x/node_modules/glob/node_modules/inherits
│ ├─┬ minimatch@1.0.0 test/fixtures/root/node_modules/@scope/x/node_modules/glob/node_modules/minimatch
│ │ ├── lru-cache@2.5.0 test/fixtures/root/node_modules/@scope/x/node_modules/glob/node_modules/minimatch/node_modules/lru-cache
│ │ └── sigmund@1.0.0 test/fixtures/root/node_modules/@scope/x/node_modules/glob/node_modules/minimatch/node_modules/sigmund
│ └── once@1.3.0 test/fixtures/root/node_modules/@scope/x/node_modules/glob/node_modules/once
├── @scope/y@1.2.3 test/fixtures/root/node_modules/@scope/y
└── foo@1.2.3 test/fixtures/root/node_modules/foo
`

exports[`test/basic.js TAP selflink > selflink tree 1`] = `
selflink@1.2.3 test/fixtures/selflink
├── @scope/y@1.2.3 test/fixtures/selflink/node_modules/@scope/y
├─┬ @scope/z@1.2.3 test/fixtures/selflink/node_modules/@scope/z
│ └── glob@4.0.5 test/fixtures/selflink/node_modules/foo/node_modules/glob (symlink)
└─┬ foo@1.2.3 test/fixtures/selflink/node_modules/foo
├─┬ glob@4.0.5 test/fixtures/selflink/node_modules/foo/node_modules/glob
│ ├── graceful-fs@3.0.2 test/fixtures/selflink/node_modules/foo/node_modules/glob/node_modules/graceful-fs
│ ├── inherits@2.0.1 test/fixtures/selflink/node_modules/foo/node_modules/glob/node_modules/inherits
│ ├─┬ minimatch@1.0.0 test/fixtures/selflink/node_modules/foo/node_modules/glob/node_modules/minimatch
│ │ ├── lru-cache@2.5.0 test/fixtures/selflink/node_modules/foo/node_modules/glob/node_modules/minimatch/node_modules/lru-cache
│ │ └── sigmund@1.0.0 test/fixtures/selflink/node_modules/foo/node_modules/glob/node_modules/minimatch/node_modules/sigmund
│ └── once@1.3.0 test/fixtures/selflink/node_modules/foo/node_modules/glob/node_modules/once
└── selflink@1.2.3 test/fixtures/selflink (symlink)
`
28 changes: 5 additions & 23 deletions test/basic.js
Expand Up @@ -48,55 +48,36 @@ test('setup symlinks', function (t) {

roots.forEach(function (root) {
var dir = path.resolve(fixtures, root)
var expectedtxt = path.resolve(dir, 'archy.txt')
var expectedre = path.resolve(dir, 'archy.re')

test(root, function (t) {
rpt(dir, function (er, d) {
if (er && er.code !== 'ENOENT') throw er

var actual = archy(archyize(d)).trim()
// console . log ('----', dir)
console.log(actual)
// console . log (require ('util') . inspect (d, {
// depth: Infinity
// }))
try {
var expect = fs.readFileSync(expectedtxt, 'utf8').trim()
t.equal(actual, expect, root + ' tree')
} catch (e) {
var expect = new RegExp(fs.readFileSync(expectedre, 'utf8').trim())
t.like(actual, expect, root + ' tree')
}
t.matchSnapshot(actual, root + ' tree')
t.end()
})
})
})

test('linkedroot', function (t) {
var dir = path.resolve(fixtures, 'linkedroot')
var out = dir + '-archy.txt'
rpt(dir, function (er, d) {
if (er && er.code !== 'ENOENT') throw er

var actual = archy(archyize(d)).trim()
console.log(actual)
var expect = fs.readFileSync(out, 'utf8').trim()
t.equal(actual, expect, 'linkedroot tree')
t.matchSnapshot(actual, 'linkedroot tree')
t.end()
})
})

test('deeproot', function (t) {
var dir = path.resolve(fixtures, 'deeproot/root')
var out = path.resolve(fixtures, 'deep') + '-archy.txt'
rpt(dir, function (er, d) {
if (er && er.code !== 'ENOENT') throw er

var actual = archy(archyize(d)).trim()
console.log(actual)
var expect = fs.readFileSync(out, 'utf8').trim()
t.equal(actual, expect, 'deeproot tree')
t.matchSnapshot(actual, 'deeproot tree')
t.end()
})
})
Expand All @@ -121,6 +102,7 @@ test('missing json does not obscure deeper errors', function (t) {
t.end()
})
})

test('missing folder', function (t) {
rpt(path.resolve(fixtures, 'does-not-exist'), function (er, d) {
t.ok(er, 'Got an error object')
Expand All @@ -129,6 +111,7 @@ test('missing folder', function (t) {
t.end()
})
})

test('missing symlinks', function (t) {
rpt(path.resolve(fixtures, 'badlink'), function (er, d) {
if (er && er.code !== 'ENOENT') throw er
Expand All @@ -140,7 +123,6 @@ test('missing symlinks', function (t) {
})
})


function archyize (d, seen) {
seen = seen || {}
var path = d.path
Expand Down
11 changes: 0 additions & 11 deletions test/fixtures/deep-archy.txt

This file was deleted.

11 changes: 0 additions & 11 deletions test/fixtures/linkedroot-archy.txt

This file was deleted.

2 changes: 0 additions & 2 deletions test/fixtures/noname/archy.txt

This file was deleted.

2 changes: 0 additions & 2 deletions test/fixtures/other/archy.txt

This file was deleted.

11 changes: 0 additions & 11 deletions test/fixtures/root/archy.txt

This file was deleted.

13 changes: 0 additions & 13 deletions test/fixtures/selflink/archy.re

This file was deleted.

0 comments on commit f656af8

Please sign in to comment.