arduino_ci 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/cpp/unittest/ArduinoUnitTests.h +16 -4
- data/cpp/unittest/Assertion.h +32 -13
- data/exe/arduino_ci_remote.rb +24 -22
- data/lib/arduino_ci/arduino_cmd.rb +0 -4
- data/lib/arduino_ci/cpp_library.rb +24 -3
- data/lib/arduino_ci/version.rb +1 -1
- data/misc/default.yaml +6 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a38212612227d3adec2b30ed2303de39f506f12a31c06b2205ee1e703dccfbb6
|
4
|
+
data.tar.gz: '033169c0b7531d90c089296cf3cd5b708995bb2e89db068813fa515ab0022b17'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7def94f0fe1d00fc32ccac118766da3cc8272f69b19123eaca24b78592e171b99687cead667c7506acb4e62f7b0445f141ed6ca716053b9d78061d66b5fafd19
|
7
|
+
data.tar.gz: af306adce91faa99e433a8006de72aa0a04a0d5f06e47187672f7d6db07254e6850c374684753e45708ce3e53cee7dd51dfffa17e63c4f58d15a20ee1e72513c
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[](https://rubygems.org/gems/arduino_ci)
|
2
2
|
[](https://travis-ci.org/ifreecarve/arduino_ci)
|
3
|
-
[](http://www.rubydoc.info/gems/arduino_ci/0.1.
|
3
|
+
[](http://www.rubydoc.info/gems/arduino_ci/0.1.3)
|
4
4
|
|
5
5
|
# ArduinoCI Ruby gem (`arduino_ci`)
|
6
6
|
|
@@ -43,12 +43,10 @@ unittest(your_test_name)
|
|
43
43
|
assertEqual(4, doSomething());
|
44
44
|
}
|
45
45
|
|
46
|
-
|
47
|
-
return Test::run_and_report(argc, argv);
|
48
|
-
}
|
46
|
+
unittest_main()
|
49
47
|
```
|
50
48
|
|
51
|
-
This test defines one `unittest` (a macro provided by `ArduionUnitTests.h`), called `your_test_name`, which makes some assertions on the target library. The `int main`
|
49
|
+
This test defines one `unittest` (a macro provided by `ArduionUnitTests.h`), called `your_test_name`, which makes some assertions on the target library. The `unittest_main()` is a macro for the `int main()` boilerplate required for unit testing.
|
52
50
|
|
53
51
|
|
54
52
|
## More Documentation
|
@@ -130,14 +130,16 @@ class Test
|
|
130
130
|
Results results = {0, 0, 0};
|
131
131
|
|
132
132
|
for (Test *p = sRoot; p; p = p->mNext) {
|
133
|
-
|
133
|
+
p->prepare();
|
134
134
|
p->mReporter = reporter;
|
135
|
-
|
135
|
+
TestData t1 = {p->name(), p->result()};
|
136
|
+
if (reporter) reporter->onTestStart(t1);
|
136
137
|
p->test();
|
137
138
|
if (p->mResult == RESULT_PASS) ++results.passed;
|
138
139
|
if (p->mResult == RESULT_FAIL) ++results.failed;
|
139
140
|
if (p->mResult == RESULT_SKIP) ++results.skipped;
|
140
|
-
|
141
|
+
TestData t2 = {p->name(), p->result()};
|
142
|
+
if (reporter) reporter->onTestEnd(t2);
|
141
143
|
}
|
142
144
|
|
143
145
|
return results;
|
@@ -154,8 +156,12 @@ class Test
|
|
154
156
|
return results.failed + results.skipped;
|
155
157
|
}
|
156
158
|
|
159
|
+
void prepare() {
|
160
|
+
mResult = RESULT_PASS; // not None, and not fail unless we hear otherwise
|
161
|
+
}
|
162
|
+
|
157
163
|
void test() {
|
158
|
-
|
164
|
+
// thin wrapper. nothing to do here for now
|
159
165
|
task();
|
160
166
|
}
|
161
167
|
|
@@ -210,3 +216,9 @@ class Test
|
|
210
216
|
void task(); \
|
211
217
|
} test_##name##_instance; \
|
212
218
|
void test_##name ::task()
|
219
|
+
|
220
|
+
|
221
|
+
#define unittest_main() \
|
222
|
+
int main(int argc, char *argv[]) { \
|
223
|
+
return Test::run_and_report(argc, argv); \
|
224
|
+
}
|
data/cpp/unittest/Assertion.h
CHANGED
@@ -1,21 +1,30 @@
|
|
1
1
|
#pragma once
|
2
2
|
#include "Compare.h"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
} \
|
4
|
+
#define testBehaviorOp(die, desc, rel1, arg1, op, op_name, rel2, arg2) \
|
5
|
+
do \
|
6
|
+
{ \
|
7
|
+
if (!assertion<typeof(arg1), typeof(arg2)>(__FILE__, __LINE__, \
|
8
|
+
desc, \
|
9
|
+
rel1, #arg1, (arg1), \
|
10
|
+
op_name, op, \
|
11
|
+
rel2, #arg2, (arg2))) \
|
12
|
+
{ \
|
13
|
+
if (die) return; \
|
14
|
+
} \
|
16
15
|
} while (0)
|
17
16
|
|
18
|
-
|
17
|
+
|
18
|
+
|
19
|
+
// helper define for the operators below
|
20
|
+
#define assertOp(desc, rel1, arg1, op, op_name, rel2, arg2) \
|
21
|
+
testBehaviorOp(false, desc, rel1, arg1, op, op_name, rel2, arg2)
|
22
|
+
|
23
|
+
#define assureOp(desc, rel1, arg1, op, op_name, rel2, arg2) \
|
24
|
+
testBehaviorOp(true, desc, rel1, arg1, op, op_name, rel2, arg2)
|
25
|
+
|
26
|
+
|
27
|
+
/** macro generates optional output and calls fail() but does not return if false. */
|
19
28
|
#define assertEqual(arg1,arg2) assertOp("assertEqual","expected",arg1,compareEqual,"==","actual",arg2)
|
20
29
|
#define assertNotEqual(arg1,arg2) assertOp("assertNotEqual","unwanted",arg1,compareNotEqual,"!=","actual",arg2)
|
21
30
|
#define assertLess(arg1,arg2) assertOp("assertLess","lowerBound",arg1,compareLess,"<","upperBound",arg2)
|
@@ -25,3 +34,13 @@
|
|
25
34
|
#define assertTrue(arg) assertEqual(arg,true)
|
26
35
|
#define assertFalse(arg) assertEqual(arg,false)
|
27
36
|
|
37
|
+
/** macro generates optional output and calls fail() followed by a return if false. */
|
38
|
+
#define assureEqual(arg1,arg2) assureOp("assureEqual","expected",arg1,compareEqual,"==","actual",arg2)
|
39
|
+
#define assureNotEqual(arg1,arg2) assureOp("assureNotEqual","unwanted",arg1,compareNotEqual,"!=","actual",arg2)
|
40
|
+
#define assureLess(arg1,arg2) assureOp("assureLess","lowerBound",arg1,compareLess,"<","upperBound",arg2)
|
41
|
+
#define assureMore(arg1,arg2) assureOp("assureMore","upperBound",arg1,compareMore,">","lowerBound",arg2)
|
42
|
+
#define assureLessOrEqual(arg1,arg2) assureOp("assureLessOrEqual","lowerBound",arg1,compareLessOrEqual,"<=","upperBound",arg2)
|
43
|
+
#define assureMoreOrEqual(arg1,arg2) assureOp("assureMoreOrEqual","upperBound",arg1,compareMoreOrEqual,">=","lowerBound",arg2)
|
44
|
+
#define assureTrue(arg) assertEqual(arg,true)
|
45
|
+
#define assureFalse(arg) assertEqual(arg,false)
|
46
|
+
|
data/exe/arduino_ci_remote.rb
CHANGED
@@ -72,8 +72,10 @@ end
|
|
72
72
|
# do that, set the URLs, and download the packages
|
73
73
|
all_packages = all_platforms.values.map { |v| v[:package] }.uniq.reject(&:nil?)
|
74
74
|
all_urls = all_packages.map { |p| config.package_url(p) }.uniq.reject(&:nil?)
|
75
|
-
|
76
|
-
|
75
|
+
unless all_urls.empty?
|
76
|
+
assure("Setting board manager URLs") do
|
77
|
+
@arduino_cmd.set_pref("boardsmanager.additional.urls", all_urls.join(","))
|
78
|
+
end
|
77
79
|
end
|
78
80
|
|
79
81
|
all_packages.each do |p|
|
@@ -86,26 +88,6 @@ aux_libraries.each do |l|
|
|
86
88
|
assure("Installing aux library '#{l}'") { @arduino_cmd.install_library(l) }
|
87
89
|
end
|
88
90
|
|
89
|
-
attempt("Setting compiler warning level") { @arduino_cmd.set_pref("compiler.warning_level", "all") }
|
90
|
-
|
91
|
-
library_examples.each do |example_path|
|
92
|
-
ovr_config = config.from_example(example_path)
|
93
|
-
ovr_config.platforms_to_build.each do |p|
|
94
|
-
board = all_platforms[p][:board]
|
95
|
-
assure("Switching to board for #{p} (#{board})") { @arduino_cmd.use_board(board) }
|
96
|
-
example_name = File.basename(example_path)
|
97
|
-
attempt("Verifying #{example_name}") do
|
98
|
-
ret = @arduino_cmd.verify_sketch(example_path)
|
99
|
-
unless ret
|
100
|
-
puts
|
101
|
-
puts "Last command: #{@arduino_cmd.last_msg}"
|
102
|
-
puts @arduino_cmd.last_err
|
103
|
-
end
|
104
|
-
ret
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
91
|
config.platforms_to_unittest.each do |p|
|
110
92
|
board = all_platforms[p][:board]
|
111
93
|
assure("Switching to board for #{p} (#{board})") { @arduino_cmd.use_board(board) }
|
@@ -129,4 +111,24 @@ config.platforms_to_unittest.each do |p|
|
|
129
111
|
end
|
130
112
|
end
|
131
113
|
|
114
|
+
attempt("Setting compiler warning level") { @arduino_cmd.set_pref("compiler.warning_level", "all") }
|
115
|
+
|
116
|
+
library_examples.each do |example_path|
|
117
|
+
ovr_config = config.from_example(example_path)
|
118
|
+
ovr_config.platforms_to_build.each do |p|
|
119
|
+
board = all_platforms[p][:board]
|
120
|
+
assure("Switching to board for #{p} (#{board})") { @arduino_cmd.use_board(board) }
|
121
|
+
example_name = File.basename(example_path)
|
122
|
+
attempt("Verifying #{example_name}") do
|
123
|
+
ret = @arduino_cmd.verify_sketch(example_path)
|
124
|
+
unless ret
|
125
|
+
puts
|
126
|
+
puts "Last command: #{@arduino_cmd.last_msg}"
|
127
|
+
puts @arduino_cmd.last_err
|
128
|
+
end
|
129
|
+
ret
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
132
134
|
terminate(true)
|
@@ -35,12 +35,28 @@ module ArduinoCI
|
|
35
35
|
@last_msg = ""
|
36
36
|
end
|
37
37
|
|
38
|
+
# Guess whether a file is part of the vendor bundle (indicating we should ignore it).
|
39
|
+
#
|
40
|
+
# This assumes the vendor bundle will be at `vendor/bundle` and not some other location
|
41
|
+
# @param path [String] The path to check
|
42
|
+
# @return [Array<String>] The paths of the found files
|
43
|
+
def vendor_bundle?(path)
|
44
|
+
# TODO: look for Gemfile, look for .bundle/config and get BUNDLE_PATH from there?
|
45
|
+
base = File.join(@base_dir, "vendor")
|
46
|
+
real = File.join(File.realpath(@base_dir), "vendor")
|
47
|
+
return true if path.start_with?(base)
|
48
|
+
return true if path.start_with?(real)
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
38
52
|
# Get a list of all CPP source files in a directory and its subdirectories
|
39
53
|
# @param some_dir [String] The directory in which to begin the search
|
40
54
|
# @return [Array<String>] The paths of the found files
|
41
55
|
def cpp_files_in(some_dir)
|
42
56
|
real = File.realpath(some_dir)
|
43
|
-
Find.find(real).
|
57
|
+
files = Find.find(real).reject { |path| File.directory?(path) }
|
58
|
+
ret = files.select { |path| CPP_EXTENSIONS.include?(File.extname(path)) }
|
59
|
+
ret
|
44
60
|
end
|
45
61
|
|
46
62
|
# CPP files that are part of the project library under test
|
@@ -50,6 +66,7 @@ module ArduinoCI
|
|
50
66
|
cpp_files_in(@base_dir).reject do |p|
|
51
67
|
next true if File.dirname(p).include?(tests_dir)
|
52
68
|
next true if File.dirname(p).include?(real_tests_dir)
|
69
|
+
next true if vendor_bundle?(p)
|
53
70
|
end
|
54
71
|
end
|
55
72
|
|
@@ -80,8 +97,12 @@ module ArduinoCI
|
|
80
97
|
# Find all directories in the project library that include C++ header files
|
81
98
|
# @return [Array<String>]
|
82
99
|
def header_dirs
|
83
|
-
|
84
|
-
|
100
|
+
real = File.realpath(@base_dir)
|
101
|
+
all_files = Find.find(real).reject { |path| File.directory?(path) }
|
102
|
+
unbundled = all_files.reject { |path| vendor_bundle?(path) }
|
103
|
+
files = unbundled.select { |path| HPP_EXTENSIONS.include?(File.extname(path)) }
|
104
|
+
ret = files.map { |path| File.dirname(path) }.uniq
|
105
|
+
ret
|
85
106
|
end
|
86
107
|
|
87
108
|
# wrapper for the GCC command
|
data/lib/arduino_ci/version.rb
CHANGED
data/misc/default.yaml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# Note that ci_config_spec.rb has tests for this file's contents
|
2
|
+
|
1
3
|
packages:
|
2
4
|
esp8266:esp8266:
|
3
5
|
url: http://arduino.esp8266.com/stable/package_esp8266com_index.json
|
@@ -22,7 +24,7 @@ platforms:
|
|
22
24
|
warnings:
|
23
25
|
flags:
|
24
26
|
zero:
|
25
|
-
board: arduino:samd:
|
27
|
+
board: arduino:samd:arduino_zero_native
|
26
28
|
package: arduino:samd
|
27
29
|
gcc:
|
28
30
|
features:
|
@@ -30,7 +32,7 @@ platforms:
|
|
30
32
|
warnings:
|
31
33
|
flags:
|
32
34
|
esp8266:
|
33
|
-
board: esp8266:esp8266:huzzah
|
35
|
+
board: esp8266:esp8266:huzzah:FlashSize=4M3M,CpuFrequency=80
|
34
36
|
package: esp8266:esp8266
|
35
37
|
gcc:
|
36
38
|
features:
|
@@ -67,6 +69,7 @@ compile:
|
|
67
69
|
platforms:
|
68
70
|
- uno
|
69
71
|
- due
|
72
|
+
- zero
|
70
73
|
- leonardo
|
71
74
|
|
72
75
|
unittest:
|
@@ -74,4 +77,5 @@ unittest:
|
|
74
77
|
platforms:
|
75
78
|
- uno
|
76
79
|
- due
|
80
|
+
- zero
|
77
81
|
- leonardo
|