Skip to content

Commit

Permalink
WIP: Add test for submission validation
Browse files Browse the repository at this point in the history
  • Loading branch information
josephsnyder committed Oct 9, 2024
1 parent 63bef62 commit 4602d25
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/cdash/include/ctestparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ function ctest_parse($filehandle, string $filename, $projectid, $expected_md5 =
$schema_file = $xml_info['xml_schema'];

// If validation is enabled and if this file has a corresponding schema, validate it
\Log::critical(((bool) config('cdash.validate_xml_submissions')));
\Log::critical($schema_file);
if (((bool) config('cdash.validate_xml_submissions')) === true && isset($schema_file)) {
try {
SubmissionUtils::validate_xml(storage_path("app/".$filename), $schema_file);
SubmissionUtils::validate_xml($filename, $schema_file);
} catch (CDashXMLValidationException $e) {
foreach ($e->getDecodedMessage() as $error) {
Log::error("Validating $filename: ".$error);
Expand Down
3 changes: 3 additions & 0 deletions app/cdash/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -607,5 +607,8 @@ set_tests_properties(/Feature/RemoteWorkers PROPERTIES DEPENDS install_3)

add_laravel_test(/Unit/app/Console/Command/ValidateXmlCommandTest)

add_php_test(submissionvalidation)
set_tests_properties(submissionvalidation PROPERTIES DEPENDS install_3)

add_subdirectory(ctest)
add_subdirectory(autoremovebuilds)
48 changes: 48 additions & 0 deletions app/cdash/tests/test_submissionvalidation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
require_once dirname(__FILE__) . '/cdash_test_case.php';


use CDash\Model\Build;
use App\Models\BuildInformation;

class SubmissionValidationTestCase extends KWWebTestCase
{
protected $PDO;
protected $ConfigFile;
protected $Original;

public function _construct() {

parent::__construct();
}

public function submit($fileName)
{
$rep = dirname(__FILE__) . '/../../../tests/data/XmlValidation';
$file = "$rep/$fileName";
#print_r($file);
#print_r(file_get_contents($file));
#print($this->submission('InsightExample', $file));
if (false) {
return false;
}

$this->assertTrue(true, "Submission of $file has succeeded");
}

public function testSubmissionValidation()
{

$this->ConfigFile = dirname(__FILE__) . '/../../../.env';
$this->Original = file_get_contents($this->ConfigFile);
#print_r($this->Original);
file_put_contents($this->ConfigFile, "VALIDATE_XML_SUBMISSIONS=true\n", FILE_APPEND | LOCK_EX);


$this->submit("invalid_Configure.xml");
# $this->submit("valid_Build.xml");


file_put_contents($this->ConfigFile, $this->Original);
}
}

0 comments on commit 4602d25

Please sign in to comment.