00-setup-fixtures.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // the fixtures have some weird stuff that is painful
  2. // to include directly in the repo for various reasons.
  3. //
  4. // So, unpack the fixtures with the system tar first.
  5. //
  6. // This means, of course, that it'll only work if you
  7. // already have a tar implementation, and some of them
  8. // will not properly unpack the fixtures anyway.
  9. //
  10. // But, since usually those tests will fail on Windows
  11. // and other systems with less capable filesystems anyway,
  12. // at least this way we don't cause inconveniences by
  13. // merely cloning the repo or installing the package.
  14. var tap = require("tap")
  15. , child_process = require("child_process")
  16. , rimraf = require("rimraf")
  17. , test = tap.test
  18. , path = require("path")
  19. test("clean fixtures", function (t) {
  20. rimraf(path.resolve(__dirname, "fixtures"), function (er) {
  21. t.ifError(er, "rimraf ./fixtures/")
  22. t.end()
  23. })
  24. })
  25. test("clean tmp", function (t) {
  26. rimraf(path.resolve(__dirname, "tmp"), function (er) {
  27. t.ifError(er, "rimraf ./tmp/")
  28. t.end()
  29. })
  30. })
  31. test("extract fixtures", function (t) {
  32. var c = child_process.spawn("tar"
  33. ,["xzvf", "fixtures.tgz"]
  34. ,{ cwd: __dirname })
  35. c.stdout.on("data", errwrite)
  36. c.stderr.on("data", errwrite)
  37. function errwrite (chunk) {
  38. process.stderr.write(chunk)
  39. }
  40. c.on("exit", function (code) {
  41. t.equal(code, 0, "extract fixtures should exit with 0")
  42. if (code) {
  43. t.comment("Note, all tests from here on out will fail because of this.")
  44. }
  45. t.end()
  46. })
  47. })