Skip to content

Instantly share code, notes, and snippets.

@esafirm
Created February 19, 2020 03:08
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 esafirm/81d66941f381d2f40044291c3e0710ba to your computer and use it in GitHub Desktop.
Save esafirm/81d66941f381d2f40044291c3e0710ba to your computer and use it in GitHub Desktop.
Script to test check
#!/usr/bin/env ruby
# frozen_string_literal: true
TARGET_DIR = ARGV[0]
@failing_module = []
@no_test_module = []
def fail_number(file_path)
file = IO.read(file_path)
file.scan(%r{\<div class\="counter"\>(\d*)</div\>})[1][0].to_i
end
def append_fail_if_needed(mod, fail_number)
return if fail_number.zero?
@failing_module.append(
'fail': fail_number,
'mod': mod
)
end
def check_target(target_dir)
modules = Dir["#{target_dir}/*"]
modules.each do |mod|
file_path = "#{mod}/build/reports/tests/testDebugUnitTest/index.html"
if File.exist?(file_path)
append_fail_if_needed(mod, fail_number(file_path))
else
@no_test_module.append(mod)
end
end
end
if TARGET_DIR.nil?
%w[commons libs features].each { |target| check_target(target) }
else
check_target(TARGET_DIR)
end
formatted_error = @failing_module.map { |p| "#{p[:mod]} | Error: #{p[:fail]}" }
puts "Error Modules:\n#{formatted_error.join("\n")}"
puts "\n"
puts "No Test Modules:\n#{@no_test_module.join("\n")}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment