Skip to content

Commit 3e2b0e9

Browse files
committed
Removed 'files', 'libraries', 'cb_personal_libraries' paths from compilation output and added info texts, indicating where the error came from
1 parent 5a7c0ba commit 3e2b0e9

File tree

2 files changed

+59
-7
lines changed

2 files changed

+59
-7
lines changed

Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,20 +1401,26 @@ private function cleanUpClangOutput($clang_output, $compiler_config, $option)
14011401
private function pathRemover($output, $compiler_config)
14021402
{
14031403

1404-
// Remove any instance of "compiler.RANDOM/files/" folder name from the text
1405-
$modified = str_replace($compiler_config["compiler_dir"]."/files/", '', $output);
1404+
// Remove any instance of "compiler.RANDOM/files/" folder name from the text, add (sketch file) info text
1405+
$modified = str_replace($compiler_config["compiler_dir"]."/files/", '(sketch file) ', $output);
14061406

14071407
// Remove any remaining instance of "compiler.RANDOM/" folder name from the text.
14081408
$modified = str_replace($compiler_config["compiler_dir"]."/", '', $modified);
14091409

1410-
// Remove any instance of codebender arduino core files folder name from the text
1411-
$modified = str_replace($compiler_config["arduino_cores_dir"]."/v105/", '', $modified);
1410+
// Replace userId_cb_personal_lib prefix from personal libraries errors with a (personal library file) info text.
1411+
$modified = preg_replace('/libraries\/\d+_cb_personal_lib_/', '(personal library file) ', $modified);
14121412

1413-
// Remove any instance of codebender external core file folder name from the text
1413+
// Replace libraries/ prefix from personal libraries errors with a (personal library file) info text.
1414+
$modified = str_replace('libraries/', '(library file) ', $modified);
1415+
1416+
// Remove any instance of codebender arduino core files folder name from the text, add (arduino core file) info text
1417+
$modified = str_replace($compiler_config["arduino_cores_dir"]."/v105/", '(arduino core file) ', $modified);
1418+
1419+
// Remove any instance of codebender external core file folder name from the text, , add (arduino core file) info text
14141420
if (isset($compiler_config["external_core_files"]) && $compiler_config["external_core_files"] != "")
14151421
{
1416-
$modified = str_replace($compiler_config["external_core_files"], '', $modified);
1417-
$modified = str_replace("/override_cores/", '', $modified);
1422+
$modified = str_replace($compiler_config["external_core_files"], '(arduino core file) ', $modified);
1423+
$modified = str_replace("/override_cores/", '(arduino core file) ', $modified);
14181424
}
14191425

14201426
return $modified;

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,52 @@ public function testCleanedUpLinkerError()
249249
$this->assertEquals($expectedLinkerError, $response['message']);
250250
}
251251

252+
public function testEthernetCompileErrorRemovedLibraryPaths()
253+
{
254+
$files = array(array("filename" => "Blink.ino", "content" => "#include <Ethernet.h>\nvoid setup() {\n}\nvoid loop() {\n}\n"));
255+
$format = "binary";
256+
$version = "105";
257+
$libraries = array('PseudoEthernet' => array('files' => array('filename' => 'Ethernet.h', 'content' => "#include \"SPI.h\"\n")));
258+
$build = array("mcu" => "atmega328p", "f_cpu" => "16000000", "core" => "arduino", "variant" => "standard");
259+
260+
$data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build));
261+
262+
$client = static::createClient();
263+
264+
$authorizationKey = $client->getContainer()->getParameter("authorizationKey");
265+
266+
$client->request('POST', '/' . $authorizationKey . '/v1', array(), array(), array(), $data);
267+
268+
$response = json_decode($client->getResponse()->getContent(), true);
269+
270+
$this->assertEquals($response["success"], false);
271+
$this->assertEquals($response["step"], 4);
272+
$this->assertContains('(library file) PseudoEthernet/Ethernet.h:1:10: </b><b><font style="color: red">fatal error: </font></b><b>\'SPI.h\' file not found', $response['message']);
273+
}
274+
275+
public function testEthernetCompileErrorRemovedPersonalLibraryPaths()
276+
{
277+
$files = array(array("filename" => "Blink.ino", "content" => "#include <Ethernet.h>\nvoid setup() {\n}\nvoid loop() {\n}\n"));
278+
$format = "binary";
279+
$version = "105";
280+
$libraries = array('4096_cb_personal_lib_PseudoEthernet' => array('files' => array('filename' => 'Ethernet.h', 'content' => "#include \"SPI.h\"\n")));
281+
$build = array("mcu" => "atmega328p", "f_cpu" => "16000000", "core" => "arduino", "variant" => "standard");
282+
283+
$data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build));
284+
285+
$client = static::createClient();
286+
287+
$authorizationKey = $client->getContainer()->getParameter("authorizationKey");
288+
289+
$client->request('POST', '/' . $authorizationKey . '/v1', array(), array(), array(), $data);
290+
291+
$response = json_decode($client->getResponse()->getContent(), true);
292+
293+
$this->assertEquals($response["success"], false);
294+
$this->assertEquals($response["step"], 4);
295+
$this->assertContains('(personal library file) PseudoEthernet/Ethernet.h:1:10: </b><b><font style="color: red">fatal error: </font></b><b>\'SPI.h\' file not found', $response['message']);
296+
}
297+
252298
public function testAutocomplete()
253299
{
254300
$this->markTestIncomplete('No tests for the code completion feature yet.');

0 commit comments

Comments
 (0)