Skip to content

Commit dbea937

Browse files
committed
Added functional tests for external cores/variants usage
1 parent 335d89a commit dbea937

File tree

1 file changed

+63
-18
lines changed

1 file changed

+63
-18
lines changed

Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
class DefaultControllerFunctionalTest extends WebTestCase
88
{
9-
public function testStatus()
10-
{
9+
public function testStatus() {
1110
$client = static::createClient();
1211

1312
$client->request('GET', '/status');
@@ -16,8 +15,7 @@ public function testStatus()
1615

1716
}
1817

19-
public function testInvalidKey()
20-
{
18+
public function testInvalidKey() {
2119
$client = static::createClient();
2220

2321
$client->request('GET', '/inValidKey/v1');
@@ -26,8 +24,7 @@ public function testInvalidKey()
2624

2725
}
2826

29-
public function testInvalidAPI()
30-
{
27+
public function testInvalidAPI() {
3128
$client = static::createClient();
3229

3330
$auth_key = $client->getContainer()->getParameter("auth_key");
@@ -38,8 +35,7 @@ public function testInvalidAPI()
3835

3936
}
4037

41-
public function testInvalidInput()
42-
{
38+
public function testInvalidInput() {
4339
$client = static::createClient();
4440

4541
$auth_key = $client->getContainer()->getParameter("auth_key");
@@ -50,8 +46,7 @@ public function testInvalidInput()
5046

5147
}
5248

53-
public function testBlinkUnoSyntaxCheck()
54-
{
49+
public function testBlinkUnoSyntaxCheck() {
5550
$files = array(array("filename" => "Blink.ino", "content" => "int led = 13;\nvoid setup() {pinMode(led, OUTPUT);}\nvoid loop() {\ndigitalWrite(led, HIGH);\ndelay(1000);\ndigitalWrite(led, LOW);\ndelay(1000);\n}\n"));
5651
$format = "syntax";
5752
$version = "105";
@@ -71,10 +66,13 @@ public function testBlinkUnoSyntaxCheck()
7166
$this->assertEquals($response["success"], true);
7267
$this->assertTrue(is_numeric($response["time"]));
7368

69+
$objectFilesPath = $client->getContainer()->getParameter('temp_dir') . '/' . $client->getContainer()->getParameter('objdir');
70+
$coreObjectLibrary = glob("$objectFilesPath/*__v105__hardware__arduino__cores__arduino________atmega328p_16000000_arduino_standard_null_null_______core.a");
71+
$this->assertTrue(count($coreObjectLibrary) > 0);
72+
7473
}
7574

76-
public function testBlinkUnoCompile()
77-
{
75+
public function testBlinkUnoCompile() {
7876
$files = array(array("filename" => "Blink.ino", "content" => "\nint led = 13;\nvoid setup() {\npinMode(led, OUTPUT);\n}\nvoid loop() {\ndigitalWrite(led, HIGH);\ndelay(1000);\ndigitalWrite(led, LOW);\ndelay(1000);\n}\n"));
7977
$format = "binary";
8078
$version = "105";
@@ -96,8 +94,7 @@ public function testBlinkUnoCompile()
9694
$this->assertTrue(is_numeric($response["size"]));
9795
}
9896

99-
public function testBlinkUnoSyntaxCheckError()
100-
{
97+
public function testBlinkUnoSyntaxCheckError() {
10198
$files = array(array("filename" => "Blink.ino", "content" => "\nint led = 13\nvoid setup() {\npinMode(led, OUTPUT);\npinMode(led);\n}\nvoid loop() {\ndigitalWrite(led, HIGH);\ndelay(1000);\ndigitalWrite(led, LOW);\ndelay(1000);\n}\n"));
10299
$format = "syntax";
103100
$version = "105";
@@ -124,8 +121,7 @@ public function testBlinkUnoSyntaxCheckError()
124121
// $this->assertContains("2 errors generated.", $response["message"]); //unfortunately we no longer show how many errors were generated
125122
}
126123

127-
public function testBlinkUnoCompileError()
128-
{
124+
public function testBlinkUnoCompileError() {
129125
$files = array(array("filename" => "Blink.ino", "content" => "\nint led = 13\nvoid setup() {\npinMode(led, OUTPUT);\npinMode(led);\n}\nvoid loop() {\ndigitalWrite(led, HIGH);\ndelay(1000);\ndigitalWrite(led, LOW);\n delay(1000);\n}\n"));
130126
$format = "binary";
131127
$version = "105";
@@ -151,8 +147,57 @@ public function testBlinkUnoCompileError()
151147
// $this->assertContains("2 errors generated.", $response["message"]); //unfortunately we no longer show how many errors were generated
152148
}
153149

154-
public function testIncorrectInputs()
155-
{
150+
public function testExternalVariant() {
151+
$files = array(array('filename' => 'Blink.ino', 'content' => "void setup(){}\nvoid loop(){}\n"));
152+
$format = 'binary';
153+
$version = '105';
154+
$libraries = array();
155+
$build = array('mcu' => 'atmega32u4', 'f_cpu' => '8000000', 'core' => 'arduino', 'variant' => 'flora', 'pid' => '0x8004', 'vid' => '0x239A');
156+
$data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build));
157+
158+
$client = static::createClient();
159+
160+
$auth_key = $client->getContainer()->getParameter("auth_key");
161+
162+
$client->request('POST', '/'.$auth_key.'/v1', array(), array(), array(), $data);
163+
164+
$response = json_decode($client->getResponse()->getContent(), true);
165+
166+
$this->assertEquals($response['success'], true);
167+
$objectFilesPath = $client->getContainer()->getParameter('temp_dir') . '/' . $client->getContainer()->getParameter('objdir');
168+
$coreObjectLibrary = glob("$objectFilesPath/*v105__hardware__arduino__cores__arduino________atmega32u4_8000000_arduino_flora_0x239A_0x8004_______core.a");
169+
170+
$this->assertTrue(count($coreObjectLibrary) > 0);
171+
}
172+
173+
public function testExternalCore() {
174+
$files = array(array('filename' => 'Blink.ino', 'content' => "void setup(){}\nvoid loop(){}\n"));
175+
$format = 'binary';
176+
$version = '105';
177+
$libraries = array();
178+
$build = array('mcu' => 'attiny85', 'f_cpu' => '8000000', 'core' => 'tiny');
179+
$data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build));
180+
181+
$client = static::createClient();
182+
183+
$auth_key = $client->getContainer()->getParameter("auth_key");
184+
185+
$client->request('POST', '/'.$auth_key.'/v1', array(), array(), array(), $data);
186+
187+
$response = json_decode($client->getResponse()->getContent(), true);
188+
189+
$this->assertEquals($response['success'], true);
190+
$objectFilesPath = $client->getContainer()->getParameter('temp_dir') . '/' . $client->getContainer()->getParameter('objdir');
191+
$coreObjectLibrary = glob("$objectFilesPath/*__external_cores__tiny__cores__tiny________attiny85_8000000_tiny__null_null_______core.a");
192+
193+
$this->assertTrue(count($coreObjectLibrary) > 0);
194+
}
195+
196+
public function testAutocomplete() {
197+
$this->markTestIncomplete('No tests for the code completion feature yet.');
198+
}
199+
200+
public function testIncorrectInputs() {
156201
$this->markTestIncomplete("No tests for invalid inputs yet");
157202
}
158203
}

0 commit comments

Comments
 (0)