Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ private function doAutocomplete($ARDUINO_CORES_DIR, $compiler_config, $compile_d

$ext = pathinfo($file, PATHINFO_EXTENSION);
if (!in_array($ext, array("ino", "c", "cpp", "h", "hpp")))
return array("success" => false, "message" => "Sorry, autocompletion is only supported for .ino, .c, .cpp or .h files.");
return array("success" => false, "message" => "Sorry, autocompletion is only supported for .ino, .c, .cpp, .h or .hpp files.");
if ($ext == "ino")
{
$ext = "cpp";
Expand All @@ -1149,7 +1149,7 @@ private function doAutocomplete($ARDUINO_CORES_DIR, $compiler_config, $compile_d
$json_array = array("file" => $compiler_config["autocmpfile"], "row" => $compiler_config["autocmprow"], "column" => $compiler_config["autocmpcol"], "prefix" => $compiler_config["autocmpprefix"], "command" => $commandline);

}
elseif ($ext == "cpp" || $ext == "h")
elseif ($ext == "cpp" || $ext == "h" || $ext == "hpp" )
{
$commandline = "$CPP $CPPFLAGS $core_includes $target_arch -MMD $include_directories -c -o $filename.o $filename.$ext 2>&1";
$json_array = array("file" => $compiler_config["autocmpfile"], "row" => $compiler_config["autocmprow"], "column" => $compiler_config["autocmpcol"], "prefix" => $compiler_config["autocmpprefix"], "command" => $commandline);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function extractFiles($directory, $request_files, $lib_extraction)
// separated by "|" to be used in regular expressions. They are also
// used as keys in an array that will contain the paths of all the
// extracted files.
$allowedExtensions = array("c", "cpp", "h", "inc", "ino", "o", "S");
$allowedExtensions = array("c", "cpp", "h", "inc", "ino", "o", "S", "hpp");
$files = array();
foreach ($allowedExtensions as $ext)
$files[$ext] = array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ public function testInvalidInput()

}

public function testSkchHppUnoSyntaxCheck()
{
$files = array(array("filename" => "SkchHpp.ino", "content" => "#include<jsonhp.hpp>\nvoid setup()\n{\nSerial.begin(9600);\n\tint x = vardeb+5;\nSerial.println(x);\n}\n\nvoid loop()\n{\n\n}\n"));
$format = "syntax";
$version = "105";
$libraries = array('jsonlib' => array('files' => array('filename' => 'jsonhp.hpp', 'content' => "#define vardeb 3;\n")));
$build = array("mcu" => "atmega328p", "f_cpu" => "16000000", "core" => "arduino", "variant" => "standard");

$data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build));

$client = static::createClient();

$authorizationKey = $client->getContainer()->getParameter("authorizationKey");

$client->request('POST', '/' . $authorizationKey . '/v1', array(), array(), array(), $data);

$response = json_decode($client->getResponse()->getContent(), true);

$this->assertEquals($response["success"], true);
$this->assertTrue(is_numeric($response["time"]));

}


public function testBlinkUnoSyntaxCheck()
{
$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"));
Expand Down