| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 | var tap = require("tap")  , tar = require("../tar.js")  , fs = require("fs")  , path = require("path")  , file = path.resolve(__dirname, "fixtures/c.tar")  , index = 0  , expect =[ [ 'entry',    { path: 'c.txt',      mode: 420,      uid: 24561,      gid: 20,      size: 513,      mtime: new Date('Wed, 26 Oct 2011 01:10:58 GMT'),      cksum: 5422,      type: '0',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '' },    undefined ],  [ 'entry',    { path: 'cc.txt',      mode: 420,      uid: 24561,      gid: 20,      size: 513,      mtime: new Date('Wed, 26 Oct 2011 01:11:02 GMT'),      cksum: 5525,      type: '0',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '' },    undefined ],  [ 'entry',    { path: 'r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      mode: 420,      uid: 24561,      gid: 20,      size: 100,      mtime: new Date('Thu, 27 Oct 2011 03:43:23 GMT'),      cksum: 18124,      type: '0',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '' },    undefined ],  [ 'entry',    { path: 'Ω.txt',      mode: 420,      uid: 24561,      gid: 20,      size: 2,      mtime: new Date('Thu, 27 Oct 2011 17:51:49 GMT'),      cksum: 5695,      type: '0',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '' },    undefined ],  [ 'extendedHeader',    { path: 'PaxHeader/Ω.txt',      mode: 420,      uid: 24561,      gid: 20,      size: 120,      mtime: new Date('Thu, 27 Oct 2011 17:51:49 GMT'),      cksum: 6702,      type: 'x',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '' },    { path: 'Ω.txt',      ctime: 1319737909,      atime: 1319739061,      dev: 234881026,      ino: 51693379,      nlink: 1 } ],  [ 'entry',    { path: 'Ω.txt',      mode: 420,      uid: 24561,      gid: 20,      size: 2,      mtime: new Date('Thu, 27 Oct 2011 17:51:49 GMT'),      cksum: 5695,      type: '0',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '',      ctime: new Date('Thu, 27 Oct 2011 17:51:49 GMT'),      atime: new Date('Thu, 27 Oct 2011 18:11:01 GMT'),      dev: 234881026,      ino: 51693379,      nlink: 1 },    undefined ],  [ 'extendedHeader',    { path: 'PaxHeader/200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      mode: 420,      uid: 24561,      gid: 20,      size: 353,      mtime: new Date('Thu, 27 Oct 2011 03:41:08 GMT'),      cksum: 14488,      type: 'x',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '' },    { path: '200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      ctime: 1319686868,      atime: 1319741254,      'LIBARCHIVE.creationtime': '1319686852',      dev: 234881026,      ino: 51681874,      nlink: 1 } ],  [ 'entry',    { path: '200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      mode: 420,      uid: 24561,      gid: 20,      size: 200,      mtime: new Date('Thu, 27 Oct 2011 03:41:08 GMT'),      cksum: 14570,      type: '0',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '',      ctime: new Date('Thu, 27 Oct 2011 03:41:08 GMT'),      atime: new Date('Thu, 27 Oct 2011 18:47:34 GMT'),      'LIBARCHIVE.creationtime': '1319686852',      dev: 234881026,      ino: 51681874,      nlink: 1 },    undefined ],  [ 'longPath',    { path: '././@LongLink',      mode: 0,      uid: 0,      gid: 0,      size: 201,      mtime: new Date('Thu, 01 Jan 1970 00:00:00 GMT'),      cksum: 4976,      type: 'L',      linkpath: '',      ustar: false },    '200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' ],  [ 'entry',    { path: '200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      mode: 420,      uid: 1000,      gid: 1000,      size: 201,      mtime: new Date('Thu, 27 Oct 2011 22:21:50 GMT'),      cksum: 14086,      type: '0',      linkpath: '',      ustar: false },    undefined ],  [ 'longLinkpath',    { path: '././@LongLink',      mode: 0,      uid: 0,      gid: 0,      size: 201,      mtime: new Date('Thu, 01 Jan 1970 00:00:00 GMT'),      cksum: 4975,      type: 'K',      linkpath: '',      ustar: false },    '200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' ],  [ 'longPath',    { path: '././@LongLink',      mode: 0,      uid: 0,      gid: 0,      size: 201,      mtime: new Date('Thu, 01 Jan 1970 00:00:00 GMT'),      cksum: 4976,      type: 'L',      linkpath: '',      ustar: false },    '200LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL' ],  [ 'entry',    { path: '200LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL',      mode: 511,      uid: 1000,      gid: 1000,      size: 0,      mtime: new Date('Fri, 28 Oct 2011 23:05:17 GMT'),      cksum: 21603,      type: '2',      linkpath: '200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      ustar: false },    undefined ],  [ 'extendedHeader',    { path: 'PaxHeader/200-hard',      mode: 420,      uid: 24561,      gid: 20,      size: 143,      mtime: new Date('Thu, 27 Oct 2011 03:41:08 GMT'),      cksum: 6533,      type: 'x',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '' },    { ctime: 1320617144,      atime: 1320617232,      'LIBARCHIVE.creationtime': '1319686852',      dev: 234881026,      ino: 51681874,      nlink: 2 } ],  [ 'entry',    { path: '200-hard',      mode: 420,      uid: 24561,      gid: 20,      size: 200,      mtime: new Date('Thu, 27 Oct 2011 03:41:08 GMT'),      cksum: 5526,      type: '0',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '',      ctime: new Date('Sun, 06 Nov 2011 22:05:44 GMT'),      atime: new Date('Sun, 06 Nov 2011 22:07:12 GMT'),      'LIBARCHIVE.creationtime': '1319686852',      dev: 234881026,      ino: 51681874,      nlink: 2 },    undefined ],  [ 'extendedHeader',    { path: 'PaxHeader/200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      mode: 420,      uid: 24561,      gid: 20,      size: 353,      mtime: new Date('Thu, 27 Oct 2011 03:41:08 GMT'),      cksum: 14488,      type: 'x',      linkpath: '',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '' },    { path: '200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      ctime: 1320617144,      atime: 1320617406,      'LIBARCHIVE.creationtime': '1319686852',      dev: 234881026,      ino: 51681874,      nlink: 2 } ],  [ 'entry',    { path: '200ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',      mode: 420,      uid: 24561,      gid: 20,      size: 0,      mtime: new Date('Thu, 27 Oct 2011 03:41:08 GMT'),      cksum: 15173,      type: '1',      linkpath: '200-hard',      ustar: 'ustar\0',      ustarver: '00',      uname: 'isaacs',      gname: 'staff',      devmaj: 0,      devmin: 0,      fill: '',      ctime: new Date('Sun, 06 Nov 2011 22:05:44 GMT'),      atime: new Date('Sun, 06 Nov 2011 22:10:06 GMT'),      'LIBARCHIVE.creationtime': '1319686852',      dev: 234881026,      ino: 51681874,      nlink: 2 },    undefined ] ]tap.test("parser test", function (t) {  var parser = tar.Parse()  parser.on("end", function () {    t.equal(index, expect.length, "saw all expected events")    t.end()  })  fs.createReadStream(file)    .pipe(parser)    .on("*", function (ev, entry) {      var wanted = expect[index]      if (!wanted) {        return t.fail("Unexpected event: " + ev)      }      var result = [ev, entry.props]      entry.on("end", function () {        result.push(entry.fields || entry.body)        t.equal(ev, wanted[0], index + " event type")        t.equivalent(entry.props, wanted[1], wanted[1].path + " entry properties")        if (wanted[2]) {          t.equivalent(result[2], wanted[2], "metadata values")        }        index ++      })    })})
 |