Initial commit
[yaffs-website] / node_modules / tar / test / 00-setup-fixtures.js
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
15 var tap = require("tap")
16 , child_process = require("child_process")
17 , rimraf = require("rimraf")
18 , test = tap.test
19 , path = require("path")
20
21 test("clean fixtures", function (t) {
22   rimraf(path.resolve(__dirname, "fixtures"), function (er) {
23     t.ifError(er, "rimraf ./fixtures/")
24     t.end()
25   })
26 })
27
28 test("clean tmp", function (t) {
29   rimraf(path.resolve(__dirname, "tmp"), function (er) {
30     t.ifError(er, "rimraf ./tmp/")
31     t.end()
32   })
33 })
34
35 test("extract fixtures", function (t) {
36   var c = child_process.spawn("tar"
37                              ,["xzvf", "fixtures.tgz"]
38                              ,{ cwd: __dirname })
39
40   c.stdout.on("data", errwrite)
41   c.stderr.on("data", errwrite)
42   function errwrite (chunk) {
43     process.stderr.write(chunk)
44   }
45
46   c.on("exit", function (code) {
47     t.equal(code, 0, "extract fixtures should exit with 0")
48     if (code) {
49       t.comment("Note, all tests from here on out will fail because of this.")
50     }
51     t.end()
52   })
53 })