From 4d9409392a99a854047236902b775dda8f108caf Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Tue, 27 Mar 2018 21:21:07 -0400 Subject: [PATCH 1/8] ask for g++ version (not gcc) since that's what we use --- .github/issue_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 5ada51e8..7cd948bb 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -4,7 +4,7 @@ - `ruby -v`: - `bundle -v`: - `bundle info arduino_ci`: - - `gcc -v`: + - `g++ -v`: - Arduino IDE version: - URL of failing Travis CI job: - URL of your Arduino project: From 2092388fff270abedabcf07b15fa5629e2c5787e Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Tue, 27 Mar 2018 21:43:08 -0400 Subject: [PATCH 2/8] bump minimum version in example --- SampleProjects/DoSomething/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SampleProjects/DoSomething/Gemfile.lock b/SampleProjects/DoSomething/Gemfile.lock index 960bb950..01228d8d 100644 --- a/SampleProjects/DoSomething/Gemfile.lock +++ b/SampleProjects/DoSomething/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: /Users/ikatz/Development/non-wayfair/arduino_ci specs: - arduino_ci (0.0.1) + arduino_ci (0.1.7) os (~> 1.0) GEM From f68d450c8a3b2e74e2641e1106f1f8e6c34a7497 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Tue, 27 Mar 2018 21:45:30 -0400 Subject: [PATCH 3/8] fix OSX compilation / portability errors --- CHANGELOG.md | 1 + cpp/arduino/Print.h | 1 + cpp/arduino/WString.h | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b96eb3b..fc9909f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Removed ### Fixed +- Compile errors / portability issues in `WString.h` and `Print.h`, first reported by `dfrencham` on GitHub ### Security diff --git a/cpp/arduino/Print.h b/cpp/arduino/Print.h index d9ab6d09..438ca924 100644 --- a/cpp/arduino/Print.h +++ b/cpp/arduino/Print.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "WString.h" #define DEC 10 diff --git a/cpp/arduino/WString.h b/cpp/arduino/WString.h index e92cf919..39474564 100644 --- a/cpp/arduino/WString.h +++ b/cpp/arduino/WString.h @@ -9,6 +9,22 @@ typedef std::string string; +// work around some portability issues +#if defined(__clang__) + #define ARDUINOCI_ISNAN ::isnan + #define ARDUINOCI_ISINF ::isinf +#elif defined(__GNUC__) || defined(__GNUG__) + #define ARDUINOCI_ISNAN std::isnan + #define ARDUINOCI_ISINF std::isinf +#elif defined(_MSC_VER) + // TODO: no idea + #define ARDUINOCI_ISNAN ::isnan + #define ARDUINOCI_ISINF ::isinf +#else + #define ARDUINOCI_ISNAN ::isnan + #define ARDUINOCI_ISINF ::isinf +#endif + class __FlashStringHelper; #define F(string_literal) (reinterpret_cast(PSTR(string_literal))) @@ -36,8 +52,8 @@ class String: public string static string dtoas(double val, int decimalPlaces) { double r = 0.5 * pow(0.1, decimalPlaces); // make sure that integer truncation will properly round - if (std::isnan(val)) return "nan"; - if (std::isinf(val)) return "inf"; + if (ARDUINOCI_ISNAN(val)) return "nan"; + if (ARDUINOCI_ISINF(val)) return "inf"; val += val > 0 ? r : -r; if (val > 4294967040.0) return "ovf"; if (val <-4294967040.0) return "ovf"; From 771385417564e80ff45c458567ea1ff519f36508 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Tue, 27 Mar 2018 21:47:40 -0400 Subject: [PATCH 4/8] add LED_BUILTIN definition --- CHANGELOG.md | 1 + cpp/arduino/ArduinoDefines.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9909f4..5b24d8ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- Definition of `LED_BUILTIN`, first reported by `dfrencham` on GitHub ### Changed diff --git a/cpp/arduino/ArduinoDefines.h b/cpp/arduino/ArduinoDefines.h index d10e3de2..f34aca6d 100644 --- a/cpp/arduino/ArduinoDefines.h +++ b/cpp/arduino/ArduinoDefines.h @@ -89,3 +89,6 @@ #define TIMER5B 17 #define TIMER5C 18 +#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + #define LED_BUILTIN 13 +#endif From 02a5e5161a4f1bf4852fea652bb783ad09dca2a4 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Mon, 2 Apr 2018 10:20:57 -0400 Subject: [PATCH 5/8] add stubs for tone and noTone --- CHANGELOG.md | 1 + cpp/arduino/Godmode.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b24d8ac..399038cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added - Definition of `LED_BUILTIN`, first reported by `dfrencham` on GitHub +- Stubs for `tone` and `noTone`, first suggested by `dfrencham` on GitHub ### Changed diff --git a/cpp/arduino/Godmode.h b/cpp/arduino/Godmode.h index 37fb6007..2d0df7ed 100644 --- a/cpp/arduino/Godmode.h +++ b/cpp/arduino/Godmode.h @@ -91,6 +91,11 @@ void analogWrite(uint8_t, int); #define analogReadResolution(...) _NOP() #define analogWriteResolution(...) _NOP() +// TODO: issue #26 to track the commanded state here +inline void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0) {} +inline void tone(uint8_t _pin, unsigned int frequency) {} +inline void noTone(uint8_t _pin) {} + GodmodeState* GODMODE(); From d4bf6a7e44fe41eb6169bdf82a7a87064c6e639c Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Mon, 2 Apr 2018 10:30:15 -0400 Subject: [PATCH 6/8] Fix inheritance of overloaded Print / Write functions --- CHANGELOG.md | 1 + SampleProjects/TestSomething/test/serial.cpp | 15 +++++++++++++++ cpp/arduino/HardwareSerial.h | 7 ++----- cpp/arduino/Stream.h | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 399038cb..2abe3408 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Compile errors / portability issues in `WString.h` and `Print.h`, first reported by `dfrencham` on GitHub +- Compile errors / inheritance issues in `Print.h` and `Stream.h`, first reported by `dfrencham` on GitHub ### Security diff --git a/SampleProjects/TestSomething/test/serial.cpp b/SampleProjects/TestSomething/test/serial.cpp index c7ee2723..f3fff903 100644 --- a/SampleProjects/TestSomething/test/serial.cpp +++ b/SampleProjects/TestSomething/test/serial.cpp @@ -43,6 +43,21 @@ unittest(serial_ports) assertEqual("bcdefg", state->serialPort[0].dataOut); } + unittest(all_serial_writes) + { + GodmodeState* state = GODMODE(); + state->serialPort[0].dataIn = ""; + state->serialPort[0].dataOut = ""; + + char str[4] = "xyz"; + Serial.write(reinterpret_cast(str ), 3); + Serial.print((int)1); + Serial.print((long)2); + Serial.print((double)3.4); + Serial.print((char)'a'); + Serial.print("b"); + } + #endif unittest_main() diff --git a/cpp/arduino/HardwareSerial.h b/cpp/arduino/HardwareSerial.h index 758e304b..7de98d5a 100644 --- a/cpp/arduino/HardwareSerial.h +++ b/cpp/arduino/HardwareSerial.h @@ -57,11 +57,8 @@ class HardwareSerial : public Stream, public ObservableDataStream return 1; } - inline size_t write(unsigned long n) { return write((uint8_t)n); } - inline size_t write(long n) { return write((uint8_t)n); } - inline size_t write(unsigned int n) { return write((uint8_t)n); } - inline size_t write(int n) { return write((uint8_t)n); } - // using Print::write; // pull in write(str) and write(buf, size) from Print + // https://stackoverflow.com/a/4271276 + using Print::write; // pull in write(str) and write(buf, size) from Print operator bool() { return true; } }; diff --git a/cpp/arduino/Stream.h b/cpp/arduino/Stream.h index 3640f0e0..9f766cbf 100644 --- a/cpp/arduino/Stream.h +++ b/cpp/arduino/Stream.h @@ -56,11 +56,11 @@ class Stream : public Print return ret; } + // https://stackoverflow.com/a/4271276 using Print::write; virtual size_t write(uint8_t aChar) { mGodmodeDataIn->append(String((char)aChar)); return 1; } - Stream() { mTimeoutMillis = 1000; mGodmodeMicrosDelay = NULL; From bc846b1d92b84eba42347de6702e5840f9e92468 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Mon, 2 Apr 2018 10:31:29 -0400 Subject: [PATCH 7/8] Fix logic in print functions so that they actually print numbers --- CHANGELOG.md | 1 + SampleProjects/TestSomething/test/serial.cpp | 1 + cpp/arduino/Print.h | 48 ++++++++++---------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2abe3408..7f5988b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Compile errors / portability issues in `WString.h` and `Print.h`, first reported by `dfrencham` on GitHub - Compile errors / inheritance issues in `Print.h` and `Stream.h`, first reported by `dfrencham` on GitHub +- Print functions for int, double, long, etc ### Security diff --git a/SampleProjects/TestSomething/test/serial.cpp b/SampleProjects/TestSomething/test/serial.cpp index f3fff903..826964d4 100644 --- a/SampleProjects/TestSomething/test/serial.cpp +++ b/SampleProjects/TestSomething/test/serial.cpp @@ -56,6 +56,7 @@ unittest(serial_ports) Serial.print((double)3.4); Serial.print((char)'a'); Serial.print("b"); + assertEqual("xyz123.4000000000ab", state->serialPort[0].dataOut); } #endif diff --git a/cpp/arduino/Print.h b/cpp/arduino/Print.h index 438ca924..b7d8a522 100644 --- a/cpp/arduino/Print.h +++ b/cpp/arduino/Print.h @@ -33,38 +33,38 @@ class Print virtual size_t write(uint8_t) = 0; size_t write(const char *str) { return str == NULL ? 0 : write((const uint8_t *)str, String(str).length()); } - virtual size_t write(const uint8_t *buffer, size_t size) { size_t n; for (n = 0; size && write(*buffer++) && ++n; --size); return n; } + size_t write(const char *buffer, size_t size) { return write((const uint8_t *)buffer, size); } - size_t print(const String &s) { return write(s.c_str(), s.length()); } - size_t print(const __FlashStringHelper *str) { return print(reinterpret_cast(str)); } - size_t print(const char* str) { return print(String(str)); } - size_t print(char c) { return print(String(c)); } - size_t print(unsigned char b, int base) { return print(String(b, base)); } - size_t print(int n, int base) { return print(String(n, base)); } - size_t print(unsigned int n, int base) { return print(String(n, base)); } - size_t print(long n, int base) { return print(String(n, base)); } - size_t print(unsigned long n, int base) { return print(String(n, base)); } - size_t print(double n, int digits) { return print(String(n, digits)); } - size_t print(const Printable& x) { return x.printTo(*this); } + size_t print(const String &s) { return write(s.c_str(), s.length()); } + size_t print(const __FlashStringHelper *str) { return print(reinterpret_cast(str)); } + size_t print(const char* str) { return print(String(str)); } + size_t print(char c) { return print(String(c)); } + size_t print(unsigned char b, int base = DEC) { return print(String(b, base)); } + size_t print(int n, int base = DEC) { return print(String(n, base)); } + size_t print(unsigned int n, int base = DEC) { return print(String(n, base)); } + size_t print(long n, int base = DEC) { return print(String(n, base)); } + size_t print(unsigned long n, int base = DEC) { return print(String(n, base)); } + size_t print(double n, int base = DEC) { return print(String(n, base)); } + size_t print(const Printable& x) { return x.printTo(*this); } - size_t println(void) { return print("\r\n"); } - size_t println(const String &s) { return print(s) + println(); } - size_t println(const __FlashStringHelper *str) { return println(reinterpret_cast(str)); } - size_t println(const char* c) { return println(String(c)); } - size_t println(char c) { return println(String(c)); } - size_t println(unsigned char b, int base) { return println(String(b, base)); } - size_t println(int num, int base) { return println(String(num, base)); } - size_t println(unsigned int num, int base) { return println(String(num, base)); } - size_t println(long num, int base) { return println(String(num, base)); } - size_t println(unsigned long num, int base) { return println(String(num, base)); } - size_t println(double num, int digits) { return println(String(num, digits)); } - size_t println(const Printable& x) { return print(x) + println(); } + size_t println(void) { return print("\r\n"); } + size_t println(const String &s) { return print(s) + println(); } + size_t println(const __FlashStringHelper *str) { return println(reinterpret_cast(str)); } + size_t println(const char* c) { return println(String(c)); } + size_t println(char c) { return println(String(c)); } + size_t println(unsigned char b, int base = DEC) { return println(String(b, base)); } + size_t println(int num, int base = DEC) { return println(String(num, base)); } + size_t println(unsigned int num, int base = DEC) { return println(String(num, base)); } + size_t println(long num, int base = DEC) { return println(String(num, base)); } + size_t println(unsigned long num, int base = DEC) { return println(String(num, base)); } + size_t println(double num, int base = DEC) { return println(String(num, base)); } + size_t println(const Printable& x) { return print(x) + println(); } virtual void flush() { } From fd3da09a2ba00f1d39cd7819151990d7a8af3d50 Mon Sep 17 00:00:00 2001 From: Ian Katz Date: Mon, 2 Apr 2018 11:10:32 -0400 Subject: [PATCH 8/8] Add ability to use multiple compilers in a test --- CHANGELOG.md | 1 + README.md | 4 ++ SampleProjects/TestSomething/.arduino-ci.yml | 4 ++ exe/arduino_ci_remote.rb | 42 ++++++++++-------- lib/arduino_ci/ci_config.rb | 8 ++++ lib/arduino_ci/cpp_library.rb | 13 +++--- misc/default.yml | 2 + spec/ci_config_spec.rb | 5 +++ spec/cpp_library_spec.rb | 10 +++-- spec/testsomething_unittests_spec.rb | 46 ++++++++++++-------- spec/yaml/o1.yaml | 3 ++ 11 files changed, 90 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5988b3..e0b0c7bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Definition of `LED_BUILTIN`, first reported by `dfrencham` on GitHub - Stubs for `tone` and `noTone`, first suggested by `dfrencham` on GitHub +- Ability to specify multiple compilers for unit testing ### Changed diff --git a/README.md b/README.md index 1c22354a..5caf55c0 100644 --- a/README.md +++ b/README.md @@ -349,6 +349,10 @@ For your unit tests, in addition to setting specific libraries and platforms, yo ```yaml unittest: + compilers: + - g++ # default + - g++-4.9 + - g++-7 testfiles: select: - "*-*.*" diff --git a/SampleProjects/TestSomething/.arduino-ci.yml b/SampleProjects/TestSomething/.arduino-ci.yml index 83d8a8d8..352778d1 100644 --- a/SampleProjects/TestSomething/.arduino-ci.yml +++ b/SampleProjects/TestSomething/.arduino-ci.yml @@ -2,3 +2,7 @@ unittest: platforms: - uno - due + +unittest: + compilers: + - g++ diff --git a/exe/arduino_ci_remote.rb b/exe/arduino_ci_remote.rb index 19b39587..08d6cc59 100755 --- a/exe/arduino_ci_remote.rb +++ b/exe/arduino_ci_remote.rb @@ -69,11 +69,15 @@ def assure(message, &block) attempt("Library installed at #{installed_library_path}") { true } # check GCC -attempt_multiline("Checking GCC version") do - version = cpp_library.gcc_version - next nil unless version - puts version.split("\n").map { |l| " #{l}" }.join("\n") - version +compilers = config.compilers_to_use +assure("The set of compilers (#{compilers.length}) isn't empty") { !compilers.empty? } +compilers.each do |gcc_binary| + attempt_multiline("Checking #{gcc_binary} version") do + version = cpp_library.gcc_version(gcc_binary) + next nil unless version + puts version.split("\n").map { |l| " #{l}" }.join("\n") + version + end end # gather up all required boards so we can install them up front. @@ -121,20 +125,22 @@ def assure(message, &block) last_board = board cpp_library.test_files.each do |unittest_path| unittest_name = File.basename(unittest_path) - attempt_multiline("Unit testing #{unittest_name}") do - exe = cpp_library.build_for_test_with_configuration( - unittest_path, - config.aux_libraries_for_unittest, - config.gcc_config(p) - ) - puts - unless exe - puts "Last command: #{cpp_library.last_cmd}" - puts cpp_library.last_out - puts cpp_library.last_err - next false + compilers.each do |gcc_binary| + attempt_multiline("Unit testing #{unittest_name} with #{gcc_binary}") do + exe = cpp_library.build_for_test_with_configuration( + unittest_path, + config.aux_libraries_for_unittest, + config.gcc_config(p) + ) + puts + unless exe + puts "Last command: #{cpp_library.last_cmd}" + puts cpp_library.last_out + puts cpp_library.last_err + next false + end + cpp_library.run_test_file(exe) end - cpp_library.run_test_file(exe) end end end diff --git a/lib/arduino_ci/ci_config.rb b/lib/arduino_ci/ci_config.rb index 712db8a0..8af6c440 100644 --- a/lib/arduino_ci/ci_config.rb +++ b/lib/arduino_ci/ci_config.rb @@ -25,6 +25,7 @@ }.freeze UNITTEST_SCHEMA = { + compilers: Array, platforms: Array, libraries: Array, testfiles: { @@ -197,6 +198,13 @@ def package_url(package) @package_info[package][:url] end + # compilers to build (unit tests) with + # @return [Array] The compiler binary names (e.g. g++) to build with + def compilers_to_use + return [] if @unittest_info[:compilers].nil? + @unittest_info[:compilers] + end + # platforms to build [the examples on] # @return [Array] The platforms to build def platforms_to_build diff --git a/lib/arduino_ci/cpp_library.rb b/lib/arduino_ci/cpp_library.rb index f6904bf9..80654b34 100644 --- a/lib/arduino_ci/cpp_library.rb +++ b/lib/arduino_ci/cpp_library.rb @@ -107,10 +107,9 @@ def header_dirs end # wrapper for the GCC command - def run_gcc(*args, **kwargs) - full_args = ["g++"] + args + def run_gcc(gcc_binary, *args, **kwargs) + full_args = [gcc_binary] + args @last_cmd = " $ #{full_args.join(' ')}" - ret = Host.run_and_capture(*full_args, **kwargs) @last_err = ret[:err] @last_out = ret[:out] @@ -119,8 +118,8 @@ def run_gcc(*args, **kwargs) # Return the GCC version # @return [String] the version reported by `gcc -v` - def gcc_version - return nil unless run_gcc("-v") + def gcc_version(gcc_binary) + return nil unless run_gcc(gcc_binary, "-v") @last_err end @@ -183,7 +182,7 @@ def test_args(aux_libraries, ci_gcc_config) # @param aux_libraries [String] The external Arduino libraries required by this project # @param ci_gcc_config [Hash] The GCC config object # @return [String] path to the compiled test executable - def build_for_test_with_configuration(test_file, aux_libraries, ci_gcc_config) + def build_for_test_with_configuration(test_file, aux_libraries, gcc_binary, ci_gcc_config) base = File.basename(test_file) executable = File.expand_path("unittest_#{base}.bin") File.delete(executable) if File.exist?(executable) @@ -192,7 +191,7 @@ def build_for_test_with_configuration(test_file, aux_libraries, ci_gcc_config) test_args(aux_libraries, ci_gcc_config), [test_file], ].flatten(1) - return nil unless run_gcc(*args) + return nil unless run_gcc(gcc_binary, *args) artifacts << executable executable end diff --git a/misc/default.yml b/misc/default.yml index 90cfbc7f..4623a133 100644 --- a/misc/default.yml +++ b/misc/default.yml @@ -80,6 +80,8 @@ compile: - leonardo unittest: + compilers: + - g++ libraries: ~ platforms: - uno diff --git a/spec/ci_config_spec.rb b/spec/ci_config_spec.rb index 5d7b00d1..077dfc17 100644 --- a/spec/ci_config_spec.rb +++ b/spec/ci_config_spec.rb @@ -28,6 +28,8 @@ expect(default_config.platforms_to_unittest).to match(["uno", "due", "zero", "leonardo"]) expect(default_config.aux_libraries_for_build).to match([]) expect(default_config.aux_libraries_for_unittest).to match([]) + + expect(default_config.compilers_to_use).to match(["g++"]) end end @@ -63,6 +65,9 @@ expect(combined_config.platforms_to_unittest).to match(["bogo"]) expect(combined_config.aux_libraries_for_build).to match(["Adafruit FONA Library"]) expect(combined_config.aux_libraries_for_unittest).to match(["abc123", "def456"]) + + expect(combined_config.compilers_to_use).to match(["g++", "g++-7"]) + end end diff --git a/spec/cpp_library_spec.rb b/spec/cpp_library_spec.rb index c3ba1e43..8fdabe48 100644 --- a/spec/cpp_library_spec.rb +++ b/spec/cpp_library_spec.rb @@ -62,10 +62,12 @@ test_files = cpp_library.test_files test_files.each do |path| expected = path.include?("good") - it "tests #{File.basename(path)} expecting #{expected}" do - exe = cpp_library.build_for_test_with_configuration(path, [], config.gcc_config("uno")) - expect(exe).not_to be nil - expect(cpp_library.run_test_file(exe)).to eq(expected) + config.compilers_to_use.each do |compiler| + 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) + end end end end diff --git a/spec/testsomething_unittests_spec.rb b/spec/testsomething_unittests_spec.rb index 319f7060..69581777 100644 --- a/spec/testsomething_unittests_spec.rb +++ b/spec/testsomething_unittests_spec.rb @@ -26,32 +26,40 @@ expect(allowed_files.empty?).to be false end + it "has at least one compiler defined" do + expect(config.compilers_to_use.length.zero?).to be(false) + end + test_files = config.allowable_unittest_files(cpp_library.test_files) test_files.each do |path| tfn = File.basename(path) - context "file #{tfn}" do - before(:all) do - @exe = cpp_library.build_for_test_with_configuration(path, [], config.gcc_config("uno")) - end + config.compilers_to_use.each do |compiler| - # extra debug for c++ failures - after(:each) do |example| - if example.exception - puts "Last command: #{cpp_library.last_cmd}" - puts "========== Stdout:" - puts cpp_library.last_out - puts "========== Stderr:" - puts cpp_library.last_err + context "file #{tfn} (using #{compiler})" do + + before(:all) do + @exe = cpp_library.build_for_test_with_configuration(path, [], compiler, config.gcc_config("uno")) end - end - it "#{tfn} builds successfully" 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 + # extra debug for c++ failures + after(:each) do |example| + if example.exception + puts "Last command: #{cpp_library.last_cmd}" + puts "========== Stdout:" + puts cpp_library.last_out + puts "========== Stderr:" + puts cpp_library.last_err + end + end + + it "#{tfn} builds successfully" 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 end end diff --git a/spec/yaml/o1.yaml b/spec/yaml/o1.yaml index 0e4be54a..8f6c303d 100644 --- a/spec/yaml/o1.yaml +++ b/spec/yaml/o1.yaml @@ -32,6 +32,9 @@ compile: - esp8266 unittest: + compilers: + - g++ + - g++-7 testfiles: select: - "*-*.*"