提交 6b657c6f 编写于 作者: J John Lindgren

Fix (most) Rubocop warnings.

上级 28bf7954
......@@ -24,7 +24,7 @@ class ColourCommandLine
return unless RUBY_PLATFORM =~ /(win|w)32$/
get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
@set_console_txt_attrb =
Win32API.new('kernel32', 'SetConsoleTextAttribute', %w(L N), 'I')
Win32API.new('kernel32', 'SetConsoleTextAttribute', %w[L N], 'I')
@hout = get_std_handle.call(-11)
end
......@@ -107,7 +107,7 @@ class ColourCommandLine
$stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
end
end
end # ColourCommandLine
end
def colour_puts(role, str)
ColourCommandLine.new.out_c(:puts, role, str)
......
......@@ -4,7 +4,7 @@
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
require "#{File.expand_path(File.dirname(__FILE__))}/colour_prompt"
require_relative 'colour_prompt'
$colour_output = true
......
......@@ -45,8 +45,6 @@ TEMPLATE_INC ||= '#ifndef _%3$s_H
class UnityModuleGenerator
############################
def initialize(options = nil)
here = File.expand_path(File.dirname(__FILE__)) + '/'
@options = UnityModuleGenerator.default_options
case options
when NilClass then @options
......@@ -56,9 +54,9 @@ class UnityModuleGenerator
end
# Create default file paths if none were provided
@options[:path_src] = here + '../src/' if @options[:path_src].nil?
@options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
@options[:path_tst] = here + '../test/' if @options[:path_tst].nil?
@options[:path_src] = "#{__dir__}/../src/" if @options[:path_src].nil?
@options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
@options[:path_tst] = "#{__dir__}/../test/" if @options[:path_tst].nil?
@options[:path_src] += '/' unless @options[:path_src][-1] == 47
@options[:path_inc] += '/' unless @options[:path_inc][-1] == 47
@options[:path_tst] += '/' unless @options[:path_tst][-1] == 47
......
......@@ -4,8 +4,6 @@
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
File.expand_path(File.join(File.dirname(__FILE__), 'colour_prompt'))
class UnityTestRunnerGenerator
def initialize(options = nil)
@options = UnityTestRunnerGenerator.default_options
......@@ -15,7 +13,7 @@ class UnityTestRunnerGenerator
when Hash then @options.merge!(options)
else raise 'If you specify arguments, it should be a filename or a hash of options'
end
require "#{File.expand_path(File.dirname(__FILE__))}/type_sanitizer"
require_relative 'type_sanitizer'
end
def self.default_options
......@@ -165,7 +163,7 @@ class UnityTestRunnerGenerator
output.puts('#include "cmock.h"') unless mocks.empty?
output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H')
output.puts('#include <setjmp.h>')
output.puts("#endif")
output.puts('#endif')
output.puts('#include <stdio.h>')
if @options[:defines] && !@options[:defines].empty?
@options[:defines].each { |d| output.puts("#define #{d}") }
......@@ -379,7 +377,7 @@ class UnityTestRunnerGenerator
end
output.puts
output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
output.puts(" return suite_teardown(UnityEnd());")
output.puts(' return suite_teardown(UnityEnd());')
output.puts('}')
end
......
......@@ -210,7 +210,7 @@ class ParseOutput
# Adjusts the os specific members according to the current path style
# (Windows or Unix based)
def set_os_specifics(line)
def detect_os_specifics(line)
if line.include? '\\'
# Windows X:\Y\Z
@class_name_idx = 1
......@@ -254,43 +254,42 @@ class ParseOutput
# TEST(<test_group, <test_file>) PASS
#
# Note: Where path is different on Unix vs Windows devices (Windows leads with a drive letter)!
set_os_specifics(line)
detect_os_specifics(line)
line_array = line.split(':')
# If we were able to split the line then we can look to see if any of our target words
# were found. Case is important.
if (line_array.size >= 4) || (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
# check if the output is fixture output (with verbose flag "-v")
if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
line_array = prepare_fixture_line(line)
if line.include? ' PASS'
test_passed_unity_fixture(line_array)
@test_passed += 1
elsif line.include? 'FAIL'
test_failed_unity_fixture(line_array)
@test_failed += 1
elsif line.include? 'IGNORE'
test_ignored_unity_fixture(line_array)
@test_ignored += 1
end
# normal output / fixture output (without verbose "-v")
elsif line.include? ':PASS'
test_passed(line_array)
next unless (line_array.size >= 4) || (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
# check if the output is fixture output (with verbose flag "-v")
if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
line_array = prepare_fixture_line(line)
if line.include? ' PASS'
test_passed_unity_fixture(line_array)
@test_passed += 1
elsif line.include? ':FAIL'
test_failed(line_array)
elsif line.include? 'FAIL'
test_failed_unity_fixture(line_array)
@test_failed += 1
elsif line.include? ':IGNORE:'
test_ignored(line_array)
@test_ignored += 1
elsif line.include? ':IGNORE'
line_array.push('No reason given')
test_ignored(line_array)
elsif line.include? 'IGNORE'
test_ignored_unity_fixture(line_array)
@test_ignored += 1
end
@total_tests = @test_passed + @test_failed + @test_ignored
# normal output / fixture output (without verbose "-v")
elsif line.include? ':PASS'
test_passed(line_array)
@test_passed += 1
elsif line.include? ':FAIL'
test_failed(line_array)
@test_failed += 1
elsif line.include? ':IGNORE:'
test_ignored(line_array)
@test_ignored += 1
elsif line.include? ':IGNORE'
line_array.push('No reason given')
test_ignored(line_array)
@test_ignored += 1
end
@total_tests = @test_passed + @test_failed + @test_ignored
end
puts ''
puts '=================== SUMMARY ====================='
......
......@@ -61,8 +61,8 @@ class ArgvParser
opts.parse!(args)
options
end # parse()
end # class OptparseExample
end
end
class UnityToJUnit
include FileUtils::Verbose
......@@ -155,10 +155,6 @@ class UnityToJUnit
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
end
def here
File.expand_path(File.dirname(__FILE__))
end
private
def results_structure
......@@ -221,9 +217,9 @@ class UnityToJUnit
def write_suites_footer(stream)
stream.puts '</testsuites>'
end
end # UnityToJUnit
end
if __FILE__ == $0
if $0 == __FILE__
# parse out the command options
options = ArgvParser.parse(ARGV)
......
......@@ -11,8 +11,8 @@ module RakefileHelpers
def initialize(all_files = false)
@all_files = all_files
return false unless @all_files
return false unless File.exist?('test_file_filter.yml')
return unless @all_files
return unless File.exist?('test_file_filter.yml')
filters = YAML.load_file('test_file_filter.yml')
@all_files = filters[:all_files]
......
......@@ -101,10 +101,6 @@ class UnityTestSummary
raise "Couldn't parse test results: #{summary}" unless summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
end
def here
File.expand_path(File.dirname(__FILE__))
end
end
if $0 == __FILE__
......
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/../..'
require 'rake'
require 'rake/clean'
require HERE + 'rakefile_helper'
require_relative 'rakefile_helper'
TEMP_DIRS = [
File.join(HERE, 'build')
File.join(__dir__, 'build')
].freeze
TEMP_DIRS.each do |dir|
......@@ -32,8 +29,8 @@ task :summary do
end
desc 'Build and test Unity'
task all: %i(clean unit summary)
task default: %i(clobber all)
task all: %i[clean unit summary]
task default: %i[clobber all]
task ci: [:default]
task cruise: [:default]
......
require 'yaml'
require 'fileutils'
require UNITY_ROOT + '/auto/unity_test_summary'
require UNITY_ROOT + '/auto/generate_test_runner'
require UNITY_ROOT + '/auto/colour_reporter'
require_relative '../../auto/unity_test_summary'
require_relative '../../auto/generate_test_runner'
require_relative '../../auto/colour_reporter'
module RakefileHelpers
C_EXTENSION = '.c'.freeze
......@@ -149,7 +149,7 @@ module RakefileHelpers
def report_summary
summary = UnityTestSummary.new
summary.root = HERE
summary.root = __dir__
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
results_glob.tr!('\\', '/')
results = Dir[results_glob]
......
......@@ -4,15 +4,13 @@
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require HERE + 'rakefile_helper'
require_relative 'rakefile_helper'
TEMP_DIRS = [
File.join(HERE, 'build')
File.join(__dir__, 'build')
].freeze
TEMP_DIRS.each do |dir|
......@@ -33,10 +31,10 @@ task unit: [:prepare_for_tests] do
end
desc 'Build and test Unity Framework'
task all: %i(clean unit)
task default: %i(clobber all)
task ci: %i(no_color default)
task cruise: %i(no_color default)
task all: %i[clean unit]
task default: %i[clobber all]
task ci: %i[no_color default]
task cruise: %i[no_color default]
desc 'Load configuration'
task :config, :config_file do |_t, args|
......
......@@ -18,7 +18,7 @@ Style/HashSyntax:
EnforcedStyle: no_mixed_keys
# This is disabled because it seems to get confused over nested hashes
Style/AlignHash:
Layout/AlignHash:
Enabled: false
EnforcedHashRocketStyle: table
EnforcedColonStyle: table
......
......@@ -4,17 +4,16 @@
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/'
$verbose = false
require 'rake'
require 'rake/clean'
require UNITY_ROOT + 'rakefile_helper'
require_relative 'rakefile_helper'
require 'rspec/core/rake_task'
TEMP_DIRS = [
File.join(UNITY_ROOT, 'build'),
File.join(UNITY_ROOT, 'sandbox')
File.join(__dir__, 'build'),
File.join(__dir__, 'sandbox')
]
TEMP_DIRS.each do |dir|
......
......@@ -6,9 +6,9 @@
require 'yaml'
require 'fileutils'
require UNITY_ROOT + '../auto/unity_test_summary'
require UNITY_ROOT + '../auto/generate_test_runner'
require UNITY_ROOT + '../auto/colour_reporter'
require_relative '../auto/unity_test_summary'
require_relative '../auto/generate_test_runner'
require_relative '../auto/colour_reporter'
module RakefileHelpers
C_EXTENSION = '.c'.freeze
......@@ -179,7 +179,7 @@ module RakefileHelpers
def report_summary
summary = UnityTestSummary.new
summary.root = UNITY_ROOT
summary.root = __dir__
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
results_glob.tr!('\\', '/')
results = Dir[results_glob]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册