Skip to content
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

Pull in changes from upstream #1

Open
wants to merge 93 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
522448f
add abort to tests and use in advanced example
wmacevoy May 1, 2018
cfb703f
edit changelog
wmacevoy May 1, 2018
996ebc4
better advanced example
wmacevoy May 2, 2018
0e728f4
edit guide
wmacevoy May 2, 2018
b5b167b
edit guide
wmacevoy May 2, 2018
3b456cb
edit guide
wmacevoy May 2, 2018
3aa4c95
edit guide
wmacevoy May 2, 2018
ea9caf5
edit guide
wmacevoy May 2, 2018
b9d350d
edit guide
wmacevoy May 2, 2018
1ab6777
edit guide
wmacevoy May 2, 2018
edf0c20
ci init
wmacevoy May 2, 2018
14d8a57
merge guide
wmacevoy May 3, 2018
fa4a791
grammer
wmacevoy May 3, 2018
8211a0a
vitro example
wmacevoy May 3, 2018
e72096f
vitro example
wmacevoy May 3, 2018
0993f9a
args for test
wmacevoy May 3, 2018
1b7b6f1
vitro build
wmacevoy May 3, 2018
b873410
test vitro
wmacevoy May 3, 2018
a965d42
vitro example
wmacevoy May 3, 2018
906c98b
linux build
wmacevoy May 3, 2018
31fb892
leave .hex artifact
wmacevoy May 3, 2018
07a1218
ci
wmacevoy May 4, 2018
25797be
test ci
wmacevoy May 6, 2018
82384d6
ci_self_test
wmacevoy May 6, 2018
b9c9abb
dir_cache
wmacevoy May 6, 2018
92579d3
simpler includes cache_ide
wmacevoy May 6, 2018
3616ecb
compile_vitro
wmacevoy May 6, 2018
66d79cd
Merge branch 'iss63' of github.com:mmurdoch/arduinounit into iss63
wmacevoy May 6, 2018
7e12acc
compile
wmacevoy May 6, 2018
00737e4
ci mac
wmacevoy May 6, 2018
c5fd9ce
vitro test file
wmacevoy May 6, 2018
486ce6d
vitro
wmacevoy May 6, 2018
eecfe80
fix arduino_exe
wmacevoy May 7, 2018
18f218d
ide update
wmacevoy May 11, 2018
41e134c
launch arduino
wmacevoy May 11, 2018
3ca3aa7
compile uno
wmacevoy May 11, 2018
4a1b88e
compile uno
wmacevoy May 11, 2018
a66593a
compile uno
wmacevoy May 11, 2018
2dff44a
compile mega
wmacevoy May 11, 2018
fbcf127
library props
wmacevoy May 11, 2018
e192ecd
library properties
wmacevoy May 11, 2018
907b2c0
upload
wmacevoy May 14, 2018
64cf0af
ci self-test
wmacevoy May 14, 2018
6b7fb36
merge
wmacevoy May 14, 2018
cd98350
continuous integration tools.
wmacevoy May 14, 2018
2ca5162
merge
wmacevoy May 14, 2018
21687fe
merge
wmacevoy May 14, 2018
ce10afb
Put mergeable progmem strings in a separate section
matthijskooijman May 17, 2018
11517ec
Fix indentation after previous commit
matthijskooijman May 17, 2018
2f1bee9
Merge pull request #81 from matthijskooijman/fix-progmem
wmacevoy May 17, 2018
0d9a648
Merge branch 'master' of github.com:mmurdoch/arduinounit
wmacevoy Jun 11, 2018
218fbd1
version update
wmacevoy Jun 11, 2018
daa6cc3
new macro names
wmacevoy Jun 11, 2018
0af78db
Use correct field separator in keywords.txt
per1234 Jul 17, 2018
5d16d57
Merge pull request #84 from per1234/keywords-separator
wmacevoy Jul 17, 2018
117e71a
make context script
wmacevoy Feb 17, 2019
0001840
do not set path
wmacevoy Feb 17, 2019
e840009
move to better name
wmacevoy Feb 17, 2019
15749d5
build-test on pi
wmacevoy Feb 17, 2019
1dd70aa
skip slow tests with --fast
wmacevoy Feb 17, 2019
8a3409a
better error reporting
wmacevoy Feb 17, 2019
7995635
ci pi+mac!
wmacevoy Feb 17, 2019
44b3fe6
package_install script
wmacevoy Feb 17, 2019
59bf279
add unzip/tar if commands are missing
wmacevoy Feb 17, 2019
ce23585
update default version
wmacevoy Feb 17, 2019
93086a7
local vars
wmacevoy Feb 17, 2019
2230a5a
build simavr on mac
wmacevoy Feb 17, 2019
bfc15a9
create lib dir for osx
wmacevoy Feb 17, 2019
7476ba7
ci notes and easy reset
wmacevoy Feb 17, 2019
6ab8191
better reset
wmacevoy Feb 17, 2019
e4f7a65
fix ci upload
wmacevoy Feb 17, 2019
4ad93a1
not quite reproducing the bug
wmacevoy Feb 17, 2019
e0710c7
Fix for TEENSYDUINO not having the protected String::concat(const cha…
ssilverman Mar 17, 2019
5431e99
Merge pull request #88 from ssilverman/master
wmacevoy Mar 21, 2019
306e0b5
teensy support
wmacevoy Sep 8, 2019
6b9060c
add debug flag (-g) to compile_avr
wmacevoy Sep 8, 2019
7266d16
debug hack on ubuntu
wmacevoy Sep 9, 2019
60840b8
not all skipped.
wmacevoy Sep 9, 2019
dbcfa8c
merge#89
wmacevoy Sep 9, 2019
9dbd3ce
resolve #86 - finally!
wmacevoy Sep 9, 2019
2453376
remove skipped from known bug list
wmacevoy Sep 9, 2019
7e8095f
edit
wmacevoy Sep 9, 2019
b687ea4
edit
wmacevoy Sep 9, 2019
72da542
Fix incorrect merging of PROGMEM strings
matthijskooijman Jan 30, 2021
1e67169
Merge pull request #91 from matthijskooijman/progmem-string-merging
wmacevoy Nov 13, 2022
bf4effc
Introduce a new "done" list of tests
matthijskooijman Apr 13, 2018
9b1ce8b
Increment count in constructor instead of insert()
matthijskooijman May 17, 2018
63108e8
Add Test::resetDoneTest() to re-run completed tests
matthijskooijman Jul 26, 2017
9b14493
Add Test::runUntilDone()
matthijskooijman May 17, 2018
c96d03d
Document resetDoneTests() and runUntilDone()
matthijskooijman May 17, 2018
9157b89
Merge pull request #85 from matthijskooijman/multiple-runs
wmacevoy May 10, 2023
e9dacf4
reset script
wmacevoy May 23, 2023
6e7e6dd
cleaner factored script
wmacevoy May 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 45 additions & 34 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,60 @@

## 2.0.0

* Rewrite
* Rewrite

## 2.1

* Updated documentation
* Tests for FakeStreamBuffer
* Support for Arduino Due
* Support for Flash Strings (avoid namespace collision with Arduino String)
* Reset of FakeStream
* Updated documentation
* Tests for FakeStreamBuffer
* Support for Arduino Due
* Support for Flash Strings (avoid namespace collision with Arduino String)
* Reset of FakeStream

## 2.1.1

* Support for Arduino Due (adjust examples)
* Add library.properties file
* Support for Arduino Due (adjust examples)
* Add library.properties file

## 2.2.0

* Move to Arduino 1.5 compliant library directory structure
* Move utility to ArduinoUnitUtility to avoid conflict with other libraries
* Adjust firmware test to explain basic usage
* Support for comparing various string types in (#iss47)
* Add Compare.h and mkCompare in meta for comparing strings
* Move to Arduino 1.5 compliant library directory structure
* Move utility to ArduinoUnitUtility to avoid conflict with other libraries
* Adjust firmware test to explain basic usage
* Support for comparing various string types in (#iss47)
* Add Compare.h and mkCompare in meta for comparing strings

## 2.3.0

* Remove support of very old gcc compiler
* Add support for de-duplicaton of flash strings
* Add support for ESP 8266 and ESP 32
* Use more standard file names (README.md, LICENSE, and CHANGELOG.md)
* Use less likely to fail version of `while (!Serial) {}` in examples and documentation.
* Make Test::TestString ArduinoUnitString, and refactor Compare to leverage that code.
* Add an optional lazy message last argument to every assert.
* Add building outside of arduino environment
* Significant reduction of code implementation and compiled size (Compare.h is now small)
* Add minimal mock builds on dev (in vitro) platform
* Add better mock builds.
* Use type widening to reduce specializations.
* Depricate FakeStream for MockStream and MockPrint
* Resolve a<b equivalence regresion (issue 77)
* Resolve builds for ESP8266/ESP32
* Prefer `decltype` over `__typeof__`
* Added a guidebook
* assertNear(a,b,max[,message]) for float/double
* assertRelation(args [,message [,retval]])
* assertRelativelyNear(a,b,max[,message]) for float/double

* Remove support of very old gcc compiler
* Add support for de-duplicaton of flash strings
* Add support for ESP 8266 and ESP 32
* Use more standard file names (README.md, LICENSE, and CHANGELOG.md)
* Use less likely to fail version of `while (!Serial) {}` in examples and documentation.
* Make Test::TestString ArduinoUnitString, and refactor Compare to leverage that code.
* Add an optional lazy message last argument to every assert.
* Add building outside of arduino environment
* Significant reduction of code implementation and compiled size (Compare.h is now small)
* Add minimal mock builds on dev (in vitro) platform
* Add better mock builds.
* Use type widening to reduce specializations.
* Depricate FakeStream for MockStream and MockPrint
* Resolve a<b equivalence regresion (issue 77)
* Resolve builds for ESP8266/ESP32
* Prefer `decltype` over `__typeof__`
* Added a guidebook
* assertNear(a,b,max[,message]) for float/double
* assertRelation(args [,message [,retval]])
* assertRelativelyNear(a,b,max[,message]) for float/double
* Test::abort() to complete all unresolved tests
* Provide "en vitro" simple example & build scripts
## 3.0.0
* Provide preliminary Continuous Integration Testing support (ci)
## 3.0.2
* Data deduplication bug fix patch.
## 3.0.3
* Support for Teensy (#87)
## 3.0.4
* Skipped message bug fixed (#86)
* Debug (alpha) documented for simavr/avr-gdb (ci.md)

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
UNAME := $(shell uname)

ifeq ($(UNAME), Linux)
ARDUINO_DIR=/usr/share/arduino
ARDUINO_DIR=$(HOME)/Arduino
endif
ifeq ($(UNAME), Darwin)
ARDUINO_DIR=$(HOME)/Documents/Arduino
Expand Down
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ The following asserts are supported [with an optional footnote and return value]
| Assertion | Description |
| --- | --- |
| `assertEqual(a,b [,footnote [,retval]])` | `a == b`? |
| `assertNear(a,b,maxerr, [,footnote[,retval]])` | `|b-a|<=maxerr`? |
| `assertRelativelyNear(a,b,maxerr, [,footnote[,retval]])` | `|b-a|/(½(|a|+|b|))<=maxerr`? |
| `assertNear(a,b,maxerr, [,footnote[,retval]])` | `abs(b-a)<=maxerr`? |
| `assertRelativelyNear(a,b,maxerr, [,footnote[,retval]])` | `abs(b-a)/abs(½(abs(a)+abs(b)))<=maxerr`? |
| `assertNotEqual(a,b [,footnote[,retval]])` | `a != b`? |
| `assertLess(a,b [,footnote[,retval]])` | `a < b`? |
| `assertLessOrEqual(a,b [,footnote[,retval]])` | `a <= b`? |
Expand Down Expand Up @@ -137,6 +137,55 @@ void setup()
}
```

## Re-running tests (advanced)
Typically, you just want to run all tests once and then show the result.
If so, you can skip this section.

In more advanced situations, you might want to run the entire test suite
multiple times (for example if your tests can be configured with
different parameters). To facilitate this, you can use the
`Test::resetDoneTests()` function.

Calling this function will reset all completed tests (passed, failed or
skipped) back to their initial state. For tests that define a `setup`
method, this will be run again on the next `Test::run()`. If any tests
were not completed yet, these are unaffected. The statistics (number of
passed, failed and skipped tests) are also reset to 0.

Note that excluded tests (using `Test::exclude()`) are treated as
skipped tests, so these are also re-run (you will need to call
`Test::exclude()` again after `resetDoneTests()` if you want keep these
tests excluded). Tests removed with their `remove()` method are really
removed, so not re-run when using `resetDoneTests()`.

Typically, you would use this after all tests are completed (but if you
call `resetDoneTests()` when some tests are still pending, those
tests are unaffected). You must never call `resetDoneTests()` from
inside a test, only between calls to `Test::run()`.

Below is an example that runs all tests once, then changes a global
variable and runs all tests again. To have a bit more direct control
over running the tests, this example does not call `Test::run()`
infinitely in the `loop()`, but instead uses `Test:runUntilDone()` which
repeatedly calls `Test::run()` until all tests are completed.

```
bool some_global_setting = false;

void setup() {
Serial.begin(9600);
while(!Serial) {} // Portability for Leonardo/Micro

Test::runUntilDone();

some_global_setting = true;
Test::resetDoneTests();
Test::runUntilDone();
}

void loop() { }
```

# Output

The `Test::out` value is the *shared* value for all tests describing where output for all tests goes. The default is
Expand Down
21 changes: 0 additions & 21 deletions bin/compile-avr

This file was deleted.

3 changes: 3 additions & 0 deletions bin/compile-lib-avr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ compile() {
echo "compile time error: avr."
exit 1
fi

cp "${ARDUINO_TARGET_HEX}" "${ARDUINO_TARGET_INO%.ino}.hex"

if [ "${ARDUINO_TARGET_UPLOAD}" = "true" -a -e "${ARDUINO_TARGET_PORT}" ] ; then
if ! ${ARDUINO_DIR}/hardware/tools/avr/bin/avrdude -C${ARDUINO_DIR}/hardware/tools/avr/etc/avrdude.conf -v -p${ARDUINO_TARGET_BOARD##*cpu=} -cwiring -P"${ARDUINO_TARGET_PORT}" -b${ARDUINO_TARGET_BAUD} -D -Uflash:w:"${ARDUINO_TARGET_HEX}":i
then
Expand Down
140 changes: 140 additions & 0 deletions ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# CI - Continuous Integration

This is preliminary support for continuous integration. These have been tested in Linux (Ubuntu 16.04) and Mac OSX. These are tool agnostic: you can run them by hand, as part of a commit hook (no server), or using a continuous integration service like Travis CI or Jenkins. They also support en vitro, simulator, and en vivo tests.

## Install

There really is nothing to install. The CI tools are bash scripts that can be run from anywhere. They maintain a set of IDE's under the $HOME/.arduino directory so you can test your project with different versions of the IDE and different installed libraries.

### Prerequisites

#### macosx

On a OS X, you will have to install the XCode command line tools and homebrew:

```bash
if ! which git ; then xcode-select --install ; fi # xcode cli
if ! which brew ; then /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ; fi # homebrew
```

#### linux

In linux, you need git make g++ unzip and curl:

```bash
sudo apt install -y git make g++ unzip curl
```

#### windows

Install Windows Subsystem for Linux, then Ubuntu under WSL, then follow the linux instructions in a WSL/Ubuntu terminal. I think.

This has not been tested in windows. I believe using the Windows Subsystem for Linux and installing Ubuntu 16.04 would be a path to success [WSL](https://devtidbits.com/2017/06/08/run-ubuntu-16-04-on-windows-10-creators-update/), although some tweaks may be necessary. __All commands are assumed to be running from a bash shell.___

### Setup

Copy the arduinounit (or at least the ci sub-folder) and its contents to clone this repository in your projects folder, as in:

```bash
# the directory is where you keep your projects...
mkdir -p "$HOME/projects"
cd "$HOME/projects"
git clone https://github.com/mmurdoch/arduinounit.git
```

To make the tools easier to use, you can define the `au` bash function by sourcing `au` in the `ci` directory (notice the dot with a space):

```bash
. "$HOME/projects/arduinounit/ci/au"

```

You can put this in your `.profile` if you like, so it is set every time you log in.

To test (you may have to log out and log back in), try:

```bash
au dir
au dir_cache
au arduino_dir
au sketchbook
au arduino --pref update.check=false --install-library ArduinoUnit
```

In the `examples/basic` arduinounit folder, try,

```bash
au compile_uno
au simavr_uno
```

If you want to see the output in junit format (you really don't, but Jenkins, TravisCI and similar CI tools do), try

```bash
au simavr_uno | au au2ju
```

In the vitro example, you can run tests 3 different ways: on the hardware, on the simulator, or on the dev system:

```bash
au compile_vitro
./vitro
./vitro | au au2ju
au compile_uno
au simavr_uno --hex=vitro.hex
au upload_uno
```

You may have to specify --port=[port] to upload, assuming an UNO board is connected.

These all take `--os=(macosx|linux64|linux32|linuxarm|windows)` and `--version=(arduino_ide_version)` options.

### Important

The CI tools do NOT use the standard install location for arduino. This is because tool configuration tests [checking if your project builds with certain version of the IDE or dependent librarie(s)] would be very inconvenient if that required the removal and installation of your standard arduino environment. Instead the IDE and simavr tools are cached in a directory structure:

```bash
${HOME}/.arduino/
cache/
arduino-${VERSION}-${OS}(.zip|.tar.xz)
arduino-${VERSION}-${OS}(.zip|.tar.xz).sha512sum.txt
simavr/
... git clone https://github.com/buserror/simavr .
${VERSION}-${OS}/
...
portable/
sketchbook/
libraries/
```

The CI tools install the IDE in "portable" mode so they do not use or modify your default IDE. When making a "clean install test", do NOT delete the zip/tar files in the cache. These are checked against the very secure sha512 (and will be re-downloaded if they checksum fails). Downloading these again is very slow and a waste of bandwidth.

A clean (except the ide cache which is pointless and slow) install can be started with:

```bash
au reset
```

## debug

*Warning* this is a hack. But stepping through code is amazingly useful. I have only worked out steps on Ubuntu 18.04, and depends on the simavr tool, which gives no uart output. Still it is better than nothing.

1. Install simavr (sudo apt install simavr). This should also install avr-gcc.
1. Install this toolset in in Ubunutu: run `au arduino` to spin up the basic working cache of the ide.
1. Create and set the TMP environment variable so the system does not build and erase a temporary file. I used "<project>/tmpdir" and made that folder.
1. Compile the project with `au compile_avr` in the project directory. The build residue should be in TMP.
1. Look in the TMP directory, and find the build folder.
1. Open two terminals here; one to run the program and one to debug from.
1. In your run terminal, type
```bash
simavr -g -m atmega328p -f 16000000 basic.ino.elf
```
1. In your debug terminal, type `avr-gdb` to start the avr debugger, then in th prompts type
```bash
tui enable
file basic.ino.elf
target remote :1234
b setup
c
s
```
9 changes: 9 additions & 0 deletions ci/au
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# find directory of this sourced context

pushd $(dirname "${BASH_SOURCE[0]}") >/dev/null
arduinounit_ci_bin="$PWD/bin"
popd >/dev/null

eval 'au() { local cmd="$1"; shift; "'"$arduinounit_ci_bin"'/$cmd" "$@"; }; export -f au;'


Loading