link-file-entry-collision.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Set the umask, so that it works the same everywhere.
  2. process.umask(parseInt('22', 8))
  3. var tap = require("tap")
  4. , tar = require("../tar.js")
  5. , fs = require("fs")
  6. , path = require("path")
  7. , file = path.resolve(__dirname, "link-file-entry-collision/bad-link.tar")
  8. , target = path.resolve(__dirname, "tmp/link-file-entry-collision")
  9. , index = 0
  10. , fstream = require("fstream")
  11. , mkdirp = require("mkdirp")
  12. , rimraf = require("rimraf")
  13. tap.test("preclean", function (t) {
  14. rimraf.sync(target)
  15. t.pass("cleaned!")
  16. t.end()
  17. })
  18. tap.test("extract test", function (t) {
  19. var extract = tar.Extract(target)
  20. var inp = fs.createReadStream(file)
  21. inp.pipe(extract)
  22. extract.on("end", function () {
  23. t.equal(fs.readFileSync(target + "/bad-link-target", "utf8"),
  24. "this should remain the same\n")
  25. t.equal(fs.readFileSync(target + "/a.txt", "utf8"),
  26. "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
  27. t.end()
  28. })
  29. })
  30. tap.test("cleanup", function (t) {
  31. rimraf.sync(target)
  32. t.pass("cleaned!")
  33. t.end()
  34. })