Skip to content

Commit 8160f2a

Browse files
author
James Foster
authored
Merge branch 'cptr450' into digitalPinToPort
2 parents e9d37db + 736bf20 commit 8160f2a

File tree

14 files changed

+849
-425
lines changed

14 files changed

+849
-425
lines changed

.github/workflows/Arduino-CI.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This is the name of the workflow, visible on GitHub UI
2+
name: Arduino CI
3+
4+
# Run on a Push or a Pull Request
5+
on: [push, pull_request]
6+
7+
jobs:
8+
runTest:
9+
runs-on: ubuntu-latest
10+
steps:
11+
# Clone the repo using the `checkout` action
12+
- uses: actions/checkout@v2
13+
14+
# Get Ruby
15+
- uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: 2.6
18+
19+
# Install and run Arduino CI tests
20+
- name: Build and Execute
21+
run: |
22+
g++ -v
23+
bundle install
24+
bundle exec rubocop --version
25+
bundle exec rubocop -D .
26+
bundle exec rspec --backtrace
27+
cd SampleProjects/TestSomething
28+
bundle install
29+
bundle exec arduino_ci_remote.rb

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ script:
2626
- bundle exec rspec --backtrace
2727
- cd SampleProjects/TestSomething
2828
- bundle install
29-
- bundle exec arduino_ci_remote.rb
29+
- bundle exec arduino_ci.rb

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
### Added
1010
- Add `__AVR__` to defines when compiling
1111
- Add support for `diditalPinToPort()`, `digitalPinToBitMask()`, and `portOutputRegister()`
12+
- Support for mock EEPROM (but only if board supports it)
1213

1314
### Changed
1415
- Move repository from https://github.com/ianfixes/arduino_ci to https://github.com/Arduino-CI/arduino_ci
16+
- Revise math macros to avoid name clashes
1517

1618
### Deprecated
19+
- Deprecated `arduino_ci_remote.rb` in favor of `arduino_ci.rb`
1720

1821
### Removed
1922

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ $ bundle install --path vendor/bundle # adds packages to local library
9494
With that installed, just the following shell command each time you want the tests to execute:
9595

9696
```
97-
$ bundle exec arduino_ci_remote.rb
97+
$ bundle exec arduino_ci.rb
9898
```
9999

100-
`arduino_ci_remote.rb` is the main entry point for this library. This command will iterate over all the library's `examples/` and attempt to compile them. If you set up unit tests, it will run those as well.
100+
`arduino_ci.rb` is the main entry point for this library. This command will iterate over all the library's `examples/` and attempt to compile them. If you set up unit tests, it will run those as well.
101101

102102

103103
### Reference
104104

105-
For more information on the usage of `arduino_ci_remote.rb`, see [REFERENCE.md](REFERENCE.md). It contains information such as:
105+
For more information on the usage of `arduino_ci.rb`, see [REFERENCE.md](REFERENCE.md). It contains information such as:
106106

107107
* How to configure build options (platforms to test, Arduino library dependencies to install) with an `.arduino-ci.yml` file
108108
* Where to put unit test files
@@ -121,7 +121,7 @@ The following prerequisites must be fulfilled:
121121

122122
### Testing with remote CI
123123

124-
> **Note:** `arduino_ci_remote.rb` expects to be run from the root directory of your Arduino project library.
124+
> **Note:** `arduino_ci.rb` expects to be run from the root directory of your Arduino project library.
125125
126126

127127
#### Travis CI
@@ -135,7 +135,7 @@ sudo: false
135135
language: ruby
136136
script:
137137
- bundle install
138-
- bundle exec arduino_ci_remote.rb
138+
- bundle exec arduino_ci.rb
139139
```
140140
141141
@@ -149,7 +149,7 @@ Next, you'll need this in `appveyor.yml` in your repo.
149149
build: off
150150
test_script:
151151
- bundle install
152-
- bundle exec arduino_ci_remote.rb
152+
- bundle exec arduino_ci.rb
153153
```
154154

155155
## Known Problems

REFERENCE.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Build / Test Behavior of Arduino CI
22

3-
All tests are run via the same command: `bundle exec arduino_ci_remote.rb`.
3+
All tests are run via the same command: `bundle exec arduino_ci.rb`.
44

55
This script is responsible for detecting and runing all unit tests, on every combination of Arduino platform and C++ compiler. This is followed by attempting to detect and build every example on every "default" Arduino platform.
66

@@ -11,7 +11,7 @@ These defaults are specified in [misc/default.yml](misc/default.yml). You are f
1111

1212
## Directly Overriding Build Behavior (short term use)
1313

14-
When testing locally, it's often advantageous to limit the number of tests that are performed to only those tests that relate to the work you're doing; you'll get a faster turnaround time in seeing the results. For a full listing, see `bundle exec arduino_ci_remote.rb --help`.
14+
When testing locally, it's often advantageous to limit the number of tests that are performed to only those tests that relate to the work you're doing; you'll get a faster turnaround time in seeing the results. For a full listing, see `bundle exec arduino_ci.rb --help`.
1515

1616

1717
### `--skip-unittests` option
@@ -233,14 +233,14 @@ For most build environments, the only script that need be executed by the CI sys
233233
```shell
234234
# simplest build script
235235
bundle install
236-
bundle exec arduino_ci_remote.rb
236+
bundle exec arduino_ci.rb
237237
```
238238

239239
However, more flexible usage is available:
240240

241241
### Custom Versions of external Arduino Libraries
242242

243-
Sometimes you need a fork of an Arduino library instead of the version that will be installed via their GUI. `arduino_ci_remote.rb` won't overwrite existing downloaded libraries with fresh downloads, but it won't fetch the custom versions for you either.
243+
Sometimes you need a fork of an Arduino library instead of the version that will be installed via their GUI. `arduino_ci.rb` won't overwrite existing downloaded libraries with fresh downloads, but it won't fetch the custom versions for you either.
244244

245245
If this is the behavior you need, `ensure_arduino_installation.rb` is for you. It ensures that an Arduino binary is available on the system.
246246

@@ -261,7 +261,7 @@ git clone https://repository.com/custom_library_repo.git
261261
mv custom_library_repo $(bundle exec arduino_library_location.rb)
262262
263263
# now run CI
264-
bundle exec arduino_ci_remote.rb
264+
bundle exec arduino_ci.rb
265265
```
266266

267267
Note the use of subshell to execute `bundle exec arduino_library_location.rb`. This command simply returns the directory in which Arduino Libraries are (or should be) installed.
@@ -581,3 +581,40 @@ unittest(spi) {
581581
assertEqual("LMNOe", String(inBuf));
582582
}
583583
```
584+
585+
### EEPROM
586+
587+
`EEPROM` is a global with a simple API to read and write bytes to persistent memory (like a tiny hard disk) given an `int` location. Since the Arduino core already provides this as a global, and the core API is sufficient for basic testing (read/write), there is no direct tie to the `GODMODE` API. (If you need more, such as a log of intermediate values, enter a feature request.)
588+
589+
```C++
590+
unittest(eeprom)
591+
{
592+
uint8_t a;
593+
// size
594+
assertEqual(EEPROM_SIZE, EEPROM.length());
595+
// initial values
596+
a = EEPROM.read(0);
597+
assertEqual(255, a);
598+
// write and read
599+
EEPROM.write(0, 24);
600+
a = EEPROM.read(0);
601+
assertEqual(24, a);
602+
// update
603+
EEPROM.write(1, 14);
604+
EEPROM.update(1, 22);
605+
a = EEPROM.read(1);
606+
assertEqual(22, a);
607+
// put and get
608+
const float f1 = 0.025f;
609+
float f2 = 0.0f;
610+
EEPROM.put(5, f1);
611+
assertEqual(0.0f, f2);
612+
EEPROM.get(5, f2);
613+
assertEqual(0.025f, f2);
614+
// array access
615+
int val = 10;
616+
EEPROM[2] = val;
617+
a = EEPROM[2];
618+
assertEqual(10, a);
619+
}
620+
```

SampleProjects/DoSomething/.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ sudo: false
22
language: ruby
33
script:
44
- bundle install
5-
- bundle exec arduino_ci_remote.rb
5+
- bundle exec arduino_ci.rb

SampleProjects/DoSomething/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ At a minimum, you will need the following lines in your file:
3434
language: ruby
3535
script:
3636
- bundle install
37-
- bundle exec arduino_ci_remote.rb
37+
- bundle exec arduino_ci.rb
3838
```
3939
4040
This will install the necessary ruby gem, and run it. There are no command line arguments as of this writing, because all configuration is provided by...
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include <ArduinoUnitTests.h>
2+
#include <Arduino.h>
3+
4+
// Only run EEPROM tests if there is hardware support!
5+
#if defined(EEPROM_SIZE) || (defined(E2END) && E2END)
6+
#include <EEPROM.h>
7+
8+
GodmodeState* state = GODMODE();
9+
unittest_setup()
10+
{
11+
state->reset();
12+
}
13+
14+
unittest(length)
15+
{
16+
assertEqual(EEPROM_SIZE, EEPROM.length());
17+
}
18+
19+
unittest(firstRead)
20+
{
21+
uint8_t a = EEPROM.read(0);
22+
assertEqual(255, a);
23+
}
24+
25+
unittest(writeRead)
26+
{
27+
EEPROM.write(0, 24);
28+
uint8_t a = EEPROM.read(0);
29+
assertEqual(24, a);
30+
31+
EEPROM.write(0, 128);
32+
a = EEPROM.read(0);
33+
assertEqual(128, a);
34+
35+
EEPROM.write(0, 256);
36+
a = EEPROM.read(0);
37+
assertEqual(0, a);
38+
39+
int addr = EEPROM_SIZE / 2;
40+
EEPROM.write(addr, 63);
41+
a = EEPROM.read(addr);
42+
assertEqual(63, a);
43+
44+
addr = EEPROM_SIZE - 1;
45+
EEPROM.write(addr, 188);
46+
a = EEPROM.read(addr);
47+
assertEqual(188, a);
48+
}
49+
50+
unittest(updateWrite)
51+
{
52+
EEPROM.write(1, 14);
53+
EEPROM.update(1, 22);
54+
uint8_t a = EEPROM.read(1);
55+
assertEqual(22, a);
56+
}
57+
58+
unittest(putGet)
59+
{
60+
const float f1 = 0.025f;
61+
float f2 = 0.0f;
62+
EEPROM.put(5, f1);
63+
assertEqual(0.0f, f2);
64+
EEPROM.get(5, f2);
65+
assertEqual(0.025f, f2);
66+
}
67+
68+
unittest(array)
69+
{
70+
int val = 10;
71+
EEPROM[2] = val;
72+
uint8_t a = EEPROM[2];
73+
assertEqual(10, a);
74+
}
75+
76+
#endif
77+
78+
unittest_main()

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ test_script:
2424
- bundle exec rspec --backtrace
2525
- cd SampleProjects\TestSomething
2626
- bundle install
27-
- bundle exec arduino_ci_remote.rb
27+
- bundle exec arduino_ci.rb

0 commit comments

Comments
 (0)