Skip to content

Commit 7289056

Browse files
committed
update READMEs
1 parent ae63752 commit 7289056

File tree

4 files changed

+119
-15
lines changed

4 files changed

+119
-15
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
88
### Added
9+
- Unit testing support
10+
- Documentation for all Ruby methods
911
- `ArduinoInstallation` class for managing lib / executable paths
1012
- `DisplayManager` class for managing Xvfb instance if needed
1113
- `ArduinoCmd` captures and caches preferences

README.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,38 @@
77
[Arduino CI](https://github.com/ifreecarve/arduino_ci) is a Ruby gem for executing Continuous Integration (CI) tests on an Arduino library -- both locally and as part of a service like Travis CI.
88

99

10-
## Installation
10+
## Installation In Your GitHub Project And Using Travis CI
1111

12-
Add this line to your application's Gemfile:
12+
Add a file called `Gemfile` (no extension) to your Arduino project:
1313

1414
```ruby
15+
source 'https://rubygems.org'
1516
gem 'arduino_ci'
1617
```
1718

18-
And then execute:
19+
Next, you need this in `.travis.yml`
1920

20-
$ bundle
21+
```yaml
22+
sudo: false
23+
language: ruby
24+
script:
25+
- bundle install
26+
- bundle exec arduino_ci_remote.rb
27+
```
28+
29+
That's literally all there is to it on the repository side. You'll need to go to https://travis-ci.org/profile/ and enable testing for your Arduino project. Once that happens, you should be all set.
2130
22-
Or install it yourself as:
2331
24-
$ gem install arduino_ci
32+
## More Documentation
2533
34+
This software is in alpha. But [SampleProjects/DoSomething](SampleProjects/DoSomething) has a decent writeup and is a good bare-bones example of all the features.
2635
27-
## Usage
36+
## Known Problems
2837
29-
TODO: Write usage instructions here, based on other TODO of writing the actual gem.
38+
* The Arduino library is not fully mocked.
39+
* I don't have preprocessor defines for all the Arduino board flavors
40+
* Arduino Zero boards don't work in CI. I'm confused.
41+
* https://github.com/ifreecarve/arduino_ci/issues
3042
3143
3244
## Author
@@ -37,3 +49,5 @@ This gem was written by Ian Katz ([email protected]) in 2018. It's released
3749
## See Also
3850
3951
* [Contributing](CONTRIBUTING.md)
52+
* [Adafruit/travis-ci-arduino](https://github.com/adafruit/travis-ci-arduino) which inspired this project
53+
* [mmurdoch/arduinounit](https://github.com/mmurdoch/arduinounit) from which the unit test macros were adopted

SampleProjects/DoSomething/README.md

+94-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Arduino CI and Unit Tests HOWTO [![Build Status](https://travis-ci.org/ifreecarve/arduino-ci-unit-tests.svg?branch=master)](https://travis-ci.org/ifreecarve/arduino-ci-unit-tests)
1+
# Arduino CI and Unit Tests HOWTO
22

33
This project is a template for a CI-enabled (and unit testable) Arduino project of your own.
44

@@ -7,17 +7,105 @@ This project is a template for a CI-enabled (and unit testable) Arduino project
77

88
* Travis CI
99
* Unit tests
10-
* Development workflow matches CI workflow - the `platformio ci` line at the bottom of `.travis.yml` can be run on your local terminal (just append the name of the file you want to compile).
10+
* Development workflow matches CI workflow
1111

1212
# Where The Magic Happens
1313

1414
Here is the minimal set of files that you will need to adapt to your own project:
1515

16-
* `.travis.yml` - You'll need to fill in the `env` section with files relevant to your project, and list out all the `--board`s under the `script` section.
17-
* `platformio.ini` - You'll need to add information for any architectures you plan to support.
18-
* `library.properties` - You'll need to update the `architectures` and `includes` lines as appropriate
16+
17+
### `Gemfile` Ruby gem configuration
18+
19+
```ruby
20+
source 'https://rubygems.org'
21+
gem 'arduino_ci'
22+
```
23+
24+
You'll need this to get access to the functionality.
25+
26+
> This is different from the `Gemfile` that's included in this directory! That's for purposes of testing the ruby gem that also lives in this repository. So "do as I say, not as I do", in this case.
27+
28+
29+
### `.travis.yml` Travis CI configuration
30+
31+
At a minimum, you will need the following lines in your file:
32+
33+
```yaml
34+
language: ruby
35+
script:
36+
- bundle install
37+
- bundle exec arduino_ci_remote.rb
38+
```
39+
40+
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...
41+
42+
### `.arduino-ci.yaml` ArduinoCI configuration
43+
44+
This file controls all aspects of building and unit testing. The (relatively-complete) defaults can be found [in the base project](../../misc/default.yaml).
45+
46+
The most relevant sections for most projects will be as follows:
47+
48+
```yaml
49+
compile:
50+
libraries: ~
51+
platforms:
52+
- uno
53+
- due
54+
- leonardo
55+
56+
unittest:
57+
libraries: ~
58+
platforms:
59+
- uno
60+
- due
61+
- leonardo
62+
```
63+
64+
This does nothing but specify a list of what platforms should run each set of tests. The platforms themselves can also be defined and/or extended in the yaml file. For example, `esp8266` as shown here:
65+
66+
```yaml
67+
platforms:
68+
esp8266:
69+
board: esp8266:esp8266:huzzah
70+
package: esp8266:esp8266
71+
gcc:
72+
features:
73+
defines:
74+
warnings:
75+
flags:
76+
```
77+
78+
Of course, this wouldn't work by itself -- the Arduino IDE would have to know how to install the package via the board manager. So there's a section for packages too:
79+
80+
```yaml
81+
packages:
82+
esp8266:esp8266:
83+
url: http://arduino.esp8266.com/stable/package_esp8266com_index.json
84+
```
85+
86+
### Unit tests in `test/`
87+
88+
All `.cpp` files in the `test/` directory are assumed to contain unit tests. Each and every one will be compiled and executed on its own.
89+
90+
The most basic unit test file is as follows:
91+
92+
```C++
93+
#include <ArduinoUnitTests.h>
94+
#include "../do-something.h"
95+
96+
unittest(your_test_name)
97+
{
98+
assertEqual(4, doSomething());
99+
}
100+
101+
int main(int argc, char *argv[]) {
102+
return Test::run_and_report(argc, argv);
103+
}
104+
```
105+
106+
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` section is boilerplate.
19107

20108

21109
# Credits
22110

23-
This Arduino example was created in January 2018 by Ian Katz <ianfixes@gmail.com>.
111+
This Arduino example was created in January 2018 by Ian Katz <ifreecarve@gmail.com>.

SampleProjects/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Arduino Sample Projects
22
=======================
33

4-
This directory contains example projects that are meant to be built with this gem.
4+
This directory contains example projects that are meant to be built with this gem. Except "TestSomething". That one's just a beater for CI testing and includes some tests that are designed to fail (to test negative inputs).

0 commit comments

Comments
 (0)