Module: Keeptesting::CLI

Defined in:
lib/keeptesting/cli.rb

Constant Summary collapse

GREEN_TEXT =
"\033[32m"
YELLOW_TEXT =
"\033[33m"
RED_TEXT =
"\033[31m"
RESET_TEXT =
"\033[0m"

Class Method Summary collapse

Class Method Details

.colorize_emacs_modeline(fg, bg) ⇒ Object



32
33
34
35
# File 'lib/keeptesting/cli.rb', line 32

def self.colorize_emacs_modeline(fg, bg)
  #TODO only run if emacsclient exists
  %x{emacsclient --eval "(set-face-attribute 'mode-line nil :background \\"#{bg}\\" :foreground \\"#{fg}\\")"}
end

.start_test_loop(options) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/keeptesting/cli.rb', line 37

def self.start_test_loop(options)
  Keeptesting::CLI::testrun(options)
  FSSM.monitor do
    options[:watched_paths].each do |watched_path|
      path watched_path do
        update {|base, relative| Keeptesting::CLI::testrun(options)}
        delete {|base, relative| Keeptesting::CLI::testrun(options)}
        create {|base, relative| Keeptesting::CLI::testrun(options)}
      end
    end
  end
end

.testrun(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/keeptesting/cli.rb', line 12

def self.testrun(options)
  puts `clear`
  puts "#{YELLOW_TEXT}RUNNING TESTS...#{RESET_TEXT}"
  Keeptesting::CLI::colorize_emacs_modeline("Black", "Gold")

  cmd = options[:test_command]
  test_output = `#{cmd} 2>&1`
  test_succeded = Keeptesting::Common::test_success?(test_output, options[:failure_regex])
  puts `clear`
  if test_succeded
    puts "#{GREEN_TEXT}SUCCESS!#{RESET_TEXT}\n\n\n"
    Keeptesting::CLI::colorize_emacs_modeline("White", "ForestGreen")
  else
    puts "#{RED_TEXT}FAILURE!#{RESET_TEXT}\n\n\n"
    Keeptesting::CLI::colorize_emacs_modeline("White", "Firebrick")
  end

  puts test_output
end