Skip to content

Commit 34e51f7

Browse files
committed
re-enable and expand selection and rejection of test files
1 parent 2273fe1 commit 34e51f7

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
- `to_h` and `to_s` functions for `ci_config.rb`
1111
- `CIConfig::clone`
1212
- Ability to override `CIConfig` from a hash instead of just a file
13+
- `arduino_ci_remote.rb` now supports command line switches `--testfile-select=GLOB` and `--testfile-reject=GLOB` (which can both be repeated)
1314

1415
### Changed
1516
- Simplified the use of `Array.each` with a return statement; it's now simply `Array.find`
@@ -22,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2223

2324
### Fixed
2425
- Determining a working OSX launch command no longer breaks on non-English installations
26+
- `arduino_ci_remote.rb` now honors selected and rejected test files
2527

2628
### Security
2729

exe/arduino_ci_remote.rb

+41-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,49 @@
22
require 'arduino_ci'
33
require 'set'
44
require 'pathname'
5+
require 'optparse'
56

67
WIDTH = 80
78
FIND_FILES_INDENT = 4
89

910
@failure_count = 0
1011
@passfail = proc { |result| result ? "✓" : "✗" }
1112

13+
# Use some basic parsing to allow command-line overrides of config
14+
class Parser
15+
def self.parse(options)
16+
parsed_config = {}
17+
parsed_config["unittest"] = {}
18+
19+
opt_parser = OptionParser.new do |opts|
20+
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
21+
22+
opts.on("--testfile-select=GLOB", "Unit test file (or glob) to select") do |p|
23+
parsed_config["unittest"]["testfiles"] ||= {}
24+
parsed_config["unittest"]["testfiles"]["select"] ||= []
25+
parsed_config["unittest"]["testfiles"]["select"] << p
26+
end
27+
28+
opts.on("--testfile-reject=GLOB", "Unit test file (or glob) to reject") do |p|
29+
parsed_config["unittest"]["testfiles"] ||= {}
30+
parsed_config["unittest"]["testfiles"]["reject"] ||= []
31+
parsed_config["unittest"]["testfiles"]["reject"] << p
32+
end
33+
34+
opts.on("-h", "--help", "Prints this help") do
35+
puts opts
36+
exit
37+
end
38+
end
39+
40+
opt_parser.parse!(options)
41+
parsed_config
42+
end
43+
end
44+
45+
# Read in command line options and make them read-only
46+
@cli_options = (Parser.parse ARGV).freeze
47+
1248
# terminate after printing any debug info. TODO: capture debug info
1349
def terminate(final = nil)
1450
puts "Failures: #{@failure_count}"
@@ -117,7 +153,10 @@ def display_files(pathname)
117153
non_hidden.each { |p| puts "#{margin}#{p}" }
118154
end
119155

120-
def perform_unit_tests(config)
156+
def perform_unit_tests(file_config)
157+
puts file_config.to_h[:unittest].to_s
158+
config = file_config.with_override_config(@cli_options)
159+
puts config.to_h[:unittest].to_s
121160
cpp_library = ArduinoCI::CppLibrary.new(Pathname.new("."), @arduino_cmd.lib_dir)
122161

123162
# check GCC
@@ -155,7 +194,7 @@ def perform_unit_tests(config)
155194
inform("Skipping unit tests") { "no platforms were requested" }
156195
else
157196
config.platforms_to_unittest.each do |p|
158-
cpp_library.test_files.each do |unittest_path|
197+
config.allowable_unittest_files(cpp_library.test_files).each do |unittest_path|
159198
unittest_name = unittest_path.basename.to_s
160199
compilers.each do |gcc_binary|
161200
attempt_multiline("Unit testing #{unittest_name} with #{gcc_binary}") do

0 commit comments

Comments
 (0)