-
Notifications
You must be signed in to change notification settings - Fork 34
Report compile errors in shared library #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e09a4d2
Run "TestSomething" on Windows as well as Ubuntu.
jgfoster f50b07b
Update CHANGELOG.md
jgfoster ad34cba
Properly report compile error in shared library.
jgfoster 2b01256
See if fixing code causes test to pass.
jgfoster 7dbd96c
Try fixes for errors
jgfoster 012f5bb
WIP: use `eval` and `next unless`
jgfoster 71a18b3
WIP: blank line; another attempt to capture status
jgfoster 18c43a5
WIP: another attempt at a status code
jgfoster d7b76a8
Move test script into separate file.
jgfoster da3be8f
path to test script
jgfoster 07a9d1d
See if we can force failure.
jgfoster c42d2f8
If there is no error reported, it should be an error!
jgfoster 80fda42
Will this report a failure?
jgfoster 43f8d05
This should do it!
jgfoster fb65bcd
Merge branch 'master' into shared_library
jgfoster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
unittest: | ||
platforms: | ||
- mega2560 | ||
|
||
compile: | ||
platforms: | ||
- mega2560 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.bundle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source 'https://rubygems.org' | ||
gem 'arduino_ci', path: '../../' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SharedLibrary | ||
|
||
This is an example of a shared library with a compile error (see https://github.com/Arduino-CI/arduino_ci/issues/325). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name=SharedLibrary | ||
version=0.1.0 | ||
author=James Foster <arduino@jgfoster.net> | ||
maintainer=James Foster <arduino@jgfoster.net> | ||
sentence=Sample shared library to validate that we catch compile errors | ||
paragraph=Sample shared library to validate that we catch compile errors | ||
category=Other | ||
url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/SharedLibrary | ||
architectures=avr,esp8266 | ||
includes=SharedLibrary.h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "SharedLibrary.h" | ||
|
||
int main() { | ||
return foo; // 'foo' was not declared in this scope | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
#include <Arduino.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
g++ -v | ||
cd SampleProjects/SharedLibrary | ||
bundle install | ||
bundle exec ensure_arduino_installation.rb | ||
bundle exec arduino_ci.rb --skip-examples-compilation | ||
if [ $? -ne 1 ]; then | ||
exit 1 | ||
fi | ||
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
cd SampleProjects/SharedLibrary | ||
bundle config --local path vendor/bundle | ||
bundle install | ||
bundle exec arduino_ci.rb --skip-examples-compilation | ||
*/ | ||
|
||
#include <Arduino.h> | ||
#include <ArduinoUnitTests.h> | ||
|
||
unittest(test) { assertEqual(true, true); } | ||
|
||
unittest_main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -423,7 +423,22 @@ def perform_unit_tests(cpp_library, file_config) | |
puts | ||
compilers.each do |gcc_binary| | ||
# before compiling the tests, build a shared library of everything except the test code | ||
next unless build_shared_library(gcc_binary, p, config, cpp_library) | ||
got_shared_library = true | ||
attempt_multiline("Build shared library with #{gcc_binary} for #{p}") do | ||
exe = cpp_library.build_shared_library( | ||
config.aux_libraries_for_unittest, | ||
gcc_binary, | ||
config.gcc_config(p) | ||
) | ||
unless exe | ||
puts "Last command: #{cpp_library.last_cmd}" | ||
puts cpp_library.last_out | ||
puts cpp_library.last_err | ||
got_shared_library = false | ||
end | ||
next got_shared_library | ||
end | ||
next unless got_shared_library | ||
|
||
# now build and run each test using the shared library build above | ||
config.allowable_unittest_files(cpp_library.test_files).each do |unittest_path| | ||
|
@@ -445,24 +460,6 @@ def perform_unit_tests(cpp_library, file_config) | |
end | ||
end | ||
|
||
def build_shared_library(gcc_binary, platform, config, cpp_library) | ||
attempt_multiline("Build shared library with #{gcc_binary} for #{platform}") do | ||
exe = cpp_library.build_shared_library( | ||
config.aux_libraries_for_unittest, | ||
gcc_binary, | ||
config.gcc_config(platform) | ||
) | ||
puts | ||
unless exe | ||
puts "Last command: #{cpp_library.last_cmd}" | ||
puts cpp_library.last_out | ||
puts cpp_library.last_err | ||
return false | ||
end | ||
return true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jgfoster I think the actual problem was this |
||
end | ||
end | ||
|
||
def perform_example_compilation_tests(cpp_library, config) | ||
phase("Compilation of example sketches") | ||
if @cli_options[:skip_compilation] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this change a bit? I'm not opposed to it, it just seems weird to move a small function into a big function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't understand it myself. But the symptom was that a failure in the compile shared library function (which called the
attempt_multiline()
method) did not get properly reported out when it failed. That is, we got a compile error in the shared library then went on to compile the examples and when the examples compiled okay the overall test reported as passed. It seemed to me that when theattempt_multiline()
method recognized a failure it reported it out one level but it didn't get out two levels. That is, by putting the call into a small, well-named method (which would otherwise be a good practice), it swallowed the error. But by moving it up a level the error got properly reported.Of course, this is all speculation and since I don't really understand what is going on I'm not real comfortable with the explanation. In an case, I added tests that confirmed the problem and verified the fix. But I really would welcome a better understanding of what changed and how this fixed it!