From da939052a735d11ae81411b259f1e642e255943c Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Thu, 21 Jan 2021 11:07:37 -0500 Subject: [PATCH 01/20] Test on linux on push --- .github/workflows/linux.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index 8a05f584..9c9247a8 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -1,7 +1,7 @@ # This is the name of the workflow, visible on GitHub UI name: linux -on: [pull_request] +on: [push, pull_request] jobs: "unittest_lint_sampleproject": From 7607915616b6c9a76451ce90c83f1faadf3ecf8b Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Thu, 21 Jan 2021 11:08:21 -0500 Subject: [PATCH 02/20] Avoid error when no examples directory exists --- CHANGELOG.md | 1 + lib/arduino_ci/cpp_library.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cac76ad..bed54d5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Removed ### Fixed +- A missing `examples` directory no longer causes a crash in `cpp_library.rb` ### Security diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb index 4ad7307f..0420e5b2 100644 --- a/lib/arduino_ci/cpp_library.rb +++ b/lib/arduino_ci/cpp_library.rb @@ -132,7 +132,10 @@ def info # @param installed_library_path [String] The library to query # @return [Array] Example sketch files def example_sketches - reported_dirs = info["library"]["examples"].map(&Pathname::method(:new)) + examples = info["library"]["examples"] + return [] if examples.nil? + + reported_dirs = examples.map(&Pathname::method(:new)) reported_dirs.map { |e| e + e.basename.sub_ext(".ino") }.select(&:exist?).sort_by(&:to_s) end From 8467ed952fed0e2d62b970b55208a86c0ebdda4a Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Thu, 21 Jan 2021 11:08:37 -0500 Subject: [PATCH 03/20] Fix documentation about CI --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e0a691e7..0159ce45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ ArduinoCI uses a very standard GitHub workflow. * If you are submitting code, use `master` as the base branch * If you are submitting broken unit tests (illustrating a bug that should be fixed), use `tdd` as the base branch. -Pull requests will trigger a Travis CI job. The following two commands will be expected to pass (so you may want to run them locally before opening the pull request): +Pull requests will trigger a CI job. The following two commands will be expected to pass (so you may want to run them locally before opening the pull request): * `bundle exec rubocop -D .` - code style tests * `bundle exec rspec` - functional tests From 1315d653d767a4a71aa8004fb4eaae68249245a8 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Thu, 21 Jan 2021 15:36:11 -0500 Subject: [PATCH 04/20] note that this project is for libraries --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d178110..3d4e239b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Gitter](https://badges.gitter.im/Arduino-CI/arduino_ci.svg)](https://gitter.im/Arduino-CI/arduino_ci?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![GitHub Marketplace](https://img.shields.io/badge/Get_it-on_Marketplace-informational.svg)](https://github.com/marketplace/actions/arduino_ci) -Arduino CI was created to enable better collaboration among Arduino library maintainers and contributors, by enabling automated code checks to be performed as part of a pull request process. +Arduino CI tests [Arduino libraries](https://arduino.github.io/arduino-cli/library-specification/); it was created to enable better collaboration among Arduino library maintainers and contributors, by enabling automated code checks to be performed as part of a pull request process. * enables running unit tests against the library **without hardware present** * provides a system of mocks that allow fine-grained control over the hardware inputs, including the system's clock From 6d3804f12df76f9ed6fee59e9cae11ced1f67b99 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Thu, 21 Jan 2021 15:37:12 -0500 Subject: [PATCH 05/20] remove now-incorrect message about library.properties tests in README --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 3d4e239b..7adf0f61 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ Arduino CI tests [Arduino libraries](https://arduino.github.io/arduino-cli/libra * provides a system of mocks that allow fine-grained control over the hardware inputs, including the system's clock * verifies compilation of any example sketches included in the library * can test a wide range of arduino boards with different hardware options available -* compares entries in `library.properties` to the contents of the library and reports mismatches * can be run both locally and as part of CI (GitHub Actions, TravisCI, Appveyor, etc.) * runs on multiple platforms -- any platform that supports the Arduino IDE * provides detailed analysis of segfaults in compilers that support such debugging features From 2d12190f160aacb92cf006e6d0e12cef334e9578 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Mon, 15 Feb 2021 11:14:54 -0500 Subject: [PATCH 06/20] Better communication about undefined platforms in config --- CHANGELOG.md | 1 + exe/arduino_ci.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bed54d5b..645c0c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - A missing `examples` directory no longer causes a crash in `cpp_library.rb` +- Referring to an undefined platform no longer causes a crash; it's now a helpful error message ### Security diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index 01234e7c..c2af0526 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -412,6 +412,11 @@ def perform_unit_tests(cpp_library, file_config) end end + # having undefined platforms is a config error + platforms.select { |p| config.platform_info[p].nil? }.each do |p| + assure("Platform '#{p}' is defined in configuration files") { false } + end + install_arduino_library_dependencies(config.aux_libraries_for_unittest, "") platforms.each do |p| @@ -462,6 +467,7 @@ def perform_example_compilation_tests(cpp_library, config) ovr_config = config.from_example(example_path) platforms = choose_platform_set(ovr_config, "library example", ovr_config.platforms_to_build, cpp_library.library_properties) + # having no platforms defined is probably an error if platforms.empty? explain_and_exercise_envvar(VAR_EXPECT_EXAMPLES, "examples compilation", "platforms and architectures") do puts " Configured platforms: #{ovr_config.platforms_to_build}" @@ -471,11 +477,16 @@ def perform_example_compilation_tests(cpp_library, config) end end + # having undefined platforms is a config error + platforms.select { |p| ovr_config.platform_info[p].nil? }.each do |p| + assure("Platform '#{p}' is defined in configuration files") { false } + end + install_all_packages(platforms, ovr_config) install_arduino_library_dependencies(ovr_config.aux_libraries_for_build, "") platforms.each do |p| - board = ovr_config.platform_info[p][:board] + board = ovr_config.platform_info[p][:board] # assured to exist, above attempt("Compiling #{example_name} for #{board}") do ret = @backend.compile_sketch(example_path, board) unless ret From a58fbfc3d14a4413b6274a2e1b7f2bc346ab1810 Mon Sep 17 00:00:00 2001 From: James Foster Date: Mon, 15 Feb 2021 10:47:58 -0800 Subject: [PATCH 07/20] Set all text files to have endings --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 4282322a..d56abbf3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ # Set the default behavior, in case people don't have core.autocrlf set. -* text eol=lf +* text=auto eol=lf From 39231dac768f34eb1eae7961621cef8f44711c96 Mon Sep 17 00:00:00 2001 From: James Foster Date: Mon, 15 Feb 2021 11:47:59 -0800 Subject: [PATCH 08/20] Update CHANGELOG.md to describe line endings change. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 645c0c7a..c440a65e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added ### Changed +- Update .gitattributes so we have consistent line endings ### Deprecated From 8ba04ddda8f3e7f2adc89dad3edb010a21be3d41 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 15:22:57 -0400 Subject: [PATCH 09/20] print working directory in test output --- CHANGELOG.md | 1 + exe/arduino_ci.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c440a65e..b93a55db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- Working directory is now printed in test runner output ### Changed - Update .gitattributes so we have consistent line endings diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index c2af0526..38358b3a 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -502,6 +502,7 @@ def perform_example_compilation_tests(cpp_library, config) banner inform("Host OS") { ArduinoCI::Host.os } +inform("Working directory") { Dir.pwd } # initialize command and config config = ArduinoCI::CIConfig.default.from_project_library From 6678d9d952b293af7a399b4271941c7fc53eb426 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 15:29:51 -0400 Subject: [PATCH 10/20] Explicitly include irb via rubygems --- CHANGELOG.md | 1 + Gemfile | 1 + SampleProjects/TestSomething/Gemfile | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b93a55db..10f31949 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added - Working directory is now printed in test runner output +- Explicitly include `irb` via rubygems ### Changed - Update .gitattributes so we have consistent line endings diff --git a/Gemfile b/Gemfile index d3ff73d9..ff624287 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } gemspec gem "bundler", "> 1.15", require: false, group: :test +gem "irb", "~> 1.3.5", require: false gem "keepachangelog_manager", "~> 0.0.2", require: false, group: :test gem "rspec", "~> 3.0", require: false, group: :test gem 'rubocop', '~>1.5.0', require: false, group: :test diff --git a/SampleProjects/TestSomething/Gemfile b/SampleProjects/TestSomething/Gemfile index b2b3b1fd..56c06235 100644 --- a/SampleProjects/TestSomething/Gemfile +++ b/SampleProjects/TestSomething/Gemfile @@ -1,2 +1,3 @@ source 'https://rubygems.org' gem 'arduino_ci', path: '../../' +gem "irb", "~> 1.3.5", require: false From 25728132753eafca39f6762cd0790cc0a58571c9 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 20:28:40 -0400 Subject: [PATCH 11/20] wrap library spec tests in a context --- spec/cpp_library_spec.rb | 281 ++++++++++++++++++++------------------- 1 file changed, 142 insertions(+), 139 deletions(-) diff --git a/spec/cpp_library_spec.rb b/spec/cpp_library_spec.rb index 050e0555..de3dea15 100644 --- a/spec/cpp_library_spec.rb +++ b/spec/cpp_library_spec.rb @@ -76,170 +76,173 @@ def verified_install(backend, path) RSpec.describe ArduinoCI::CppLibrary do next if skip_ruby_tests - answers = { - DoSomething: { - one_five: false, - library_properties: true, - cpp_files: [Pathname.new("DoSomething") + "do-something.cpp"], - cpp_files_libraries: [], - header_dirs: [Pathname.new("DoSomething")], - arduino_library_src_dirs: [], - test_files: [ - "DoSomething/test/bad-errormessages.cpp", - "DoSomething/test/bad-null.cpp", - "DoSomething/test/good-assert.cpp", - "DoSomething/test/good-library.cpp", - "DoSomething/test/good-null.cpp", - ].map { |f| Pathname.new(f) } - }, - OnePointOhDummy: { - one_five: false, - library_properties: false, - cpp_files: [ - "OnePointOhDummy/YesBase.cpp", - "OnePointOhDummy/utility/YesUtil.cpp", - ].map { |f| Pathname.new(f) }, - cpp_files_libraries: [], - header_dirs: [ - "OnePointOhDummy", - "OnePointOhDummy/utility" - ].map { |f| Pathname.new(f) }, - arduino_library_src_dirs: [], - test_files: [ - "OnePointOhDummy/test/null.cpp", - ].map { |f| Pathname.new(f) } - }, - OnePointFiveMalformed: { - one_five: false, - library_properties: false, - cpp_files: [ - "OnePointFiveMalformed/YesBase.cpp", - "OnePointFiveMalformed/utility/YesUtil.cpp", - ].map { |f| Pathname.new(f) }, - cpp_files_libraries: [], - header_dirs: [ - "OnePointFiveMalformed", - "OnePointFiveMalformed/utility" - ].map { |f| Pathname.new(f) }, - arduino_library_src_dirs: [], - test_files: [] - }, - OnePointFiveDummy: { + context "arduino-library-specification detection" do + + answers = { + DoSomething: { + one_five: false, + library_properties: true, + cpp_files: [Pathname.new("DoSomething") + "do-something.cpp"], + cpp_files_libraries: [], + header_dirs: [Pathname.new("DoSomething")], + arduino_library_src_dirs: [], + test_files: [ + "DoSomething/test/bad-errormessages.cpp", + "DoSomething/test/bad-null.cpp", + "DoSomething/test/good-assert.cpp", + "DoSomething/test/good-library.cpp", + "DoSomething/test/good-null.cpp", + ].map { |f| Pathname.new(f) } + }, + OnePointOhDummy: { + one_five: false, + library_properties: false, + cpp_files: [ + "OnePointOhDummy/YesBase.cpp", + "OnePointOhDummy/utility/YesUtil.cpp", + ].map { |f| Pathname.new(f) }, + cpp_files_libraries: [], + header_dirs: [ + "OnePointOhDummy", + "OnePointOhDummy/utility" + ].map { |f| Pathname.new(f) }, + arduino_library_src_dirs: [], + test_files: [ + "OnePointOhDummy/test/null.cpp", + ].map { |f| Pathname.new(f) } + }, + OnePointFiveMalformed: { + one_five: false, + library_properties: false, + cpp_files: [ + "OnePointFiveMalformed/YesBase.cpp", + "OnePointFiveMalformed/utility/YesUtil.cpp", + ].map { |f| Pathname.new(f) }, + cpp_files_libraries: [], + header_dirs: [ + "OnePointFiveMalformed", + "OnePointFiveMalformed/utility" + ].map { |f| Pathname.new(f) }, + arduino_library_src_dirs: [], + test_files: [] + }, + OnePointFiveDummy: { + one_five: true, + library_properties: true, + cpp_files: [ + "OnePointFiveDummy/src/YesSrc.cpp", + "OnePointFiveDummy/src/subdir/YesSubdir.cpp", + ].map { |f| Pathname.new(f) }, + cpp_files_libraries: [], + header_dirs: [ + "OnePointFiveDummy/src", + "OnePointFiveDummy/src/subdir", + ].map { |f| Pathname.new(f) }, + arduino_library_src_dirs: [], + test_files: [ + "OnePointFiveDummy/test/null.cpp", + ].map { |f| Pathname.new(f) } + } + } + + # easier to construct this one from the other test cases + answers[:DependOnSomething] = { one_five: true, library_properties: true, - cpp_files: [ - "OnePointFiveDummy/src/YesSrc.cpp", - "OnePointFiveDummy/src/subdir/YesSubdir.cpp", - ].map { |f| Pathname.new(f) }, - cpp_files_libraries: [], - header_dirs: [ - "OnePointFiveDummy/src", - "OnePointFiveDummy/src/subdir", - ].map { |f| Pathname.new(f) }, - arduino_library_src_dirs: [], + cpp_files: ["DependOnSomething/src/YesDeps.cpp"].map { |f| Pathname.new(f) }, + cpp_files_libraries: answers[:OnePointOhDummy][:cpp_files] + answers[:OnePointFiveDummy][:cpp_files], + header_dirs: ["DependOnSomething/src"].map { |f| Pathname.new(f) }, # this is not recursive! + arduino_library_src_dirs: answers[:OnePointOhDummy][:header_dirs] + answers[:OnePointFiveDummy][:header_dirs], test_files: [ - "OnePointFiveDummy/test/null.cpp", - ].map { |f| Pathname.new(f) } + "DependOnSomething/test/null.cpp", + ].map { |f| Pathname.new(f) } } - } - - # easier to construct this one from the other test cases - answers[:DependOnSomething] = { - one_five: true, - library_properties: true, - cpp_files: ["DependOnSomething/src/YesDeps.cpp"].map { |f| Pathname.new(f) }, - cpp_files_libraries: answers[:OnePointOhDummy][:cpp_files] + answers[:OnePointFiveDummy][:cpp_files], - header_dirs: ["DependOnSomething/src"].map { |f| Pathname.new(f) }, # this is not recursive! - arduino_library_src_dirs: answers[:OnePointOhDummy][:header_dirs] + answers[:OnePointFiveDummy][:header_dirs], - test_files: [ - "DependOnSomething/test/null.cpp", - ].map { |f| Pathname.new(f) } - } - answers.freeze + answers.freeze - answers.each do |sampleproject, expected| + answers.each do |sampleproject, expected| - # we will need to install some dummy libraries into a fake location, so do that on demand - fld = FakeLibDir.new - backend = fld.backend + # we will need to install some dummy libraries into a fake location, so do that on demand + fld = FakeLibDir.new + backend = fld.backend - context "#{sampleproject}" do - cpp_lib_path = sampleproj_path + sampleproject.to_s - around(:example) { |example| fld.in_pristine_fake_libraries_dir(example) } - before(:each) do - @base_dir = fld.libraries_dir - @cpp_library = verified_install(backend, cpp_lib_path) - end + context "#{sampleproject}" do + cpp_lib_path = sampleproj_path + sampleproject.to_s + around(:example) { |example| fld.in_pristine_fake_libraries_dir(example) } + before(:each) do + @base_dir = fld.libraries_dir + @cpp_library = verified_install(backend, cpp_lib_path) + end - it "is a sane test env" do - expect(sampleproject.to_s).to eq(@cpp_library.name) - end + it "is a sane test env" do + expect(sampleproject.to_s).to eq(@cpp_library.name) + end - it "detects 1.5 format" do - expect(@cpp_library.one_point_five?).to eq(expected[:one_five]) - end + it "detects 1.5 format" do + expect(@cpp_library.one_point_five?).to eq(expected[:one_five]) + end - it "detects library.properties" do - expect(@cpp_library.library_properties?).to eq(expected[:library_properties]) - end + it "detects library.properties" do + expect(@cpp_library.library_properties?).to eq(expected[:library_properties]) + end - context "cpp_files" do - it "finds cpp files in directory" do - relative_paths = @cpp_library.cpp_files.map { |f| f.relative_path_from(@base_dir) } - expect(relative_paths.map(&:to_s)).to match_array(expected[:cpp_files].map(&:to_s)) + context "cpp_files" do + it "finds cpp files in directory" do + relative_paths = @cpp_library.cpp_files.map { |f| f.relative_path_from(@base_dir) } + expect(relative_paths.map(&:to_s)).to match_array(expected[:cpp_files].map(&:to_s)) + end end - end - context "cpp_files_libraries" do - it "finds cpp files in directories of dependencies" do - @cpp_library.all_arduino_library_dependencies! # side effect: installs them - dependencies = @cpp_library.arduino_library_dependencies.nil? ? [] : @cpp_library.arduino_library_dependencies - dependencies.each { |d| verified_install(backend, sampleproj_path + d) } - relative_paths = @cpp_library.cpp_files_libraries(dependencies).map { |f| f.relative_path_from(@base_dir) } - expect(relative_paths.map(&:to_s)).to match_array(expected[:cpp_files_libraries].map(&:to_s)) + context "cpp_files_libraries" do + it "finds cpp files in directories of dependencies" do + @cpp_library.all_arduino_library_dependencies! # side effect: installs them + dependencies = @cpp_library.arduino_library_dependencies.nil? ? [] : @cpp_library.arduino_library_dependencies + dependencies.each { |d| verified_install(backend, sampleproj_path + d) } + relative_paths = @cpp_library.cpp_files_libraries(dependencies).map { |f| f.relative_path_from(@base_dir) } + expect(relative_paths.map(&:to_s)).to match_array(expected[:cpp_files_libraries].map(&:to_s)) + end end - end - context "header_dirs" do - it "finds directories containing h files" do - relative_paths = @cpp_library.header_dirs.map { |f| f.relative_path_from(@base_dir) } - expect(relative_paths.map(&:to_s)).to match_array(expected[:header_dirs].map(&:to_s)) + context "header_dirs" do + it "finds directories containing h files" do + relative_paths = @cpp_library.header_dirs.map { |f| f.relative_path_from(@base_dir) } + expect(relative_paths.map(&:to_s)).to match_array(expected[:header_dirs].map(&:to_s)) + end end - end - context "tests_dir" do - it "locates the tests directory" do - # since we don't know where the CI system will install this stuff, - # we need to go looking for a relative path to the SampleProjects directory - # just to get our "expected" value - relative_path = @cpp_library.tests_dir.relative_path_from(@base_dir) - expect(relative_path.to_s).to eq("#{sampleproject}/test") + context "tests_dir" do + it "locates the tests directory" do + # since we don't know where the CI system will install this stuff, + # we need to go looking for a relative path to the SampleProjects directory + # just to get our "expected" value + relative_path = @cpp_library.tests_dir.relative_path_from(@base_dir) + expect(relative_path.to_s).to eq("#{sampleproject}/test") + end end - end - context "examples_dir" do - it "locates the examples directory" do - relative_path = @cpp_library.examples_dir.relative_path_from(@base_dir) - expect(relative_path.to_s).to eq("#{sampleproject}/examples") + context "examples_dir" do + it "locates the examples directory" do + relative_path = @cpp_library.examples_dir.relative_path_from(@base_dir) + expect(relative_path.to_s).to eq("#{sampleproject}/examples") + end end - end - context "test_files" do - it "finds cpp files in directory" do - relative_paths = @cpp_library.test_files.map { |f| f.relative_path_from(@base_dir) } - expect(relative_paths.map(&:to_s)).to match_array(expected[:test_files].map(&:to_s)) + context "test_files" do + it "finds cpp files in directory" do + relative_paths = @cpp_library.test_files.map { |f| f.relative_path_from(@base_dir) } + expect(relative_paths.map(&:to_s)).to match_array(expected[:test_files].map(&:to_s)) + end end - end - context "arduino_library_src_dirs" do - it "finds src dirs from dependent libraries" do - # we explicitly feed in the internal dependencies - dependencies = @cpp_library.arduino_library_dependencies.nil? ? [] : @cpp_library.arduino_library_dependencies - dependencies.each { |d| verified_install(backend, sampleproj_path + d) } - relative_paths = @cpp_library.arduino_library_src_dirs(dependencies).map { |f| f.relative_path_from(@base_dir) } - expect(relative_paths.map(&:to_s)).to match_array(expected[:arduino_library_src_dirs].map(&:to_s)) + context "arduino_library_src_dirs" do + it "finds src dirs from dependent libraries" do + # we explicitly feed in the internal dependencies + dependencies = @cpp_library.arduino_library_dependencies.nil? ? [] : @cpp_library.arduino_library_dependencies + dependencies.each { |d| verified_install(backend, sampleproj_path + d) } + relative_paths = @cpp_library.arduino_library_src_dirs(dependencies).map { |f| f.relative_path_from(@base_dir) } + expect(relative_paths.map(&:to_s)).to match_array(expected[:arduino_library_src_dirs].map(&:to_s)) + end end end end From aacfdb2636ab3bbf159e573a3f081b3222dd47a7 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 20:29:19 -0400 Subject: [PATCH 12/20] Fix typo in compiler flag generation --- CHANGELOG.md | 1 + lib/arduino_ci/cpp_library.rb | 2 +- spec/cpp_library_spec.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10f31949..f10a3e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - A missing `examples` directory no longer causes a crash in `cpp_library.rb` - Referring to an undefined platform no longer causes a crash; it's now a helpful error message +- A copy/paste error that prevented compiler warning flags from being supplied has been fixed, via jgfoster ### Security diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb index 0420e5b2..0a9bac2e 100644 --- a/lib/arduino_ci/cpp_library.rb +++ b/lib/arduino_ci/cpp_library.rb @@ -446,7 +446,7 @@ def feature_args(ci_gcc_config) def warning_args(ci_gcc_config) return [] if ci_gcc_config[:warnings].nil? - ci_gcc_config[:features].map { |w| "-W#{w}" } + ci_gcc_config[:warnings].map { |w| "-W#{w}" } end # GCC command line arguments for defines (e.g. -Dhave_something) diff --git a/spec/cpp_library_spec.rb b/spec/cpp_library_spec.rb index de3dea15..825c3650 100644 --- a/spec/cpp_library_spec.rb +++ b/spec/cpp_library_spec.rb @@ -76,6 +76,32 @@ def verified_install(backend, path) RSpec.describe ArduinoCI::CppLibrary do next if skip_ruby_tests + context "compiler flags" do + config = ArduinoCI::CIConfig.new + config.load_yaml(File.join(File.dirname(__FILE__), "yaml", "o1.yaml")) + bogo_config = config.gcc_config("bogo") + fld = FakeLibDir.new + backend = fld.backend + cpp_lib_path = sampleproj_path + "DoSomething" + cpp_library = verified_install(backend, cpp_lib_path) + + # the keys are the methods of cpp_library to call + # the results are what we expect to see based on the config we loaded + methods_and_results = { + feature_args: ["-fa", "-fb"], + warning_args: ["-We", "-Wf"], + define_args: ["-Dc", "-Dd"], + flag_args: ["g", "h"] + } + + methods_and_results.each do |m, expected| + it "Creates #{m} from config" do + expect(expected).to eq(cpp_library.send(m, bogo_config)) + end + end + + end + context "arduino-library-specification detection" do answers = { From 71c89c39445f55160bdc08b7af27d4016d80e31e Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 20:42:03 -0400 Subject: [PATCH 13/20] remove dead code around unit test config overriding --- exe/arduino_ci.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index 38358b3a..9a1ab06d 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -17,13 +17,9 @@ # Use some basic parsing to allow command-line overrides of config class Parser def self.parse(options) - unit_config = {} output_options = { skip_unittests: false, skip_compilation: false, - ci_config: { - "unittest" => unit_config - }, } opt_parser = OptionParser.new do |opts| @@ -383,14 +379,13 @@ def choose_platform_set(config, reason, desired_platforms, library_properties) end # Unit test procedure -def perform_unit_tests(cpp_library, file_config) +def perform_unit_tests(cpp_library, config) phase("Unit testing") if @cli_options[:skip_unittests] inform("Skipping unit tests") { "as requested via command line" } return end - config = file_config.with_override_config(@cli_options[:ci_config]) compilers = get_annotated_compilers(config, cpp_library) inform("Library conforms to Arduino library specification") { cpp_library.one_point_five? ? "1.5" : "1.0" } From ecdf5cdc0b460cc7066d00a846a13b9a47c628dc Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 21:01:56 -0400 Subject: [PATCH 14/20] allow flexibility in console width --- CHANGELOG.md | 1 + exe/arduino_ci.rb | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f10a3e8d..49f722ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Update .gitattributes so we have consistent line endings +- Test runner detects console width if possible, allowing variable width from 80-132 chars ### Deprecated diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index 9a1ab06d..8c21761c 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -3,8 +3,14 @@ require 'set' require 'pathname' require 'optparse' +require 'io/console' -WIDTH = 80 +# be flexible between 80 and 132 cols of output +WIDTH = begin + [132, [80, IO::console.winsize[1] - 2].max].min +rescue NoMethodError + 80 +end VAR_CUSTOM_INIT_SCRIPT = "CUSTOM_INIT_SCRIPT".freeze VAR_USE_SUBDIR = "USE_SUBDIR".freeze VAR_EXPECT_EXAMPLES = "EXPECT_EXAMPLES".freeze From 78e2be4d15bf8004090ef80865f7d97c2b730093 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 21:17:37 -0400 Subject: [PATCH 15/20] Add megaavr / nano_every support, via midasgossye --- CHANGELOG.md | 1 + misc/default.yml | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49f722ad..80f5592a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Working directory is now printed in test runner output - Explicitly include `irb` via rubygems +- `arduino:megaavr` architecture is now included by default, using the `nano_every` platform, via midasgossye ### Changed - Update .gitattributes so we have consistent line endings diff --git a/misc/default.yml b/misc/default.yml index befbfa6f..9e49d95a 100644 --- a/misc/default.yml +++ b/misc/default.yml @@ -9,6 +9,8 @@ packages: url: https://downloads.arduino.cc/packages/package_index.json arduino:samd: url: https://downloads.arduino.cc/packages/package_index.json + arduino:megaavr: + url: https://downloads.arduino.cc/packages/package_index.json esp8266:esp8266: url: http://arduino.esp8266.com/stable/package_esp8266com_index.json adafruit:avr: @@ -57,6 +59,17 @@ platforms: - NUM_SERIAL_PORTS=2 warnings: flags: + nano_every: + board: arduino:megaavr:nona4809 + package: arduino:megaavr + gcc: + features: + defines: + - MILLIS_USE_TIMERB3 + - NO_EXTERNAL_I2C_PULLUP + - AVR_NANO_4809_328MODE + warnings: + flags: esp32: board: esp32:esp32:featheresp32:FlashFreq=80 package: esp32:esp32 From 665523b21988978e8852dd51ae2c4bcf42e2d4bc Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 21:01:46 -0400 Subject: [PATCH 16/20] Make windows tests actually run on windows --- .github/workflows/windows.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 6001624e..96982d10 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -5,7 +5,7 @@ on: [pull_request] jobs: "unittest_lint_sampleproject": - runs-on: ubuntu-latest + runs-on: windows-2019 steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 @@ -23,7 +23,7 @@ jobs: bundle exec arduino_ci.rb NetworkLib: - runs-on: ubuntu-latest + runs-on: windows-2019 steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 From fb461e8ab282189d4c1321be679db2c553c5dc58 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 21:29:07 -0400 Subject: [PATCH 17/20] Fix unit testing on windows --- SampleProjects/TestSomething/test/godmode.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SampleProjects/TestSomething/test/godmode.cpp b/SampleProjects/TestSomething/test/godmode.cpp index 024b9915..1168a863 100644 --- a/SampleProjects/TestSomething/test/godmode.cpp +++ b/SampleProjects/TestSomething/test/godmode.cpp @@ -236,9 +236,9 @@ unittest(shift_in) { originalSize = state->digitalPin[clockPin].historySize(); input = shiftIn(dataPin, clockPin, MSBFIRST); - assertEqual(0x7C, (uint)input); // 0111 1100 + assertEqual(0x7C, (uint8_t)input); // 0111 1100 assertEqual('|', input); // 0111 1100 - assertEqual((uint)'|', (uint)input); // 0111 1100 + assertEqual((uint8_t)'|', (uint8_t)input); // 0111 1100 // now verify clock assertEqual(16, state->digitalPin[clockPin].historySize() - originalSize); @@ -249,15 +249,15 @@ unittest(shift_in) { state->reset(); state->digitalPin[dataPin].fromAscii("|", true); // 0111 1100 input = shiftIn(dataPin, clockPin, LSBFIRST); // <- note the LSB/MSB flip - assertEqual(0x3E, (uint)input); // 0011 1110 + assertEqual(0x3E, (uint8_t)input); // 0011 1110 assertEqual('>', input); // 0011 1110 - assertEqual((uint)'>', (uint)input); // 0011 1110 + assertEqual((uint8_t)'>', (uint8_t)input); // 0011 1110 // test setting MSB state->reset(); state->digitalPin[dataPin].fromAscii("U", true); // 0101 0101 input = shiftIn(dataPin, clockPin, LSBFIRST); // <- note the LSB/MSB flip - assertEqual(0xAA, (uint)input); // 1010 1010 + assertEqual(0xAA, (uint8_t)input); // 1010 1010 } unittest(shift_out) { From 20152711a2246a16b99fe36a43887c3a47cfc59f Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 22:43:00 -0400 Subject: [PATCH 18/20] Fix compile errors reporting in rspec --- CHANGELOG.md | 1 + spec/testsomething_unittests_spec.rb | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80f5592a..fa5ff943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - A missing `examples` directory no longer causes a crash in `cpp_library.rb` - Referring to an undefined platform no longer causes a crash; it's now a helpful error message - A copy/paste error that prevented compiler warning flags from being supplied has been fixed, via jgfoster +- RSpec was not communicating compile errors from unit test executables that failed to build. Now it does, via jgfoster ### Security diff --git a/spec/testsomething_unittests_spec.rb b/spec/testsomething_unittests_spec.rb index c882399f..1f7bce72 100644 --- a/spec/testsomething_unittests_spec.rb +++ b/spec/testsomething_unittests_spec.rb @@ -72,7 +72,7 @@ context "file #{tfn} (using #{compiler})" do around(:example) { |example| fld.in_pristine_fake_libraries_dir(example) } - before(:all) do + before(:each) do @cpp_library = backend.install_local_library(cpp_lib_path) @exe = @cpp_library.build_for_test_with_configuration(path, [], compiler, config.gcc_config("uno")) end @@ -88,11 +88,8 @@ end end - it "#{tfn} builds successfully" do + it "#{tfn} builds successfully and passes tests" do expect(@exe).not_to be nil - end - it "#{tfn} passes tests" do - skip "Can't run the test program because it failed to build" if @exe.nil? expect(@cpp_library.run_test_file(@exe)).to_not be_falsey end end From 32196ac25e702d3bbfac83121d575a5343c223f7 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Sun, 4 Apr 2021 23:11:20 -0400 Subject: [PATCH 19/20] Avoid ingesting windows pathnames with backslashes -- convert to forward slashes --- CHANGELOG.md | 1 + lib/arduino_ci/arduino_backend.rb | 4 +++- lib/arduino_ci/arduino_downloader.rb | 2 +- lib/arduino_ci/arduino_downloader_linux.rb | 6 ------ lib/arduino_ci/arduino_downloader_osx.rb | 6 ------ lib/arduino_ci/arduino_downloader_windows.rb | 12 ++++++------ lib/arduino_ci/host.rb | 9 +++++---- spec/arduino_downloader_spec.rb | 1 - spec/host_spec.rb | 2 +- 9 files changed, 17 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa5ff943..f161e1b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Referring to an undefined platform no longer causes a crash; it's now a helpful error message - A copy/paste error that prevented compiler warning flags from being supplied has been fixed, via jgfoster - RSpec was not communicating compile errors from unit test executables that failed to build. Now it does, via jgfoster +- Windows paths now avoid picking up backslashes, for proper equality comparisons ### Security diff --git a/lib/arduino_ci/arduino_backend.rb b/lib/arduino_ci/arduino_backend.rb index 4e04f5b3..cb3e4238 100644 --- a/lib/arduino_ci/arduino_backend.rb +++ b/lib/arduino_ci/arduino_backend.rb @@ -90,7 +90,9 @@ def config_dump # @return [String] the path to the Arduino libraries directory def lib_dir - Pathname.new(config_dump["directories"]["user"]) + "libraries" + user_dir_raw = config_dump["directories"]["user"] + user_dir = OS.windows? ? Host.windows_to_pathname(user_dir_raw) : user_dir_raw + Pathname.new(user_dir) + "libraries" end # Board manager URLs diff --git a/lib/arduino_ci/arduino_downloader.rb b/lib/arduino_ci/arduino_downloader.rb index 2acdf30c..c3081f7d 100644 --- a/lib/arduino_ci/arduino_downloader.rb +++ b/lib/arduino_ci/arduino_downloader.rb @@ -43,7 +43,7 @@ def self.autolocated_executable # The executable Arduino file in an existing installation, or nil # @return [Pathname] def self.existing_executable - self.must_implement(__method__) + Host.which("arduino-cli") end # The local file (dir) name of the desired IDE package (zip/tar/etc) diff --git a/lib/arduino_ci/arduino_downloader_linux.rb b/lib/arduino_ci/arduino_downloader_linux.rb index 487273d1..8eb787eb 100644 --- a/lib/arduino_ci/arduino_downloader_linux.rb +++ b/lib/arduino_ci/arduino_downloader_linux.rb @@ -17,12 +17,6 @@ def self.extracted_file "arduino-cli" end - # The executable Arduino file in an existing installation, or nil - # @return [string] - def self.existing_executable - Host.which("arduino-cli") - end - # Make any preparations or run any checks prior to making changes # @return [string] Error message, or nil if success def prepare diff --git a/lib/arduino_ci/arduino_downloader_osx.rb b/lib/arduino_ci/arduino_downloader_osx.rb index 89890599..9e77505b 100644 --- a/lib/arduino_ci/arduino_downloader_osx.rb +++ b/lib/arduino_ci/arduino_downloader_osx.rb @@ -17,12 +17,6 @@ def self.extracted_file "arduino-cli" end - # The executable Arduino file in an existing installation, or nil - # @return [string] - def self.existing_executable - Host.which("arduino-cli") - end - # Make any preparations or run any checks prior to making changes # @return [string] Error message, or nil if success def prepare diff --git a/lib/arduino_ci/arduino_downloader_windows.rb b/lib/arduino_ci/arduino_downloader_windows.rb index 9b7d1862..ffb952a2 100644 --- a/lib/arduino_ci/arduino_downloader_windows.rb +++ b/lib/arduino_ci/arduino_downloader_windows.rb @@ -28,12 +28,6 @@ def package_file "arduino-cli_#{@desired_version}_Windows_64bit.zip" end - # The executable Arduino file in an existing installation, or nil - # @return [string] - def self.existing_executable - Host.which("arduino-cli") - end - # The technology that will be used to extract the download # (for logging purposes) # @return [string] @@ -57,5 +51,11 @@ def self.extracted_file "arduino-cli.exe" end + # The executable Arduino file in a forced installation, or nil + # @return [Pathname] + def self.force_installed_executable + Pathname.new(Host.windows_to_pathname(ENV['HOME'])) + self.extracted_file + end + end end diff --git a/lib/arduino_ci/host.rb b/lib/arduino_ci/host.rb index dc8e2911..4cd5e243 100644 --- a/lib/arduino_ci/host.rb +++ b/lib/arduino_ci/host.rb @@ -17,13 +17,14 @@ class Host # via https://stackoverflow.com/a/5471032/2063546 # which('ruby') #=> /usr/bin/ruby # @param cmd [String] the command to search for - # @return [String] the full path to the command if it exists + # @return [Pathname] the full path to the command if it exists def self.which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] - ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| + ENV['PATH'].split(File::PATH_SEPARATOR).each do |string_path| + path = OS.windows? ? windows_to_pathname(string_path) : Pathname.new(string_path) exts.each do |ext| - exe = File.join(path, "#{cmd}#{ext}") - return exe if File.executable?(exe) && !File.directory?(exe) + exe = path.join("#{cmd}#{ext}") + return exe if exe.executable? && !exe.directory? end end nil diff --git a/spec/arduino_downloader_spec.rb b/spec/arduino_downloader_spec.rb index 9158b439..6fda6366 100644 --- a/spec/arduino_downloader_spec.rb +++ b/spec/arduino_downloader_spec.rb @@ -7,7 +7,6 @@ it "has correct class properties" do ad = ArduinoCI::ArduinoDownloader - expect{ad.existing_executable}.to raise_error(NotImplementedError) expect{ad.extracted_file}.to raise_error(NotImplementedError) expect{ad.extracter}.to raise_error(NotImplementedError) expect{ad.extract("foo")}.to raise_error(NotImplementedError) diff --git a/spec/host_spec.rb b/spec/host_spec.rb index ac40f4e0..f9b94f4b 100644 --- a/spec/host_spec.rb +++ b/spec/host_spec.rb @@ -54,7 +54,7 @@ def with_tmpdir(path) it "can find things with which" do ruby_path = ArduinoCI::Host.which("ruby") expect(ruby_path).not_to be nil - expect(ruby_path.include? "ruby").to be true + expect(ruby_path.to_s.include? "ruby").to be true end end From 1ee342c18740e665b265cc81af346c9ee160c208 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Mon, 5 Apr 2021 00:00:25 -0400 Subject: [PATCH 20/20] Put build artifacts in temporary directories --- CHANGELOG.md | 1 + exe/arduino_ci.rb | 4 +++- lib/arduino_ci/cpp_library.rb | 23 +++++++++++------------ spec/cpp_library_spec.rb | 2 +- spec/testsomething_unittests_spec.rb | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f161e1b7..8531167d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Update .gitattributes so we have consistent line endings - Test runner detects console width if possible, allowing variable width from 80-132 chars +- Unit test executables are now built as tempfiles ### Deprecated diff --git a/exe/arduino_ci.rb b/exe/arduino_ci.rb index 8c21761c..4abeaac2 100755 --- a/exe/arduino_ci.rb +++ b/exe/arduino_ci.rb @@ -439,7 +439,9 @@ def perform_unit_tests(cpp_library, config) puts cpp_library.last_err next false end - cpp_library.run_test_file(exe) + cpp_library.run_test_file(Pathname.new(exe.path)) + ensure + exe&.unlink end end end diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb index 0a9bac2e..c7736a40 100644 --- a/lib/arduino_ci/cpp_library.rb +++ b/lib/arduino_ci/cpp_library.rb @@ -23,9 +23,6 @@ class CppLibrary # @return [ArduinoBackend] The backend support for this library attr_reader :backend - # @return [Array] The set of artifacts created by this class (note: incomplete!) - attr_reader :artifacts - # @return [Array] The set of directories that should be excluded from compilation attr_reader :exclude_dirs @@ -50,7 +47,6 @@ def initialize(friendly_name, backend) @name = friendly_name @backend = backend @info_cache = nil - @artifacts = [] @last_err = "" @last_out = "" @last_msg = "" @@ -491,13 +487,13 @@ def test_args(aux_libraries, ci_gcc_config) # @param test_file [Pathname] The path to the file containing the unit tests # @param aux_libraries [Array] The external Arduino libraries required by this project # @param ci_gcc_config [Hash] The GCC config object - # @return [Pathname] path to the compiled test executable + # @return [Tempfile] the compiled test executable def build_for_test_with_configuration(test_file, aux_libraries, gcc_binary, ci_gcc_config) base = test_file.basename - executable = Pathname.new("unittest_#{base}.bin").expand_path - File.delete(executable) if File.exist?(executable) + executable = Tempfile.new("unittest_#{base}.bin") + executable.close arg_sets = [] - arg_sets << ["-std=c++0x", "-o", executable.to_s, "-DARDUINO=100"] + arg_sets << ["-std=c++0x", "-o", executable.path, "-DARDUINO=100"] if libasan?(gcc_binary) arg_sets << [ # Stuff to help with dynamic memory mishandling "-g", "-O1", @@ -514,17 +510,20 @@ def build_for_test_with_configuration(test_file, aux_libraries, gcc_binary, ci_g arg_sets << cpp_files_libraries(full_dependencies).map(&:to_s) arg_sets << [test_file.to_s] args = arg_sets.flatten(1) - return nil unless run_gcc(gcc_binary, *args) + unless run_gcc(gcc_binary, *args) + executable.unlink + return nil + end - artifacts << executable executable end # print any found stack dumps - # @param executable [Pathname] the path to the test file + # @param executable [Tempfile] the path to the test file def print_stack_dump(executable) + path = Pathname.new(executable.path) possible_dumpfiles = [ - executable.sub_ext("#{executable.extname}.stackdump") + path.sub_ext("#{path.extname}.stackdump") ] possible_dumpfiles.select(&:exist?).each do |dump| puts "========== Stack dump from #{dump}:" diff --git a/spec/cpp_library_spec.rb b/spec/cpp_library_spec.rb index 825c3650..c531cfd0 100644 --- a/spec/cpp_library_spec.rb +++ b/spec/cpp_library_spec.rb @@ -307,7 +307,7 @@ def verified_install(backend, path) it "tests #{File.basename(path)} with #{compiler} expecting #{expected}" do exe = @cpp_library.build_for_test_with_configuration(path, [], compiler, config.gcc_config("uno")) expect(exe).not_to be nil - expect(@cpp_library.run_test_file(exe)).to eq(expected) + expect(@cpp_library.run_test_file(Pathname.new(exe.path))).to eq(expected) end end end diff --git a/spec/testsomething_unittests_spec.rb b/spec/testsomething_unittests_spec.rb index 1f7bce72..2dbdf540 100644 --- a/spec/testsomething_unittests_spec.rb +++ b/spec/testsomething_unittests_spec.rb @@ -90,7 +90,7 @@ it "#{tfn} builds successfully and passes tests" do expect(@exe).not_to be nil - expect(@cpp_library.run_test_file(@exe)).to_not be_falsey + expect(@cpp_library.run_test_file(Pathname.new(@exe.path))).to_not be_falsey end end end