Permalink
Browse files

Update tools/generate-tests.js

  • Loading branch information...
Constellation committed Oct 24, 2012
1 parent 2f57b1f commit 1986b6f9ae3de3983b54217156e4f3a83e9953b1
Showing with 15 additions and 2 deletions.
  1. +15 −2 tools/generate-tests.js
View
17 tools/generate-tests.js 100644 → 100755
@@ -33,18 +33,31 @@
root = path.join(path.dirname(fs.realpathSync(__filename)), '..'),
names = process.argv.splice(2),
name,
+ current,
+ num,
+ exists,
test,
expected;
+ exists = fs.existsSync || path.existsSync;
+
if (names.length === 0) {
console.log('Usage:');
console.log(' node generate-tests.js name');
process.exit(1);
}
name = names[0];
- test = path.join(root, 'test', 'compare', name + '.js');
- expected = path.join(root, 'test', 'compare', name + '.expected.js');
+ current = name;
+ num = 1;
+ do {
+ test = path.join(root, 'test', 'compare', current + '.js');
+ expected = path.join(root, 'test', 'compare', current + '.expected.js');
+ if (!exists(test) && !exists(expected)) {
+ break;
+ }
+ current = name + '-' + (++num);
+ } while (true);
fs.writeFileSync(test, '', 'utf-8');
fs.writeFileSync(expected, '', 'utf-8');

0 comments on commit 1986b6f

Please sign in to comment.