Skip to content
Merged
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
50 changes: 7 additions & 43 deletions app/Models/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Enums\TestTimeStatusCategory;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
Expand All @@ -19,7 +18,6 @@
*
* @property int $id
* @property int $buildid
* @property int $outputid
* @property string $status 'failed' | 'passed' | 'notrun' TODO: Turn this into a proper enum.
* @property float $time
* @property float $timemean
Expand All @@ -30,14 +28,17 @@
* @property string $testname
* @property ?Carbon $starttime
* @property TestTimeStatusCategory $timestatuscategory
* @property string $path
* @property string $command
* @property string $output
*
* @mixin Builder<Test>
*/
class Test extends Model
{
public $timestamps = false;

protected $table = 'build2test';
protected $table = 'tests';

/**
* @deprecated 08/24/2024 This member variable is deprecated. Use the labels() Eloquent relationship instead.
Expand All @@ -58,7 +59,6 @@ class Test extends Model

protected $fillable = [
'buildid',
'outputid',
'status',
'time',
'timemean',
Expand All @@ -68,12 +68,14 @@ class Test extends Model
'details',
'testname',
'starttime',
'path',
'command',
'output',
];

protected $casts = [
'id' => 'integer',
'buildid' => 'integer',
'outputid' => 'integer',
'time' => 'float',
'timemean' => 'float',
'timestd' => 'float',
Expand All @@ -91,14 +93,6 @@ public function build(): BelongsTo
return $this->belongsTo('App\Models\Build', 'buildid');
}

/**
* @return BelongsTo<TestOutput, $this>
*/
public function testOutput(): BelongsTo
{
return $this->belongsTo('App\Models\TestOutput', 'outputid');
}

/**
* @return HasMany<TestMeasurement, $this>
*/
Expand Down Expand Up @@ -131,36 +125,6 @@ public function testImages(): HasMany
return $this->hasMany(TestImage::class, 'testid');
}

/**
* @return Attribute<?string,null>
*/
protected function path(): Attribute
{
return Attribute::make(
get: fn (mixed $value, array $attributes): ?string => $this->testOutput->path ?? null,
);
}

/**
* @return Attribute<?string,null>
*/
protected function command(): Attribute
{
return Attribute::make(
get: fn (mixed $value, array $attributes): ?string => $this->testOutput->command ?? null,
);
}

/**
* @return Attribute<?string,null>
*/
protected function output(): Attribute
{
return Attribute::make(
get: fn (mixed $value, array $attributes): ?string => $this->testOutput->output ?? null,
);
}

/**
* Add a label to this buildtest.
*
Expand Down
40 changes: 0 additions & 40 deletions app/Models/TestOutput.php

This file was deleted.

11 changes: 3 additions & 8 deletions app/Utils/TestCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use App\Models\Test;
use App\Models\TestImage;
use App\Models\TestMeasurement;
use App\Models\TestOutput;
use Carbon\Carbon;
use CDash\Model\Build;
use CDash\Model\Image;
Expand Down Expand Up @@ -140,23 +139,19 @@ public function create(Build $build): void
}

DB::transaction(function () use ($build): void {
$outputid = TestOutput::select('id')->firstOrCreate([
'path' => $this->testPath,
'command' => $this->testCommand,
'output' => $this->testOutput,
])->id;

// Note: the newstatus column is currently handled in
// ctestparserutils::compute_test_difference. This gets updated when we call
// Build::ComputeTestTiming.
$buildtest = Test::create([
'buildid' => $build->Id,
'outputid' => $outputid,
'status' => $this->testStatus,
'details' => $this->testDetails,
'time' => "$this->buildTestTime",
'testname' => $this->testName,
'starttime' => $this->testStartTime,
'path' => $this->testPath,
'command' => $this->testCommand,
'output' => $this->testOutput,
]);

if ($this->measurements->isNotEmpty()) {
Expand Down
12 changes: 6 additions & 6 deletions app/cdash/tests/test_bazeljson.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testBazelJSON()
$buildtestid = $test_stmt->fetchColumn();

// Verify that only output for the specified test is displayed
$output = Test::findOrFail((int) $buildtestid)->testOutput->output;
$output = Test::findOrFail((int) $buildtestid)->output;

$not_expected = 'Executed 2 out of 2 tests';
if (str_contains($output, $not_expected)) {
Expand Down Expand Up @@ -235,7 +235,7 @@ public function testBazelTestFailed()
$buildtestid = $test_stmt->fetchColumn();

// Verify that all of the build output is displayed.
$output = Test::findOrFail((int) $buildtestid)->testOutput->output;
$output = Test::findOrFail((int) $buildtestid)->output;

$expected = 'FAIL: testDrakeFindResourceOrThrowInInstall (__main__.TestCommonInstall)';
if (!str_contains($output, $expected)) {
Expand Down Expand Up @@ -288,7 +288,7 @@ public function testBazelTimeout()
$buildtestid = $test_stmt->fetchColumn();

// Verify that the 'TIMEOUT' message is displayed
$output = Test::findOrFail((int) $buildtestid)->testOutput->output;
$output = Test::findOrFail((int) $buildtestid)->output;

$expected = 'TIMEOUT';
if (!str_contains($output, $expected)) {
Expand Down Expand Up @@ -511,7 +511,7 @@ public function testShardTestFailures()
$buildtestid = $test_stmt->fetchColumn();

// Verify that the expected output is displayed
$output = Test::findOrFail((int) $buildtestid)->testOutput->output;
$output = Test::findOrFail((int) $buildtestid)->output;

$expected = '//automotive/maliput/multilane:multilane_builder_test';
if (!str_contains($output, $expected)) {
Expand Down Expand Up @@ -540,7 +540,7 @@ public function testShardTestFailures()

// Verify that the expected output is displayed
$test = Test::findOrFail((int) $buildtestid);
$output = $test->testOutput->output;
$output = $test->output;

$expected = 'automotive/maliput/multilane:multilane_lanes_test';
if (!str_contains($output, $expected)) {
Expand Down Expand Up @@ -600,7 +600,7 @@ public function testShardTestTimeout()

// Verify that the expected output is displayed
$test = Test::findOrFail((int) $buildtestid);
$output = $test->testOutput->output;
$output = $test->output;

$expected = 'Note: This is test shard 8 of 10.';
if (!str_contains($output, $expected)) {
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/test_outputcolor.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testOutputColor(): void

// Get test output.
$buildtestid = $this->getIdForTest('colortest_long');
$output = Test::findOrFail((int) $buildtestid)->testOutput->output;
$output = Test::findOrFail((int) $buildtestid)->output;

// Check for expected escape sequences.
if (!str_contains($output, "\x1B[32m")) {
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/test_redundanttests.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testRedundantTests(): void
$test1found = false;
$test2found = false;
foreach ($results as $row) {
$output = Test::findOrFail((int) $row->id)->testOutput?->output;
$output = Test::findOrFail((int) $row->id)->output;
if ($output === "this is a test\n") {
$test1found = true;
}
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/tests/test_truncateoutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testTruncateOutput(): void
build2test.testname = 'curl'");
$buildtestid = $buildtests[0]->id;

$testOutput = Test::findOrFail((int) $buildtestid)->testOutput->output;
$testOutput = Test::findOrFail((int) $buildtestid)->output;
$expected = 'The rest of the test output was removed since it exceeds the threshold';
$this->assertTrue(str_contains($testOutput, $expected));

Expand Down
Loading