Skip to content

Commit 33a136d

Browse files
authored
Report compile errors in shared library (#327)
Properly report compile error in shared library (fix #325).
1 parent 2a68c83 commit 33a136d

File tree

14 files changed

+100
-19
lines changed

14 files changed

+100
-19
lines changed

.github/workflows/linux.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ jobs:
6161
bundle exec ensure_arduino_installation.rb
6262
sh ./scripts/install.sh
6363
bundle exec arduino_ci.rb
64+
65+
SharedLibrary:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v2
69+
- uses: ruby/setup-ruby@v1
70+
with:
71+
ruby-version: 2.6
72+
- name: Test SharedLibrary should fail
73+
run: ./SampleProjects/SharedLibrary/test.sh

.github/workflows/macos.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ jobs:
6161
bundle exec ensure_arduino_installation.rb
6262
sh ./scripts/install.sh
6363
bundle exec arduino_ci.rb
64+
65+
SharedLibrary:
66+
runs-on: macos-latest
67+
steps:
68+
- uses: actions/checkout@v2
69+
- uses: ruby/setup-ruby@v1
70+
with:
71+
ruby-version: 2.6
72+
- name: Test SharedLibrary should fail
73+
run: ./SampleProjects/SharedLibrary/test.sh

.github/workflows/windows.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,13 @@ jobs:
5050
bundle exec ensure_arduino_installation.rb
5151
bash -x ./scripts/install.sh
5252
bundle exec arduino_ci.rb
53+
54+
SharedLibrary:
55+
runs-on: windows-latest
56+
steps:
57+
- uses: actions/checkout@v2
58+
- uses: ruby/setup-ruby@v1
59+
with:
60+
ruby-version: 2.6
61+
- name: Test SharedLibrary should fail
62+
run: ./SampleProjects/SharedLibrary/test.sh

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3232
- Fix copy/paste error to allow additional warnings for a platform
3333
- Apply "rule of three" to Client copy constructor and copy assignment operator
3434
- Run Windows tests on Windows not Ubuntu
35+
- Properly report error in building shared library
3536

3637
### Security
3738

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
unittest:
2+
platforms:
3+
- mega2560
4+
5+
compile:
6+
platforms:
7+
- mega2560
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.bundle

SampleProjects/SharedLibrary/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gem 'arduino_ci', path: '../../'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SharedLibrary
2+
3+
This is an example of a shared library with a compile error (see https://github.com/Arduino-CI/arduino_ci/issues/325).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=SharedLibrary
2+
version=0.1.0
3+
author=James Foster <arduino@jgfoster.net>
4+
maintainer=James Foster <arduino@jgfoster.net>
5+
sentence=Sample shared library to validate that we catch compile errors
6+
paragraph=Sample shared library to validate that we catch compile errors
7+
category=Other
8+
url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/SharedLibrary
9+
architectures=avr,esp8266
10+
includes=SharedLibrary.h
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "SharedLibrary.h"
2+
3+
int main() {
4+
return foo; // 'foo' was not declared in this scope
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
#include <Arduino.h>

SampleProjects/SharedLibrary/test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
g++ -v
2+
cd SampleProjects/SharedLibrary
3+
bundle install
4+
bundle exec ensure_arduino_installation.rb
5+
bundle exec arduino_ci.rb --skip-examples-compilation
6+
if [ $? -ne 1 ]; then
7+
exit 1
8+
fi
9+
exit 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
cd SampleProjects/SharedLibrary
3+
bundle config --local path vendor/bundle
4+
bundle install
5+
bundle exec arduino_ci.rb --skip-examples-compilation
6+
*/
7+
8+
#include <Arduino.h>
9+
#include <ArduinoUnitTests.h>
10+
11+
unittest(test) { assertEqual(true, true); }
12+
13+
unittest_main()

exe/arduino_ci.rb

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,22 @@ def perform_unit_tests(cpp_library, file_config)
423423
puts
424424
compilers.each do |gcc_binary|
425425
# before compiling the tests, build a shared library of everything except the test code
426-
next unless build_shared_library(gcc_binary, p, config, cpp_library)
426+
got_shared_library = true
427+
attempt_multiline("Build shared library with #{gcc_binary} for #{p}") do
428+
exe = cpp_library.build_shared_library(
429+
config.aux_libraries_for_unittest,
430+
gcc_binary,
431+
config.gcc_config(p)
432+
)
433+
unless exe
434+
puts "Last command: #{cpp_library.last_cmd}"
435+
puts cpp_library.last_out
436+
puts cpp_library.last_err
437+
got_shared_library = false
438+
end
439+
next got_shared_library
440+
end
441+
next unless got_shared_library
427442

428443
# now build and run each test using the shared library build above
429444
config.allowable_unittest_files(cpp_library.test_files).each do |unittest_path|
@@ -445,24 +460,6 @@ def perform_unit_tests(cpp_library, file_config)
445460
end
446461
end
447462

448-
def build_shared_library(gcc_binary, platform, config, cpp_library)
449-
attempt_multiline("Build shared library with #{gcc_binary} for #{platform}") do
450-
exe = cpp_library.build_shared_library(
451-
config.aux_libraries_for_unittest,
452-
gcc_binary,
453-
config.gcc_config(platform)
454-
)
455-
puts
456-
unless exe
457-
puts "Last command: #{cpp_library.last_cmd}"
458-
puts cpp_library.last_out
459-
puts cpp_library.last_err
460-
return false
461-
end
462-
return true
463-
end
464-
end
465-
466463
def perform_example_compilation_tests(cpp_library, config)
467464
phase("Compilation of example sketches")
468465
if @cli_options[:skip_compilation]

0 commit comments

Comments
 (0)