Created
February 19, 2020 03:08
-
-
Save esafirm/81d66941f381d2f40044291c3e0710ba to your computer and use it in GitHub Desktop.
Script to test check
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 | |
# 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