Revision 5aef65a9 deps/npm/node_modules/glob/test/root.js

View differences:

deps/npm/node_modules/glob/test/root.js
1
var tap = require("tap")
1
var t = require("tap")
2 2

  
3 3
var origCwd = process.cwd()
4 4
process.chdir(__dirname)
5 5

  
6
tap.test("changing root and searching for /b*/**", function (t) {
7
  var glob = require('../')
8
  var path = require('path')
9
  t.test('.', function (t) {
10
    glob('/b*/**', { globDebug: true, root: '.' }, function (er, matches) {
11
      t.ifError(er)
12
      t.like(matches, [])
13
      t.end()
14
    })
15
  })
6
var glob = require('../')
7
var path = require('path')
16 8

  
17
  t.test('a', function (t) {
18
    glob('/b*/**', { globDebug: true, root: path.resolve('a') }, function (er, matches) {
19
      t.ifError(er)
20
      t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
21
        return path.join(path.resolve('a'), m)
22
      }))
23
      t.end()
24
    })
9
t.test('.', function (t) {
10
  glob('/b*/**', { globDebug: true, root: '.' }, function (er, matches) {
11
    t.ifError(er)
12
    t.like(matches, [])
13
    t.end()
25 14
  })
15
})
16

  
26 17

  
27
  t.test('root=a, cwd=a/b', function (t) {
28
    glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b') }, function (er, matches) {
29
      t.ifError(er)
30
      t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
31
        return path.join(path.resolve('a'), m)
32
      }))
33
      t.end()
34
    })
18
t.test('a', function (t) {
19
  console.error("root=" + path.resolve('a'))
20
  glob('/b*/**', { globDebug: true, root: path.resolve('a') }, function (er, matches) {
21
    t.ifError(er)
22
    var wanted = [
23
        '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f'
24
      ].map(function (m) {
25
        return path.join(path.resolve('a'), m).replace(/\\/g, '/')
26
      })
27

  
28
    t.like(matches, wanted)
29
    t.end()
35 30
  })
31
})
36 32

  
37
  t.test('cd -', function (t) {
38
    process.chdir(origCwd)
33
t.test('root=a, cwd=a/b', function (t) {
34
  glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b') }, function (er, matches) {
35
    t.ifError(er)
36
    t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) {
37
      return path.join(path.resolve('a'), m).replace(/\\/g, '/')
38
    }))
39 39
    t.end()
40 40
  })
41
})
41 42

  
43
t.test('cd -', function (t) {
44
  process.chdir(origCwd)
42 45
  t.end()
43 46
})

Also available in: Unified diff