diff --git a/app/Http/Controllers/BuildController.php b/app/Http/Controllers/BuildController.php index 4b25552a74..667fcefb78 100644 --- a/app/Http/Controllers/BuildController.php +++ b/app/Http/Controllers/BuildController.php @@ -266,11 +266,11 @@ public function apiBuildSummary(): JsonResponse foreach ($e_errors as $error_array) { $error_response = []; $error_response['logline'] = $error_array['logline']; - $error_response['text'] = $error_array['text']; + $error_response['text'] = $error_array['stdoutput']; $error_response['sourcefile'] = $error_array['sourcefile']; $error_response['sourceline'] = $error_array['sourceline']; - $error_response['precontext'] = $error_array['precontext']; - $error_response['postcontext'] = $error_array['postcontext']; + $error_response['precontext'] = ''; + $error_response['postcontext'] = ''; $errors_response[] = $error_response; } @@ -292,11 +292,11 @@ public function apiBuildSummary(): JsonResponse foreach ($e_warnings as $error_array) { $warning_response = []; $warning_response['logline'] = $error_array['logline']; - $warning_response['text'] = $error_array['text']; + $warning_response['text'] = $error_array['stdoutput']; $warning_response['sourcefile'] = $error_array['sourcefile']; $warning_response['sourceline'] = $error_array['sourceline']; - $warning_response['precontext'] = $error_array['precontext']; - $warning_response['postcontext'] = $error_array['postcontext']; + $warning_response['precontext'] = ''; + $warning_response['postcontext'] = ''; $warnings_response[] = $warning_response; } diff --git a/app/Http/Controllers/BuildPropertiesController.php b/app/Http/Controllers/BuildPropertiesController.php index a0a869e833..9876b18df2 100644 --- a/app/Http/Controllers/BuildPropertiesController.php +++ b/app/Http/Controllers/BuildPropertiesController.php @@ -227,7 +227,7 @@ private function get_defects_for_builds() $valid_defect = true; // Query builderror table. $sql = - "SELECT buildid, text AS descr + "SELECT buildid, stderror AS descr FROM builderror WHERE type = $type AND buildid IN $placeholder_str"; diff --git a/app/Models/BasicBuildAlert.php b/app/Models/BasicBuildAlert.php index 38fe884277..76ebea3251 100644 --- a/app/Models/BasicBuildAlert.php +++ b/app/Models/BasicBuildAlert.php @@ -3,6 +3,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; /** @@ -10,11 +11,10 @@ * @property int $buildid * @property int $type * @property int $logline - * @property string $text + * @property string $stdoutput + * @property string $stderror * @property string $sourcefile * @property int $sourceline - * @property string|null $precontext - * @property string|null $postcontext * @property int $repeatcount * @property bool $newstatus * @@ -30,11 +30,10 @@ class BasicBuildAlert extends Model 'buildid', 'type', 'logline', - 'text', + 'stdoutput', + 'stderror', 'sourcefile', 'sourceline', - 'precontext', - 'postcontext', 'repeatcount', 'newstatus', ]; @@ -43,9 +42,30 @@ class BasicBuildAlert extends Model 'buildid' => 'integer', 'type' => 'integer', // TODO: Convert this to an enum 'logline' => 'integer', - 'text' => 'string', + 'stdoutput' => 'string', + 'stderror' => 'string', 'sourceline' => 'integer', 'repeatcount' => 'integer', 'newstatus' => 'boolean', ]; + + /** + * @return Attribute + */ + protected function precontext(): Attribute + { + return Attribute::make( + get: fn (mixed $value, array $attributes): null => null, + ); + } + + /** + * @return Attribute + */ + protected function postcontext(): Attribute + { + return Attribute::make( + get: fn (mixed $value, array $attributes): null => null, + ); + } } diff --git a/app/Utils/RepositoryUtils.php b/app/Utils/RepositoryUtils.php index da32bb0d82..83def0ec23 100644 --- a/app/Utils/RepositoryUtils.php +++ b/app/Utils/RepositoryUtils.php @@ -547,9 +547,9 @@ private static function get_email_summary(int $buildid, array $errors, $errorkey $info = ''; if (strlen($error->sourcefile) > 0) { $info .= "{$error->sourcefile} line {$error->sourceline} ({$serverURI}/viewBuildError.php?buildid={$buildid})"; - $info .= "{$error->text}\n"; + $info .= "{$error->stderror}\n"; } else { - $info .= "{$error->text}\n{$error->postcontext}\n"; + $info .= "{$error->stderror}\n"; } $information .= mb_substr($info, 0, $maxchars); } @@ -595,9 +595,9 @@ private static function get_email_summary(int $buildid, array $errors, $errorkey $info = ''; if (strlen($warning->sourcefile) > 0) { $info .= "{$warning->sourcefile} line {$warning->sourceline} ({$serverURI}/viewBuildError.php?type=1&buildid={$buildid})\n"; - $info .= "{$warning->text}\n"; + $info .= "{$warning->stderror}\n"; } else { - $info .= "{$warning->text}\n{$warning->postcontext}\n"; + $info .= "{$warning->stderror}\n"; } $information .= substr($info, 0, $maxchars); } diff --git a/app/Utils/SubmissionUtils.php b/app/Utils/SubmissionUtils.php index e6a0e466ad..a0bf4b78b9 100644 --- a/app/Utils/SubmissionUtils.php +++ b/app/Utils/SubmissionUtils.php @@ -172,7 +172,7 @@ public static function compute_error_difference($buildid, $previousbuildid, $war WHERE builderror_previous.buildid = :previousbuildid AND builderror_previous.type = builderror.type - AND builderror_previous.text = builderror.text + AND builderror_previous.stderror = builderror.stderror AND builderror_previous.sourcefile = builderror.sourcefile AND builderror_previous.sourceline = builderror.sourceline ) @@ -230,7 +230,7 @@ public static function compute_error_difference($buildid, $previousbuildid, $war WHERE builderror.buildid = :buildid AND builderror_previous.type = builderror.type - AND builderror_previous.text = builderror.text + AND builderror_previous.stderror = builderror.stderror AND builderror_previous.sourcefile = builderror.sourcefile AND builderror_previous.sourceline = builderror.sourceline ) diff --git a/app/cdash/app/Model/Build.php b/app/cdash/app/Model/Build.php index cb34973b28..e62449b640 100644 --- a/app/cdash/app/Model/Build.php +++ b/app/cdash/app/Model/Build.php @@ -548,7 +548,7 @@ public function GetResolvedBuildErrors(int $type): PDOStatement|false WHERE builderror.buildid = ? AND builderror_previous.type = builderror.type - AND builderror_previous.text = builderror.text + AND builderror_previous.stderror = builderror.stderror AND builderror_previous.sourcefile = builderror.sourcefile AND builderror_previous.sourceline = builderror.sourceline ) diff --git a/app/cdash/app/Model/BuildError.php b/app/cdash/app/Model/BuildError.php index d8f97d2d79..6b69fe0d6e 100644 --- a/app/cdash/app/Model/BuildError.php +++ b/app/cdash/app/Model/BuildError.php @@ -51,13 +51,12 @@ public function Insert(): void 'buildid' => (int) $this->BuildId, 'type' => $this->Type, 'logline' => (int) $this->LogLine, - 'text' => $this->Text, 'sourcefile' => $this->SourceFile ?? '', 'sourceline' => (int) $this->SourceLine, - 'precontext' => $this->PreContext, - 'postcontext' => $this->PostContext, 'repeatcount' => (int) $this->RepeatCount, 'newstatus' => 0, + 'stdoutput' => $this->PreContext . $this->Text . $this->PostContext, + 'stderror' => $this->Text, ]); } @@ -74,7 +73,7 @@ private static function GetSourceFile(array $data): array // Detect if the source directory has already been replaced by CTest // with /.../. If so, sourcefile is already a relative path from the // root of the source tree. - if (str_contains($data['text'], '/.../')) { + if (str_contains($data['stdoutput'], '/.../')) { $parts = explode('/', $data['sourcefile']); $sourceFile['file'] = array_pop($parts); $sourceFile['directory'] = implode('/', $parts); @@ -110,9 +109,9 @@ public static function marshal(array $data, Project $project, $revision): array 'new' => (int) ($data['newstatus'] ?? -1), 'logline' => (int) $data['logline'], 'cvsurl' => RepositoryUtils::get_diff_url($project->Id, $project->CvsUrl, $sourceFile['directory'], $sourceFile['file'], $revision), - 'precontext' => RepositoryUtils::linkify_compiler_output($project->CvsUrl, $source_dir, $revision, $data['precontext']), - 'text' => RepositoryUtils::linkify_compiler_output($project->CvsUrl, $source_dir, $revision, $data['text']), - 'postcontext' => RepositoryUtils::linkify_compiler_output($project->CvsUrl, $source_dir, $revision, $data['postcontext']), + 'precontext' => '', + 'text' => RepositoryUtils::linkify_compiler_output($project->CvsUrl, $source_dir, $revision, $data['stdoutput']), + 'postcontext' => '', 'sourcefile' => $data['sourcefile'], 'sourceline' => $data['sourceline'], ]; diff --git a/app/cdash/tests/case/CDash/Model/BuildErrorTest.php b/app/cdash/tests/case/CDash/Model/BuildErrorTest.php index 37de7fbee7..2befc23e8a 100644 --- a/app/cdash/tests/case/CDash/Model/BuildErrorTest.php +++ b/app/cdash/tests/case/CDash/Model/BuildErrorTest.php @@ -37,23 +37,21 @@ public function testMarshalBuildError(): void $input_data = [ 'logline' => 16, 'newstatus' => 1, - 'precontext' => "Scanning dependencies of target main\n[ 83%] Building CXX object src/CMakeFiles/main.dir/main.cpp.o\n/.../foo/src/main.cpp: In function `int main(int, char**)`:", - 'postcontext' => " asdf = 0;\n ^\n[100%] Linking CXX executable main", 'sourcefile' => 'src/main.cpp', 'sourceline' => '2', - 'text' => '/.../foo/src/main.cpp:2:3: error: `asdf` not declared in this scope', + 'stdoutput' => "Scanning dependencies of target main\n[ 83%] Building CXX object src/CMakeFiles/main.dir/main.cpp.o\n/.../foo/src/main.cpp: In function `int main(int, char**)`:/.../foo/src/main.cpp:2:3: error: `asdf` not declared in this scope asdf = 0;\n ^\n[100%] Linking CXX executable main", ]; $this->mock_project->CvsUrl = 'https://github.com/FooCo/foo'; $marshaled = BuildError::marshal($input_data, $this->mock_project, '12'); $expected = [ - 'new' => '1', - 'logline' => '16', + 'new' => 1, + 'logline' => 16, 'cvsurl' => 'https://github.com/FooCo/foo/blob/12/src/main.cpp', - 'precontext' => "Scanning dependencies of target main\n[ 83%] Building CXX object src/CMakeFiles/main.dir/main.cpp.o\n/.../foo/src/main.cpp: In function `int main(int, char**)`:", - 'text' => "src/main.cpp:2:3: error: `asdf` not declared in this scope", - 'postcontext' => " asdf = 0;\n ^\n[100%] Linking CXX executable main", + 'precontext' => '', + 'text' => "Scanning dependencies of target main\n[ 83%] Building CXX object src/CMakeFiles/main.dir/main.cpp.o\n/.../foo/src/main.cpp: In function `int main(int, char**)`:src/main.cpp:2:3: error: `asdf` not declared in this scope asdf = 0;\n ^\n[100%] Linking CXX executable main", + 'postcontext' => '', 'sourcefile' => 'src/main.cpp', 'sourceline' => '2', ]; diff --git a/database/migrations/2026_01_19_193919_builderror_context_to_stdout.php b/database/migrations/2026_01_19_193919_builderror_context_to_stdout.php new file mode 100644 index 0000000000..6c974702e2 --- /dev/null +++ b/database/migrations/2026_01_19_193919_builderror_context_to_stdout.php @@ -0,0 +1,20 @@ + {{cdash.errortypename}} -

-      
-        

-      
-

+      

     
   
 
diff --git a/resources/js/vue/components/BuildSummary.vue b/resources/js/vue/components/BuildSummary.vue
index a87c9e11d3..5b87668ae1 100644
--- a/resources/js/vue/components/BuildSummary.vue
+++ b/resources/js/vue/components/BuildSummary.vue
@@ -900,18 +900,10 @@
           File: {{ error.sourcefile }}
           Line: {{ error.sourceline }}
         
-        
         
-        
 
         

@@ -952,18 +944,10 @@ File: {{ warning.sourcefile }} Line: {{ warning.sourceline }}
- -

diff --git a/tests/Feature/GraphQL/BuildTypeTest.php b/tests/Feature/GraphQL/BuildTypeTest.php index 608e6f0304..6e939023a3 100644 --- a/tests/Feature/GraphQL/BuildTypeTest.php +++ b/tests/Feature/GraphQL/BuildTypeTest.php @@ -233,11 +233,10 @@ public function testBasicWarningFields(): void $build->basicAlerts()->create([ 'type' => Build::TYPE_WARN, 'logline' => 5, - 'text' => 'def', + 'stdoutput' => 'abc', + 'stderror' => 'def', 'sourcefile' => '/a/b/c', 'sourceline' => 7, - 'precontext' => 'ghi', - 'postcontext' => 'jlk', ]); $this->graphQL(' @@ -286,11 +285,11 @@ public function testBasicWarningFields(): void [ 'node' => [ 'logLine' => 5, - 'text' => 'def', + 'text' => 'abc', 'sourceFile' => '/a/b/c', 'sourceLine' => 7, - 'preContext' => 'ghi', - 'postContext' => 'jlk', + 'preContext' => null, + 'postContext' => null, ], ], ], @@ -316,11 +315,10 @@ public function testBasicErrorFields(): void $build->basicAlerts()->create([ 'type' => Build::TYPE_ERROR, 'logline' => 5, - 'text' => 'def', + 'stdoutput' => 'abc', + 'stderror' => 'def', 'sourcefile' => '/a/b/c', 'sourceline' => 7, - 'precontext' => 'ghi', - 'postcontext' => 'jlk', ]); $this->graphQL(' @@ -372,11 +370,11 @@ public function testBasicErrorFields(): void [ 'node' => [ 'logLine' => 5, - 'text' => 'def', + 'text' => 'abc', 'sourceFile' => '/a/b/c', 'sourceLine' => 7, - 'preContext' => 'ghi', - 'postContext' => 'jlk', + 'preContext' => null, + 'postContext' => null, ], ], ], @@ -401,20 +399,26 @@ public function testMultipleBasicWarningsAndBasicErrors(): void $errors = []; for ($i = 0; $i < 10; $i++) { $warning = [ - 'text' => Str::uuid()->toString(), + 'stdoutput' => Str::uuid()->toString(), + 'stderror' => Str::uuid()->toString(), ]; $error = [ - 'text' => Str::uuid()->toString(), + 'stdoutput' => Str::uuid()->toString(), + 'stderror' => Str::uuid()->toString(), ]; $build->basicAlerts()->create(array_merge($warning, ['type' => Build::TYPE_WARN])); $build->basicAlerts()->create(array_merge($error, ['type' => Build::TYPE_ERROR])); $warnings[] = [ - 'node' => $warning, + 'node' => [ + 'text' => $warning['stdoutput'], + ], ]; $errors[] = [ - 'node' => $error, + 'node' => [ + 'text' => $error['stdoutput'], + ], ]; }