Skip to content

Commit e707c9e

Browse files
committed
Add sensitivity to ARDUINO_CI_SELECT_CPP_TESTS to narrow the scope of rspec testing C++ files
1 parent 146bd37 commit e707c9e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99
### Added
10+
- Added rspec sensitivity to the environment variable `$ARDUINO_CI_SELECT_CPP_TESTS=<glob>` (for `arduino_ci` gem hackers)
1011

1112
### Changed
1213
- `CiConfig::allowable_unittest_files` now uses `Pathname` to full effect

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ To speed up testing by targeting only the files you're working on, you can set s
3232
* `ARDUINO_CI_SKIP_SPLASH_SCREEN_RSPEC_TESTS`: if set, this will avoid any rspec test that calls the arduino executable (and as such, causes the splash screen to pop up).
3333
* `ARDUINO_CI_SKIP_RUBY_RSPEC_TESTS`: if set, this will skip all tests against ruby code (useful if you are not changing Ruby code).
3434
* `ARDUINO_CI_SKIP_CPP_RSPEC_TESTS`: if set, this will skip all tests against the `TestSomething` sample project (useful if you are not changing C++ code).
35+
* `ARDUINO_CI_SELECT_CPP_TESTS=<glob>`: if set, this will skip all C++ unit tests whose filenames don't match the provided glob (executed in the tests directory)
3536

36-
You can set them to any value, they just have to be set. Example usage:
37+
Example usage:
3738

3839
```shell
3940
ARDUINO_CI_SKIP_RUBY_RSPEC_TESTS=1 bundle exec rspec

spec/testsomething_unittests_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ def get_relative_dir(sampleprojects_tests_dir)
4444
end
4545

4646
test_files = config.allowable_unittest_files(cpp_library.test_files)
47+
48+
# filter the list based on a glob, if provided
49+
unless ENV["ARDUINO_CI_SELECT_CPP_TESTS"].nil?
50+
Dir.chdir(cpp_library.tests_dir) do
51+
globbed = Pathname.glob(ENV["ARDUINO_CI_SELECT_CPP_TESTS"])
52+
test_files.select! { |p| globbed.include?(p.basename) }
53+
end
54+
end
4755
test_files.each do |path|
4856
tfn = File.basename(path)
4957

0 commit comments

Comments
 (0)