react / wstein / node_modules / react / node_modules / envify / node_modules / jstransform / node_modules / source-map / test / run-tests.js
80556 views#!/usr/bin/env node1/* -*- Mode: js; js-indent-level: 2; -*- */2/*3* Copyright 2011 Mozilla Foundation and contributors4* Licensed under the New BSD license. See LICENSE or:5* http://opensource.org/licenses/BSD-3-Clause6*/7var assert = require('assert');8var fs = require('fs');9var path = require('path');10var util = require('./source-map/util');1112function run(tests) {13var failures = [];14var total = 0;15var passed = 0;1617for (var i = 0; i < tests.length; i++) {18for (var k in tests[i].testCase) {19if (/^test/.test(k)) {20total++;21try {22tests[i].testCase[k](assert, util);23passed++;24}25catch (e) {26console.log('FAILED ' + tests[i].name + ': ' + k + '!');27console.log(e.stack);28}29}30}31}3233console.log("");34console.log(passed + ' / ' + total + ' tests passed.');35console.log("");3637failures.forEach(function (f) {38});3940return failures.length;41}4243var code;4445process.stdout.on('close', function () {46process.exit(code);47});4849function isTestFile(f) {50var testToRun = process.argv[2];51return testToRun52? path.basename(testToRun) === f53: /^test\-.*?\.js/.test(f);54}5556function toModule(f) {57return './source-map/' + f.replace(/\.js$/, '');58}5960var requires = fs.readdirSync(path.join(__dirname, 'source-map'))61.filter(isTestFile)62.map(toModule);6364code = run(requires.map(require).map(function (mod, i) {65return {66name: requires[i],67testCase: mod68};69}));70process.exit(code);717273