• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict'
2var test = require('tap').test
3var common = require('../common-tap.js')
4var path = require('path')
5var rimraf = require('rimraf')
6var mkdirp = require('mkdirp')
7var basepath = common.pkg
8var fixturepath = path.resolve(basepath, 'npm-test-platform')
9var modulepath = path.resolve(basepath, 'node_modules')
10var Tacks = require('tacks')
11var File = Tacks.File
12var Dir = Tacks.Dir
13
14var fixture = new Tacks(
15  Dir({
16    README: File(
17      'just an npm test\n'
18    ),
19    'package.json': File({
20      name: 'npm-test-platform',
21      version: '9.9.9-9',
22      homepage: 'http://www.youtube.com/watch?v=dQw4w9WgXcQ',
23      os: [
24        '!this_is_not_a_real_os',
25        '!neither_is_this'
26      ],
27      cpu: [
28        '!this_is_not_a_real_cpu',
29        '!this_isnt_either'
30      ]
31    })
32  })
33)
34
35test('setup', function (t) {
36  setup()
37  t.done()
38})
39
40test('platform', function (t) {
41  common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
42  function installCheckAndTest (err, code, stdout, stderr) {
43    if (err) throw err
44    console.error(stderr)
45    t.is(code, 0, 'install went ok')
46    t.done()
47  }
48})
49
50test('cleanup', function (t) {
51  cleanup()
52  t.done()
53})
54
55function setup () {
56  cleanup()
57  fixture.create(fixturepath)
58  mkdirp.sync(modulepath)
59}
60
61function cleanup () {
62  fixture.remove(fixturepath)
63  rimraf.sync(basepath)
64}
65