Skip to content

Instantly share code, notes, and snippets.

@BenMorganIO
Created January 24, 2015 00:01
Show Gist options
  • Select an option

  • Save BenMorganIO/f688183d1f30d0c75b2d to your computer and use it in GitHub Desktop.

Select an option

Save BenMorganIO/f688183d1f30d0c75b2d to your computer and use it in GitHub Desktop.
Test script
#!/usr/bin/env ruby
class Test
RUBOCOP = "rubocop"
COFFEELINT = "coffeelint ."
RSPEC = "spring rspec spec"
KARMA = "spring rake karma:run"
BRAKEMAN = "brakeman -A --summary -q"
def initialize
loop? ? loop { test } : test
end
private
def blocking_test
cmds = []
# Run Linters
cmds << "echo 'Rubocop:' && #{RUBOCOP}"
cmds << "echo '\nCoffeelint:' && #{COFFEELINT}"
# Run Test Suites
cmds << "echo 'RSpec:' && #{RSPEC}"
cmds << "echo '\nKarma:' && #{KARMA}"
# Misc
cmds << "echo '\nBrakeman:' && #{BRAKEMAN}"
loop? ? cmds.each { |cmd| puts `#{cmd}` } : exec(cmds.join("; "))
end
def parallel_test
require "parallel" unless defined? Parallel
cmds = [RUBOCOP, COFFEELINT, RSPEC, KARMA, BRAKEMAN]
Parallel.map(cmds) { |cmd| puts `#{cmd}` }
Parallel::Stop
end
def loop?
ARGV.include? "-l"
end
def parallel?
ARGV.include? "-p"
end
def test
parallel? ? parallel_test : blocking_test
end
end
Test.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment