-
-
Save BenMorganIO/f688183d1f30d0c75b2d to your computer and use it in GitHub Desktop.
Test script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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