mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-05-22 01:47:26 +08:00
Fix (most) Rubocop warnings.
This commit is contained in:
@ -24,7 +24,7 @@ class ColourCommandLine
|
|||||||
return unless RUBY_PLATFORM =~ /(win|w)32$/
|
return unless RUBY_PLATFORM =~ /(win|w)32$/
|
||||||
get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
|
get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
|
||||||
@set_console_txt_attrb =
|
@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)
|
@hout = get_std_handle.call(-11)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class ColourCommandLine
|
|||||||
$stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
|
$stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # ColourCommandLine
|
end
|
||||||
|
|
||||||
def colour_puts(role, str)
|
def colour_puts(role, str)
|
||||||
ColourCommandLine.new.out_c(: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]
|
# [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
|
$colour_output = true
|
||||||
|
|
||||||
|
@ -45,8 +45,6 @@ TEMPLATE_INC ||= '#ifndef _%3$s_H
|
|||||||
class UnityModuleGenerator
|
class UnityModuleGenerator
|
||||||
############################
|
############################
|
||||||
def initialize(options = nil)
|
def initialize(options = nil)
|
||||||
here = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
||||||
|
|
||||||
@options = UnityModuleGenerator.default_options
|
@options = UnityModuleGenerator.default_options
|
||||||
case options
|
case options
|
||||||
when NilClass then @options
|
when NilClass then @options
|
||||||
@ -56,9 +54,9 @@ class UnityModuleGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Create default file paths if none were provided
|
# Create default file paths if none were provided
|
||||||
@options[:path_src] = here + '../src/' if @options[:path_src].nil?
|
@options[:path_src] = "#{__dir__}/../src/" if @options[:path_src].nil?
|
||||||
@options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
|
@options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
|
||||||
@options[:path_tst] = here + '../test/' if @options[:path_tst].nil?
|
@options[:path_tst] = "#{__dir__}/../test/" if @options[:path_tst].nil?
|
||||||
@options[:path_src] += '/' unless @options[:path_src][-1] == 47
|
@options[:path_src] += '/' unless @options[:path_src][-1] == 47
|
||||||
@options[:path_inc] += '/' unless @options[:path_inc][-1] == 47
|
@options[:path_inc] += '/' unless @options[:path_inc][-1] == 47
|
||||||
@options[:path_tst] += '/' unless @options[:path_tst][-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]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
File.expand_path(File.join(File.dirname(__FILE__), 'colour_prompt'))
|
|
||||||
|
|
||||||
class UnityTestRunnerGenerator
|
class UnityTestRunnerGenerator
|
||||||
def initialize(options = nil)
|
def initialize(options = nil)
|
||||||
@options = UnityTestRunnerGenerator.default_options
|
@options = UnityTestRunnerGenerator.default_options
|
||||||
@ -15,7 +13,7 @@ class UnityTestRunnerGenerator
|
|||||||
when Hash then @options.merge!(options)
|
when Hash then @options.merge!(options)
|
||||||
else raise 'If you specify arguments, it should be a filename or a hash of options'
|
else raise 'If you specify arguments, it should be a filename or a hash of options'
|
||||||
end
|
end
|
||||||
require "#{File.expand_path(File.dirname(__FILE__))}/type_sanitizer"
|
require_relative 'type_sanitizer'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.default_options
|
def self.default_options
|
||||||
@ -165,7 +163,7 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts('#include "cmock.h"') unless mocks.empty?
|
output.puts('#include "cmock.h"') unless mocks.empty?
|
||||||
output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H')
|
output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H')
|
||||||
output.puts('#include <setjmp.h>')
|
output.puts('#include <setjmp.h>')
|
||||||
output.puts("#endif")
|
output.puts('#endif')
|
||||||
output.puts('#include <stdio.h>')
|
output.puts('#include <stdio.h>')
|
||||||
if @options[:defines] && !@options[:defines].empty?
|
if @options[:defines] && !@options[:defines].empty?
|
||||||
@options[:defines].each { |d| output.puts("#define #{d}") }
|
@options[:defines].each { |d| output.puts("#define #{d}") }
|
||||||
@ -379,7 +377,7 @@ class UnityTestRunnerGenerator
|
|||||||
end
|
end
|
||||||
output.puts
|
output.puts
|
||||||
output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
|
output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
|
||||||
output.puts(" return suite_teardown(UnityEnd());")
|
output.puts(' return suite_teardown(UnityEnd());')
|
||||||
output.puts('}')
|
output.puts('}')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class ParseOutput
|
|||||||
|
|
||||||
# Adjusts the os specific members according to the current path style
|
# Adjusts the os specific members according to the current path style
|
||||||
# (Windows or Unix based)
|
# (Windows or Unix based)
|
||||||
def set_os_specifics(line)
|
def detect_os_specifics(line)
|
||||||
if line.include? '\\'
|
if line.include? '\\'
|
||||||
# Windows X:\Y\Z
|
# Windows X:\Y\Z
|
||||||
@class_name_idx = 1
|
@class_name_idx = 1
|
||||||
@ -254,12 +254,12 @@ class ParseOutput
|
|||||||
# TEST(<test_group, <test_file>) PASS
|
# TEST(<test_group, <test_file>) PASS
|
||||||
#
|
#
|
||||||
# Note: Where path is different on Unix vs Windows devices (Windows leads with a drive letter)!
|
# 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(':')
|
line_array = line.split(':')
|
||||||
|
|
||||||
# If we were able to split the line then we can look to see if any of our target words
|
# 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.
|
# were found. Case is important.
|
||||||
if (line_array.size >= 4) || (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
|
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")
|
# check if the output is fixture output (with verbose flag "-v")
|
||||||
if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
|
if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
|
||||||
@ -291,7 +291,6 @@ class ParseOutput
|
|||||||
end
|
end
|
||||||
@total_tests = @test_passed + @test_failed + @test_ignored
|
@total_tests = @test_passed + @test_failed + @test_ignored
|
||||||
end
|
end
|
||||||
end
|
|
||||||
puts ''
|
puts ''
|
||||||
puts '=================== SUMMARY ====================='
|
puts '=================== SUMMARY ====================='
|
||||||
puts ''
|
puts ''
|
||||||
|
@ -61,8 +61,8 @@ class ArgvParser
|
|||||||
|
|
||||||
opts.parse!(args)
|
opts.parse!(args)
|
||||||
options
|
options
|
||||||
end # parse()
|
end
|
||||||
end # class OptparseExample
|
end
|
||||||
|
|
||||||
class UnityToJUnit
|
class UnityToJUnit
|
||||||
include FileUtils::Verbose
|
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]
|
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
||||||
end
|
end
|
||||||
|
|
||||||
def here
|
|
||||||
File.expand_path(File.dirname(__FILE__))
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def results_structure
|
def results_structure
|
||||||
@ -221,9 +217,9 @@ class UnityToJUnit
|
|||||||
def write_suites_footer(stream)
|
def write_suites_footer(stream)
|
||||||
stream.puts '</testsuites>'
|
stream.puts '</testsuites>'
|
||||||
end
|
end
|
||||||
end # UnityToJUnit
|
end
|
||||||
|
|
||||||
if __FILE__ == $0
|
if $0 == __FILE__
|
||||||
# parse out the command options
|
# parse out the command options
|
||||||
options = ArgvParser.parse(ARGV)
|
options = ArgvParser.parse(ARGV)
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ module RakefileHelpers
|
|||||||
def initialize(all_files = false)
|
def initialize(all_files = false)
|
||||||
@all_files = all_files
|
@all_files = all_files
|
||||||
|
|
||||||
return false unless @all_files
|
return unless @all_files
|
||||||
return false unless File.exist?('test_file_filter.yml')
|
return unless File.exist?('test_file_filter.yml')
|
||||||
|
|
||||||
filters = YAML.load_file('test_file_filter.yml')
|
filters = YAML.load_file('test_file_filter.yml')
|
||||||
@all_files = filters[:all_files]
|
@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/ }
|
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]
|
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
||||||
end
|
end
|
||||||
|
|
||||||
def here
|
|
||||||
File.expand_path(File.dirname(__FILE__))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if $0 == __FILE__
|
if $0 == __FILE__
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
||||||
UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/../..'
|
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/clean'
|
require 'rake/clean'
|
||||||
require HERE + 'rakefile_helper'
|
require_relative 'rakefile_helper'
|
||||||
|
|
||||||
TEMP_DIRS = [
|
TEMP_DIRS = [
|
||||||
File.join(HERE, 'build')
|
File.join(__dir__, 'build')
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
TEMP_DIRS.each do |dir|
|
TEMP_DIRS.each do |dir|
|
||||||
@ -32,8 +29,8 @@ task :summary do
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc 'Build and test Unity'
|
desc 'Build and test Unity'
|
||||||
task all: %i(clean unit summary)
|
task all: %i[clean unit summary]
|
||||||
task default: %i(clobber all)
|
task default: %i[clobber all]
|
||||||
task ci: [:default]
|
task ci: [:default]
|
||||||
task cruise: [:default]
|
task cruise: [:default]
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require UNITY_ROOT + '/auto/unity_test_summary'
|
require_relative '../../auto/unity_test_summary'
|
||||||
require UNITY_ROOT + '/auto/generate_test_runner'
|
require_relative '../../auto/generate_test_runner'
|
||||||
require UNITY_ROOT + '/auto/colour_reporter'
|
require_relative '../../auto/colour_reporter'
|
||||||
|
|
||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
C_EXTENSION = '.c'.freeze
|
C_EXTENSION = '.c'.freeze
|
||||||
@ -149,7 +149,7 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.root = HERE
|
summary.root = __dir__
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.tr!('\\', '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
|
@ -4,15 +4,13 @@
|
|||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/clean'
|
require 'rake/clean'
|
||||||
require 'rake/testtask'
|
require 'rake/testtask'
|
||||||
require HERE + 'rakefile_helper'
|
require_relative 'rakefile_helper'
|
||||||
|
|
||||||
TEMP_DIRS = [
|
TEMP_DIRS = [
|
||||||
File.join(HERE, 'build')
|
File.join(__dir__, 'build')
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
TEMP_DIRS.each do |dir|
|
TEMP_DIRS.each do |dir|
|
||||||
@ -33,10 +31,10 @@ task unit: [:prepare_for_tests] do
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc 'Build and test Unity Framework'
|
desc 'Build and test Unity Framework'
|
||||||
task all: %i(clean unit)
|
task all: %i[clean unit]
|
||||||
task default: %i(clobber all)
|
task default: %i[clobber all]
|
||||||
task ci: %i(no_color default)
|
task ci: %i[no_color default]
|
||||||
task cruise: %i(no_color default)
|
task cruise: %i[no_color default]
|
||||||
|
|
||||||
desc 'Load configuration'
|
desc 'Load configuration'
|
||||||
task :config, :config_file do |_t, args|
|
task :config, :config_file do |_t, args|
|
||||||
|
@ -18,7 +18,7 @@ Style/HashSyntax:
|
|||||||
EnforcedStyle: no_mixed_keys
|
EnforcedStyle: no_mixed_keys
|
||||||
|
|
||||||
# This is disabled because it seems to get confused over nested hashes
|
# This is disabled because it seems to get confused over nested hashes
|
||||||
Style/AlignHash:
|
Layout/AlignHash:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
EnforcedHashRocketStyle: table
|
EnforcedHashRocketStyle: table
|
||||||
EnforcedColonStyle: table
|
EnforcedColonStyle: table
|
||||||
|
@ -4,17 +4,16 @@
|
|||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
||||||
$verbose = false
|
$verbose = false
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/clean'
|
require 'rake/clean'
|
||||||
require UNITY_ROOT + 'rakefile_helper'
|
require_relative 'rakefile_helper'
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
|
|
||||||
TEMP_DIRS = [
|
TEMP_DIRS = [
|
||||||
File.join(UNITY_ROOT, 'build'),
|
File.join(__dir__, 'build'),
|
||||||
File.join(UNITY_ROOT, 'sandbox')
|
File.join(__dir__, 'sandbox')
|
||||||
]
|
]
|
||||||
|
|
||||||
TEMP_DIRS.each do |dir|
|
TEMP_DIRS.each do |dir|
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require UNITY_ROOT + '../auto/unity_test_summary'
|
require_relative '../auto/unity_test_summary'
|
||||||
require UNITY_ROOT + '../auto/generate_test_runner'
|
require_relative '../auto/generate_test_runner'
|
||||||
require UNITY_ROOT + '../auto/colour_reporter'
|
require_relative '../auto/colour_reporter'
|
||||||
|
|
||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
C_EXTENSION = '.c'.freeze
|
C_EXTENSION = '.c'.freeze
|
||||||
@ -179,7 +179,7 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.root = UNITY_ROOT
|
summary.root = __dir__
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.tr!('\\', '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
|
Reference in New Issue
Block a user