Skip to content

Commit 81b62b5

Browse files
author
James Foster
authored
Merge branch 'master' into yield
2 parents e52667e + 0e69d9a commit 81b62b5

File tree

13 files changed

+103
-11
lines changed

13 files changed

+103
-11
lines changed

.gitattributes

+39-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,40 @@
1+
# https://docs.github.com/en/github/using-git/configuring-git-to-handle-line-endings
2+
# https://git-scm.com/docs/gitattributes
3+
# https://git-scm.com/docs/git-config
4+
# https://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/
5+
6+
# Configure this repository to use Git's type detection algorithm to guess
7+
# whether a file is text or binary. Text files will have line endings converted
8+
# as if you had set
9+
# eol=native
10+
# That is, on Windows text files will have CRLF line endings in your working
11+
# directory while on Linux and macOS your text files will have LF line endings
12+
# in your working directory. In either case, they will have LF line endings in
13+
# the Git repository itself.
14+
115
# Set the default behavior, in case people don't have core.autocrlf set.
2-
* text eol=lf
16+
* text=auto
17+
18+
# Explicitly declare text files you want to always be normalized and converted
19+
# to native line endings on checkout. Git would likely get these right, but
20+
# we can be sure by adding them here.
21+
*.ino text diff=cpp
22+
*.c text diff=c
23+
*.cc text diff=cpp
24+
*.cxx text diff=cpp
25+
*.cpp text diff=cpp
26+
*.c++ text diff=cpp
27+
*.hpp text diff=cpp
28+
*.h text diff=c
29+
*.h++ text diff=cpp
30+
*.hh text diff=cpp
31+
32+
*.md text
33+
*.yaml text
34+
*.yml text
35+
36+
37+
# Denote all files that are truly binary and should not be modified.
38+
# Even if we don't have any of these, they make a good example.
39+
*.png binary
40+
*.jpg binary

.github/workflows/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ In this project, we define a workflow for each target platform. **If you're loo
77

88
The reason that all platforms are tested in _this_ project is to ensure that, as a framework, `arduino_ci` will run properly on any developer's personal workstation (regardless of OS).
99

10-
For testing an individual Arduino library in the context of GitHub, [Linux is the cheapest option](https://docs.github.com/en/free-pro-team@latest/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-github-actions) and produces results identical to the other OSes.
10+
For testing an individual Arduino library in the context of GitHub, [Linux is the cheapest option](https://docs.github.com/en/free-pro-team@latest/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-github-actions) and should produce results identical to the other OSes.

.github/workflows/linux.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This is the name of the workflow, visible on GitHub UI
22
name: linux
33

4-
on: [pull_request]
4+
on: [push, pull_request]
55

66
jobs:
77
"unittest_lint_sampleproject":

.github/workflows/macos.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This is the name of the workflow, visible on GitHub UI
22
name: macos
33

4-
on: [pull_request]
4+
on: [push, pull_request]
55

66
jobs:
77
"unittest_lint_sampleproject":

.github/workflows/windows.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This is the name of the workflow, visible on GitHub UI
22
name: windows
33

4-
on: [pull_request]
4+
on: [push, pull_request]
55

66
jobs:
77
"unittest_lint_sampleproject":

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99
### Added
10+
- Show output from successful compile
11+
- `--min-free-space=N` command-line argument to fail if free space is below requred value
1012

1113
### Changed
14+
- Fix copy/paste error to allow additional warnings for a platform
15+
- Properly report compile errors in GitHub Actions (#296)
16+
- Put build artifacts in a separate directory to reduce clutter.
1217
- Change 266 files from CRLF to LF.
1318
- Replace `#define yield() _NOP()` with `inline void yield() { _NOP(); }` so that other code can define a `yield()` function.
19+
- Update .gitattributes so we have consistent line endings
20+
- Run tests on push as well as on a pull request so developers can see impact
1421

1522
### Deprecated
1623

@@ -28,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2835

2936
### Changed
3037
- Topmost installtion instructions now suggest `gem install arduino_ci` instead of using a `Gemfile`. Reasons for using a `Gemfile` are listed and discussed separately further down the README.
38+
- Stream::readStreamUntil() no longer returns delimiter
3139

3240
### Removed
3341
- scanning of `library.properties`; this can and should now be performed by the standalone [`arduino-lint` tool](https://arduino.github.io/arduino-lint).

SampleProjects/TestSomething/.arduino-ci.yml

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
platforms:
2+
uno:
3+
board: arduino:avr:uno
4+
package: arduino:avr
5+
gcc:
6+
features:
7+
defines:
8+
- __AVR__
9+
- __AVR_ATmega328P__
10+
- ARDUINO_ARCH_AVR
11+
- ARDUINO_AVR_UNO
12+
warnings:
13+
- no-unknown-attributes
14+
flags:
15+
116
unittest:
217
platforms:
318
- uno

SampleProjects/TestSomething/test/stream.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,16 @@ unittest(stream_parse)
6969

7070
}
7171

72+
unittest(readStringUntil) {
73+
String data = "";
74+
unsigned long micros = 100;
75+
data = "abc:def";
76+
77+
Stream s;
78+
s.mGodmodeDataIn = &data;
79+
s.mGodmodeMicrosDelay = &micros;
80+
// result should not include delimiter
81+
assertEqual("abc", s.readStringUntil(':'));
82+
assertEqual("def", s.readStringUntil(':'));
83+
}
7284
unittest_main()

cpp/arduino/Stream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Stream : public Print
186186
ret = String(*mGodmodeDataIn);
187187
mGodmodeDataIn->clear();
188188
} else {
189-
ret = mGodmodeDataIn->substring(0, idxTrm + 1);
189+
ret = mGodmodeDataIn->substring(0, idxTrm);
190190
fastforward(idxTrm + 1);
191191
}
192192
return ret;

exe/arduino_ci.rb

+17-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def self.parse(options)
2424
ci_config: {
2525
"unittest" => unit_config
2626
},
27+
min_free_space: 0,
2728
}
2829

2930
opt_parser = OptionParser.new do |opts|
@@ -49,6 +50,10 @@ def self.parse(options)
4950
unit_config["testfiles"]["reject"] << p
5051
end
5152

53+
opts.on("--min-free-space=VALUE", "Minimum free SRAM memory for stack/heap") do |p|
54+
output_options[:min_free_space] = p.to_i
55+
end
56+
5257
opts.on("-h", "--help", "Prints this help") do
5358
puts opts
5459
puts
@@ -478,8 +483,18 @@ def perform_example_compilation_tests(cpp_library, config)
478483
board = ovr_config.platform_info[p][:board]
479484
attempt("Compiling #{example_name} for #{board}") do
480485
ret = @backend.compile_sketch(example_path, board)
481-
unless ret
482-
puts
486+
puts
487+
if ret
488+
output = @backend.last_msg
489+
puts output
490+
i = output.index("leaving")
491+
free_space = output[i + 8..-1].to_i
492+
min_free_space = @cli_options[:min_free_space]
493+
if free_space < min_free_space
494+
puts "Free space of #{free_space} is less than minimum of #{min_free_space}"
495+
ret = false
496+
end
497+
else
483498
puts "Last command: #{@backend.last_msg}"
484499
puts @backend.last_err
485500
end

lib/arduino_ci/arduino_backend.rb

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def compile_sketch(path, boardname)
164164
return false
165165
end
166166
ret = run_and_capture("compile", "--fqbn", boardname, "--warnings", "all", "--dry-run", path.to_s)
167+
@last_msg = ret[:out]
167168
ret[:success]
168169
end
169170

lib/arduino_ci/cpp_library.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def feature_args(ci_gcc_config)
443443
def warning_args(ci_gcc_config)
444444
return [] if ci_gcc_config[:warnings].nil?
445445

446-
ci_gcc_config[:features].map { |w| "-W#{w}" }
446+
ci_gcc_config[:warnings].map { |w| "-W#{w}" }
447447
end
448448

449449
# GCC command line arguments for defines (e.g. -Dhave_something)
@@ -491,7 +491,10 @@ def test_args(aux_libraries, ci_gcc_config)
491491
# @return [Pathname] path to the compiled test executable
492492
def build_for_test_with_configuration(test_file, aux_libraries, gcc_binary, ci_gcc_config)
493493
base = test_file.basename
494-
executable = Pathname.new("unittest_#{base}.bin").expand_path
494+
# hide build artifacts
495+
build_dir = '.arduino_ci'
496+
Dir.mkdir build_dir unless File.exist?(build_dir)
497+
executable = Pathname.new("#{build_dir}/unittest_#{base}.bin").expand_path
495498
File.delete(executable) if File.exist?(executable)
496499
arg_sets = []
497500
arg_sets << ["-std=c++0x", "-o", executable.to_s, "-DARDUINO=100"]

spec/testsomething_unittests_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
context "file #{tfn} (using #{compiler})" do
7373
around(:example) { |example| fld.in_pristine_fake_libraries_dir(example) }
7474

75-
before(:all) do
75+
before(:each) do
7676
@cpp_library = backend.install_local_library(cpp_lib_path)
7777
@exe = @cpp_library.build_for_test_with_configuration(path, [], compiler, config.gcc_config("uno"))
7878
end

0 commit comments

Comments
 (0)