Skip to content

Commit 82c0fe3

Browse files
author
James Foster
committed
Add test for Arduino-CI#192: fatal error: 'Adafruit_SPIDevice.h' file not found
1 parent 2c20e0e commit 82c0fe3

File tree

9 files changed

+94
-0
lines changed

9 files changed

+94
-0
lines changed

SampleProjects/BusIO/.arduino-ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
unittest:
2+
platforms:
3+
- mega2560
4+
libraries:
5+
- "Adafruit BusIO"
6+
# - "Adafruit_BusIO" <= This works if you have the library pre-installed
7+
8+
compile:
9+
platforms:
10+
- mega2560
11+
libraries:
12+
- "Adafruit BusIO"

SampleProjects/BusIO/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.bundle

SampleProjects/BusIO/Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gem 'arduino_ci', path: '../../'

SampleProjects/BusIO/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# BusIO
2+
3+
This is an example of a library that depends on Adafruit BusIO.
4+
It is provided to help reproduce #192.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <Adafruit_SPIDevice.h>
2+
3+
#define SPIDEVICE_CS 10
4+
Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS);
5+
6+
7+
void setup() {
8+
while (!Serial) { delay(10); }
9+
Serial.begin(115200);
10+
Serial.println("SPI device read and write test");
11+
12+
if (!spi_dev.begin()) {
13+
Serial.println("Could not initialize SPI device");
14+
while (1);
15+
}
16+
17+
uint8_t buffer[32];
18+
19+
// Try to read 32 bytes
20+
spi_dev.read(buffer, 32);
21+
Serial.print("Read: ");
22+
for (uint8_t i=0; i<32; i++) {
23+
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
24+
}
25+
Serial.println();
26+
27+
// read a register by writing first, then reading
28+
buffer[0] = 0x8F; // we'll reuse the same buffer
29+
spi_dev.write_then_read(buffer, 1, buffer, 2, false);
30+
Serial.print("Write then Read: ");
31+
for (uint8_t i=0; i<2; i++) {
32+
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
33+
}
34+
Serial.println();
35+
}
36+
37+
void loop() {
38+
39+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=BusIO
2+
version=0.1.0
3+
author=James Foster <[email protected]>
4+
maintainer=James Foster <[email protected]>
5+
sentence=Sample BusIO library to validate import of Adafruit BusIO
6+
paragraph=Sample BusIO library to validate import of Adafruit BusIO
7+
category=Other
8+
url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/BusIO
9+
architectures=avr,esp8266
10+
includes=BusIO.h

SampleProjects/BusIO/src/BusIO.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <Adafruit_SPIDevice.h>
2+
#include <Arduino.h>
3+
4+
class BusIO {
5+
public:
6+
BusIO() {}
7+
~BusIO() {}
8+
int answer() { return 42; }
9+
}

SampleProjects/BusIO/test/test.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
bundle config --local path vendor/bundle
3+
bundle install
4+
bundle exec arduino_ci.rb --skip-examples-compilation
5+
*/
6+
7+
#include <Arduino.h>
8+
#include <ArduinoUnitTests.h>
9+
#include <BusIO.h>
10+
11+
unittest(loop) {
12+
// token test
13+
BusIO busIO;
14+
assertEqual(42, busIO.answer()));
15+
}
16+
17+
unittest_main()

exe/arduino_ci.rb

100644100755
File mode changed.

0 commit comments

Comments
 (0)