Skip to content

Commit

Permalink
tap@15
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 23, 2021
1 parent 259e649 commit 1b94260
Show file tree
Hide file tree
Showing 11 changed files with 2,711 additions and 2,455 deletions.
4,979 changes: 2,632 additions & 2,347 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"events-to-array": "^1.1.2",
"mutate-fs": "^2.1.1",
"rimraf": "^2.7.1",
"tap": "^14.9.2",
"tap": "^15.0.9",
"tar-fs": "^1.16.3",
"tar-stream": "^1.6.2"
},
Expand Down
6 changes: 3 additions & 3 deletions test/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ t.test('create file', t => {
})

t.test('create', t => {
t.isa(c({ sync: true }, ['README.md']), Pack.Sync)
t.isa(c(['README.md']), Pack)
t.type(c({ sync: true }, ['README.md']), Pack.Sync)
t.type(c(['README.md']), Pack)
t.end()
})

t.test('open fails', t => {
const poop = new Error('poop')
const file = path.resolve(dir, 'throw-open.tar')
t.tearDown(mutateFS.statFail(poop))
t.teardown(mutateFS.statFail(poop))
t.throws(_ => c({
file: file,
sync: true,
Expand Down
18 changes: 7 additions & 11 deletions test/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ t.test('basic extracting', t => {
const file = path.resolve(tars, 'utf8.tar')
const dir = path.resolve(extractdir, 'basic')

t.beforeEach(cb => {
t.beforeEach(() => {
rimraf.sync(dir)
mkdirp.sync(dir)
cb()
})

const check = t => {
Expand Down Expand Up @@ -59,10 +58,9 @@ t.test('file list and filter', t => {
const file = path.resolve(tars, 'utf8.tar')
const dir = path.resolve(extractdir, 'filter')

t.beforeEach(cb => {
t.beforeEach(() => {
rimraf.sync(dir)
mkdirp.sync(dir)
cb()
})

const check = t => {
Expand Down Expand Up @@ -103,10 +101,9 @@ t.test('no file list', t => {
const file = path.resolve(tars, 'body-byte-counts.tar')
const dir = path.resolve(extractdir, 'no-list')

t.beforeEach(cb => {
t.beforeEach(() => {
rimraf.sync(dir)
mkdirp.sync(dir)
cb()
})

const check = t => {
Expand Down Expand Up @@ -145,10 +142,9 @@ t.test('read in itty bits', t => {
const file = path.resolve(tars, 'body-byte-counts.tar')
const dir = path.resolve(extractdir, 'no-list')

t.beforeEach(cb => {
t.beforeEach(() => {
rimraf.sync(dir)
mkdirp.sync(dir)
cb()
})

const check = t => {
Expand Down Expand Up @@ -191,9 +187,9 @@ t.test('bad calls', t => {

t.test('no file', t => {
const Unpack = require('../lib/unpack.js')
t.isa(x(), Unpack)
t.isa(x(['asdf']), Unpack)
t.isa(x({sync: true}), Unpack.Sync)
t.type(x(), Unpack)
t.type(x(['asdf']), Unpack)
t.type(x({sync: true}), Unpack.Sync)
t.end()
})

Expand Down
17 changes: 8 additions & 9 deletions test/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ t.test('portable pack a dir', t => {

t.test('use process cwd if cwd not specified', t => {
const cwd = process.cwd()
t.tearDown(_ => process.chdir(cwd))
t.teardown(_ => process.chdir(cwd))
process.chdir(files)

const out = []
Expand Down Expand Up @@ -368,7 +368,7 @@ t.test('add the same dir twice (exercise cache code)', t => {
t.test('if gzip is truthy, make it an object', t => {
const opt = { gzip: true }
new Pack(opt)
t.isa(opt.gzip, 'object')
t.type(opt.gzip, 'object')
t.end()
})

Expand Down Expand Up @@ -463,7 +463,7 @@ t.test('very deep gzip path, sync', t => {
pack.resume()

const zipped = pack.read()
t.isa(zipped, Buffer)
t.type(zipped, Buffer)
const data = zlib.unzipSync(zipped)
const entries = []
for (var i = 0; i < data.length; i += 512) {
Expand Down Expand Up @@ -536,7 +536,7 @@ t.test('write after end', t => {
})

t.test('emit error when stat fail', t => {
t.tearDown(mutateFS.statFail(new Error('xyz')))
t.teardown(mutateFS.statFail(new Error('xyz')))
t.throws(_ => new PackSync({ cwd: files }).add('one-byte.txt'),
new Error('xyz'))

Expand All @@ -547,7 +547,7 @@ t.test('emit error when stat fail', t => {
})

t.test('readdir fail', t => {
t.tearDown(mutateFS.fail('readdir', new Error('xyz')))
t.teardown(mutateFS.fail('readdir', new Error('xyz')))
t.throws(_ => new PackSync({ cwd: files }).add('dir'), new Error('xyz'))

new Pack({ cwd: files }).add('dir').on('error', e => {
Expand Down Expand Up @@ -678,7 +678,7 @@ t.test('ignores mid-queue', t => {
const data = Buffer.concat(out)
t.equal(data.slice(0, 100).toString().replace(/\0.*$/, ''), './')
const file = data.slice(512, 612).toString().replace(/\0.*$/, '')
t.notequal(files.indexOf(file), -1)
t.not(files.indexOf(file), -1)
t.end()
})

Expand Down Expand Up @@ -752,11 +752,10 @@ t.test('warnings', t => {
t.test('no dir recurse', t => {
const dir = path.resolve(fixtures, 'pack-no-dir-recurse')
t.teardown(_ => rimraf.sync(dir))
t.beforeEach(cb => {
t.beforeEach(() => {
rimraf.sync(dir)
mkdirp.sync(dir + '/x')
fs.writeFileSync(dir + '/x/y', 'y')
cb()
})

const check = (t, data) => {
Expand Down Expand Up @@ -1003,7 +1002,7 @@ t.test('padding works regardless of arite/add order', t =>
write({ before: true }),
write({ before: false }),
]).then(res =>
t.is(res[0], res[1], 'length is the same regardless of write/add order')))
t.equal(res[0], res[1], 'length is the same regardless of write/add order')))

t.test('prefix and subdirs', t => {
const dir = path.resolve(fixtures, 'pack-prefix-subdirs')
Expand Down
4 changes: 2 additions & 2 deletions test/read-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ t.test('meta entry', t => {
t.throws(_ => entry.write(Buffer.alloc(1024)))

t.equal(actual, expect)
t.like(entry, { meta: true, type: 'NextFileHasLongLinkpath' })
t.match(entry, { meta: true, type: 'NextFileHasLongLinkpath' })
t.end()
})

Expand Down Expand Up @@ -146,7 +146,7 @@ t.test('unknown entry type', t => {
t.throws(_ => entry.write(Buffer.alloc(1024)))

t.equal(actual, expect)
t.like(entry, { ignore: true })
t.match(entry, { ignore: true })
t.end()
})

Expand Down
12 changes: 5 additions & 7 deletions test/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const spawn = require('child_process').spawn

t.teardown(_ => rimraf.sync(dir))

const reset = cb => {
const reset = () => {
rimraf.sync(dir)
mkdirp.sync(dir)
const data = fs.readFileSync(tars + '/body-byte-counts.tar')
Expand All @@ -44,13 +44,11 @@ const reset = cb => {
fs.writeFileSync(fileEmpty, Buffer.alloc(1024))

fs.writeFileSync(fileCompressed, zlib.gzipSync(data))

if (cb)
cb()
}

t.test('setup', t => {
reset(t.end)
reset()
t.end()
})

t.test('basic file add to archive (good or truncated)', t => {
Expand Down Expand Up @@ -305,8 +303,8 @@ t.test('mtime cache', t => {
t.test('create tarball out of another tarball', t => {
const out = path.resolve(dir, 'out.tar')

t.beforeEach(cb => {
fs.writeFile(out, fs.readFileSync(path.resolve(tars, 'dir.tar')), cb)
t.beforeEach(() => {
fs.writeFileSync(out, fs.readFileSync(path.resolve(tars, 'dir.tar')))
})

const check = t => {
Expand Down
Loading

0 comments on commit 1b94260

Please sign in to comment.