Skip to content

Instantly share code, notes, and snippets.

@timbertson
Created April 13, 2010 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timbertson/364555 to your computer and use it in GitHub Desktop.
Save timbertson/364555 to your computer and use it in GitHub Desktop.
exports.run_tests: run_tests: (cb) ->
remaining: (test for test in tests when test.success is null)
iterate: ->
if remaining.length == 0
cb()
return
test: remaining.shift()
test.run(iterate)
iterate()
# Run all defined tests, report and
# exit with the number of failed tests
run_standalone: () ->
run_tests ->
[failed, succeeded]: num_failed_and_passed()
report()
process.exit(failed)
# Add tests from a file and immediately run them
load_file: (file) ->
print_file file
code: fs.readFileSync file
CoffeeScript().run code, {source: file}
print_file: (file) ->
verbose "\n" + file + ":"
compile_file: (file, temp_path) ->
dir = path.dirname(file)
file = path.basename(file)
test: new TestFile dir, file
tests.push(test)
test.compile temp_path
readdirRecursive: (base) ->
realpath ||= base
files: []
for file in fs.readdirSync(base)
absfile: fs.realpathSync(path.join(base, file))
if fs.statSync(absfile).isDirectory()
files: files.concat(readdirRecursive(absfile))
else
files.push(absfile)
return files
relativePaths: (base, paths) ->
return p.replace(base + '/', '') for p in paths
get_log_level(opts) ->
log_level: verbosity.normal
log_level: verbosity.verbose if opts.verbose
log_level: verbosity.silent if opts.silent
return log_level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment