Sha256: 808f742ae6ce64bd49c746e08de0993a907d5d8561921f7f0245c60ae6dee7d7

Contents?: true

Size: 1.71 KB

Versions: 124

Compression:

Stored size: 1.71 KB

Contents

// basic test
// show that it does the same thing by default as the shell.
var tap = require("tap")
, child_process = require("child_process")
, bashResults = require("./bash-results.json")
, globs = Object.keys(bashResults)
, glob = require("../")
, path = require("path")

// run from the root of the project
// this is usually where you're at anyway, but be sure.
process.chdir(path.resolve(__dirname, ".."))

function alphasort (a, b) {
  a = a.toLowerCase()
  b = b.toLowerCase()
  return a > b ? 1 : a < b ? -1 : 0
}

globs.forEach(function (pattern) {
  var expect = bashResults[pattern]
  // anything regarding the symlink thing will fail on windows, so just skip it
  if (process.platform === "win32" &&
      expect.some(function (m) {
        return /\/symlink\//.test(m)
      }))
    return

  tap.test(pattern, function (t) {
    glob(pattern, function (er, matches) {
      if (er)
        throw er

      // sort and unmark, just to match the shell results
      matches = cleanResults(matches)

      t.deepEqual(matches, expect, pattern)
      t.end()
    })
  })

  tap.test(pattern + " sync", function (t) {
    var matches = cleanResults(glob.sync(pattern))

    t.deepEqual(matches, expect, "should match shell")
    t.end()
  })
})

function cleanResults (m) {
  // normalize discrepancies in ordering, duplication,
  // and ending slashes.
  return m.map(function (m) {
    return m.replace(/\/+/g, "/").replace(/\/$/, "")
  }).sort(alphasort).reduce(function (set, f) {
    if (f !== set[set.length - 1]) set.push(f)
    return set
  }, []).sort(alphasort).map(function (f) {
    // de-windows
    return (process.platform !== 'win32') ? f
           : f.replace(/^[a-zA-Z]:[\/\\]+/, '/').replace(/[\\\/]+/g, '/')
  })
}

Version data entries

124 entries across 75 versions & 10 rubygems

Version Path
stylus-source-0.41.0 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.40.3 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.40.2 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.40.1 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.40.0 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.39.4 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.39.3 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.39.2 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.39.1 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.39.0 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
cssesc-source-0.1.0 vendor/node_modules/grunt/node_modules/glob/test/bash-comparison.js
cssesc-source-0.1.0 vendor/node_modules/istanbul/node_modules/fileset/node_modules/glob/test/bash-comparison.js
stylus-source-0.38.0 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.37.0 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.36.1 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.36.0 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.35.1 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.35.0 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.34.1 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js
stylus-source-0.34.0 vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js