From 733e72778391d76bb936f46a031fb4e32ff2b0e3 Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 5 Jun 2021 22:41:37 +0100 Subject: [PATCH] Refactored validation build script --- .../TargetDescriptionFiles/Validate.php | 57 ------------------- .../ValidateAvr8TargetDescriptionFiles.php | 34 +++++++++++ 2 files changed, 34 insertions(+), 57 deletions(-) delete mode 100644 build/scripts/TargetDescriptionFiles/Validate.php create mode 100644 build/scripts/ValidateAvr8TargetDescriptionFiles.php diff --git a/build/scripts/TargetDescriptionFiles/Validate.php b/build/scripts/TargetDescriptionFiles/Validate.php deleted file mode 100644 index 1da30e59..00000000 --- a/build/scripts/TargetDescriptionFiles/Validate.php +++ /dev/null @@ -1,57 +0,0 @@ -isFile() && $entry->getExtension() == 'xml') { - $output[] = clone $entry; - - } else if ($entry->isDir() && !$entry->isDot()) { - $output = array_merge($output, getXmlFiles($entry->getPathname())); - } - } - - return $output; -} - -$xmlFiles = getXmlFiles(TDF_DIR_PATH); -$failedValidationCount = 0; - -foreach ($xmlFiles as $xmlFile) { - $targetDescriptionFile = new TargetDescriptionFile($xmlFile->getPathname()); - $validationFailures = $targetDescriptionFile->validate(); - - if (!empty($validationFailures)) { - $failedValidationCount++; - - print "\033[31m"; - print "Validation for " . $xmlFile->getFilename() . " failed.\n"; - print "Full path: " . $xmlFile->getRealPath() . "\n"; - print count($validationFailures) . " errors found:\n"; - print implode("\n", $validationFailures); - print "\n\n"; - print "\033[0m"; - - } else { - print "\033[32m"; - print "Validation for " . $xmlFile->getFilename() . " passed.\n"; - print "\033[0m"; - } -} - -print "\n\n"; -print "Validated " . count($xmlFiles) . " TDFs. "; -print (($failedValidationCount > 0) ? "\033[31m" : "\033[32m"); -print $failedValidationCount . " failures." . "\033[0m" . "\n"; -echo "Done\n"; diff --git a/build/scripts/ValidateAvr8TargetDescriptionFiles.php b/build/scripts/ValidateAvr8TargetDescriptionFiles.php new file mode 100644 index 00000000..5100fabb --- /dev/null +++ b/build/scripts/ValidateAvr8TargetDescriptionFiles.php @@ -0,0 +1,34 @@ +validate(); + + if (!empty($validationFailures)) { + $failedValidationCount++; + + print "\033[31m"; + print "Validation for " . $targetDescriptionFile->filePath . " failed.\n"; + print count($validationFailures) . " errors found:\n"; + print implode("\n", $validationFailures); + print "\n\n"; + print "\033[0m"; + + } else { + print "\033[32m"; + print "Validation for " . $targetDescriptionFile->filePath . " passed.\n"; + print "\033[0m"; + } +} + +print "\n\n"; +print "Validated " . count($avr8Tdfs) . " TDFs. "; +print (($failedValidationCount > 0) ? "\033[31m" : "\033[32m"); +print $failedValidationCount . " failures." . "\033[0m" . "\n"; +echo "Done\n";