Skip to content

Commit 0af0b44

Browse files
authored
[skip-changelog] Porting legacy tests to new integration-test infra (part 1...) (#2294)
* Moved out from legacy some TryBuild* integration tests * Ported sketch_with_config integration tests out of legacy * Ported sketch_no_functions integration tests out of legacy * Ported sketch_with_backup_files integration tests out of legacy * Ported sketch_with_old_lib integration tests out of legacy * Ported sketch_with_subfolders integration tests out of legacy * Ported sketch_with_class integration tests out of legacy * Simplified integrationtest of preprocessor * Ported sketch_with_typename integration tests out of legacy * Ported sketch_with_namespace integration tests out of legacy * Ported sketch_with_default_args integration tests out of legacy * Ported sketch_with_inline_function_args integration tests out of legacy * Ported sketch_with_function_signature_inside_ifdef integration tests out of legacy * Ported sketch_with_usbcon integration tests out of legacy * Ported sketch_with_const integration tests out of legacy * Ported sketch_with_templates_and_shift integration tests out of legacy * Ported sketch eol_processing integration tests out of legacy * Ported SketchWithIfdef integration tests out of legacy * Ported sketch_with_ifdef integration tests out of legacy * Ported Bridge integration tests out of legacy * Ported more Bridge integration tests out of legacy * Ported even more Bridge integration tests out of legacy * Better subtesting categorization * Ported yet another Bridge integration tests out of legacy * Ported Balanduino integration tests out of legacy * Ported CharWithEscapedDoubleQuote integration tests out of legacy * Ported IncludeBetweenMultilineComment integration tests out of legacy * Ported LineContinuations integration tests out of legacy * Ported StringWithComment integration tests out of legacy * Ported SketchWithStruct integration tests out of legacy * Ported SketchNoFunctionsTwoFiles integration tests out of legacy * Ported SketchWithClassAndMethodSubstring integration tests out of legacy * Ported SketchThatChecksIfSPIHasTransactions integration tests out of legacy * Ported sketch_with_dependend_libraries integration tests out of legacy * Ported sketch_with_function_pointer integration tests out of legacy * Ported sketch_usbhost integration tests out of legacy * Removed sketch1 from try_build* test It's already compiled many times in other tests. * Ported sketch9 integration tests out of legacy * Removing no more used functions * Ported USBHost test * Removed no more useful test from legacy * Removed no more needed tests
1 parent 3f9373a commit 0af0b44

File tree

142 files changed

+10627
-1363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+10627
-1363
lines changed

Diff for: internal/integrationtest/compile_4/compile_test.go

+631
Large diffs are not rendered by default.

Diff for: legacy/builder/test/Baladuino/Baladuino.preprocessed.txt renamed to internal/integrationtest/compile_4/testdata/Baladuino/Baladuino.preprocessed.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <Arduino.h>
2-
#line 1 {{QuoteCppString .sketch.MainFile}}
2+
#line 1 {{QuoteCppString .sketchMainFile}}
33
/*
44
* The code is released under the GNU General Public License.
55
* Developed by Kristian Lauszus, TKJ Electronics 2013
@@ -87,11 +87,11 @@ WII Wii(&Btd); // The Wii library can communicate with Wiimotes and the Nunchuck
8787
// This can also be done using the Android or Processing application
8888
#endif
8989

90-
#line 88 {{QuoteCppString .sketch.MainFile}}
90+
#line 88 {{QuoteCppString .sketchMainFile}}
9191
void setup();
92-
#line 204 {{QuoteCppString .sketch.MainFile}}
92+
#line 204 {{QuoteCppString .sketchMainFile}}
9393
void loop();
94-
#line 88 {{QuoteCppString .sketch.MainFile}}
94+
#line 88 {{QuoteCppString .sketchMainFile}}
9595
void setup() {
9696
/* Initialize UART */
9797
Serial.begin(115200);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/*
2+
Arduino Yún Bridge example
3+
4+
This example for the Arduino Yún shows how to use the
5+
Bridge library to access the digital and analog pins
6+
on the board through REST calls. It demonstrates how
7+
you can create your own API when using REST style
8+
calls through the browser.
9+
10+
Possible commands created in this shetch:
11+
12+
"/arduino/digital/13" -> digitalRead(13)
13+
"/arduino/digital/13/1" -> digitalWrite(13, HIGH)
14+
"/arduino/analog/2/123" -> analogWrite(2, 123)
15+
"/arduino/analog/2" -> analogRead(2)
16+
"/arduino/mode/13/input" -> pinMode(13, INPUT)
17+
"/arduino/mode/13/output" -> pinMode(13, OUTPUT)
18+
19+
This example code is part of the public domain
20+
21+
http://www.arduino.cc/en/Tutorial/Bridge
22+
23+
*/
24+
25+
#include <Bridge.h>
26+
#include <BridgeServer.h>
27+
#include <BridgeClient.h>
28+
29+
// Listen to the default port 5555, the Yún webserver
30+
// will forward there all the HTTP requests you send
31+
BridgeServer server;
32+
33+
void setup() {
34+
// Bridge startup
35+
pinMode(13, OUTPUT);
36+
digitalWrite(13, LOW);
37+
Bridge.begin();
38+
digitalWrite(13, HIGH);
39+
40+
// Listen for incoming connection only from localhost
41+
// (no one from the external network could connect)
42+
server.listenOnLocalhost();
43+
server.begin();
44+
}
45+
46+
void loop() {
47+
// Get clients coming from server
48+
BridgeClient client = server.accept();
49+
50+
// There is a new client?
51+
if (client) {
52+
// Process request
53+
process(client);
54+
55+
// Close connection and free resources.
56+
client.stop();
57+
}
58+
59+
delay(50); // Poll every 50ms
60+
}
61+
62+
void process(BridgeClient client) {
63+
// read the command
64+
String command = client.readStringUntil('/');
65+
66+
// is "digital" command?
67+
if (command == "digital") {
68+
digitalCommand(client);
69+
}
70+
71+
// is "analog" command?
72+
if (command == "analog") {
73+
analogCommand(client);
74+
}
75+
76+
// is "mode" command?
77+
if (command == "mode") {
78+
modeCommand(client);
79+
}
80+
}
81+
82+
void digitalCommand(BridgeClient client) {
83+
int pin, value;
84+
85+
// Read pin number
86+
pin = client.parseInt();
87+
88+
// If the next character is a '/' it means we have an URL
89+
// with a value like: "/digital/13/1"
90+
if (client.read() == '/') {
91+
value = client.parseInt();
92+
digitalWrite(pin, value);
93+
} else {
94+
value = digitalRead(pin);
95+
}
96+
97+
// Send feedback to client
98+
client.print(F("Pin D"));
99+
client.print(pin);
100+
client.print(F(" set to "));
101+
client.println(value);
102+
103+
// Update datastore key with the current pin value
104+
String key = "D";
105+
key += pin;
106+
Bridge.put(key, String(value));
107+
}
108+
109+
void analogCommand(BridgeClient client) {
110+
int pin, value;
111+
112+
// Read pin number
113+
pin = client.parseInt();
114+
115+
// If the next character is a '/' it means we have an URL
116+
// with a value like: "/analog/5/120"
117+
if (client.read() == '/') {
118+
// Read value and execute command
119+
value = client.parseInt();
120+
analogWrite(pin, value);
121+
122+
// Send feedback to client
123+
client.print(F("Pin D"));
124+
client.print(pin);
125+
client.print(F(" set to analog "));
126+
client.println(value);
127+
128+
// Update datastore key with the current pin value
129+
String key = "D";
130+
key += pin;
131+
Bridge.put(key, String(value));
132+
} else {
133+
// Read analog pin
134+
value = analogRead(pin);
135+
136+
// Send feedback to client
137+
client.print(F("Pin A"));
138+
client.print(pin);
139+
client.print(F(" reads analog "));
140+
client.println(value);
141+
142+
// Update datastore key with the current pin value
143+
String key = "A";
144+
key += pin;
145+
Bridge.put(key, String(value));
146+
}
147+
}
148+
149+
void modeCommand(BridgeClient client) {
150+
int pin;
151+
152+
// Read pin number
153+
pin = client.parseInt();
154+
155+
// If the next character is not a '/' we have a malformed URL
156+
if (client.read() != '/') {
157+
client.println(F("error"));
158+
return;
159+
}
160+
161+
String mode = client.readStringUntil('\r');
162+
163+
if (mode == "input") {
164+
pinMode(pin, INPUT);
165+
// Send feedback to client
166+
client.print(F("Pin D"));
167+
client.print(pin);
168+
client.print(F(" configured as INPUT!"));
169+
return;
170+
}
171+
172+
if (mode == "output") {
173+
pinMode(pin, OUTPUT);
174+
// Send feedback to client
175+
client.print(F("Pin D"));
176+
client.print(pin);
177+
client.print(F(" configured as OUTPUT!"));
178+
return;
179+
}
180+
181+
client.print(F("error: invalid mode "));
182+
client.print(mode);
183+
}
184+
185+

0 commit comments

Comments
 (0)