Skip to content

Commit

Permalink
Reformat test dependencies (#2664)
Browse files Browse the repository at this point in the history
One of the [oldest issues](#280)
relates to the poor design of the CDash test suite. Many tests have
implicit dependencies upon one another. Out of an abundance of caution,
dependencies were added between all of the legacy tests to ensure that
they continue to run in the expected order, while allowing new tests to
run in parallel. As the number of new parallelizable tests has grown,
the dependency structure has become unmanageable. The eventual solution
is to write independent tests whenever possible, using
[`FIXTURES_REQUIRED`](https://cmake.org/cmake/help/latest/prop_test/FIXTURES_REQUIRED.html)
in combination with
[`RESOURCE_LOCK`](https://cmake.org/cmake/help/latest/prop_test/RESOURCE_LOCK.html)
for cases where tests need to have exclusive access to the `.env` or
database. This PR is a stepping stone towards that goal by removing
unnecessary test dependencies and creating dedicated places to put new
independent tests.
  • Loading branch information
williamjallen authored Jan 16, 2025
1 parent 7da65b4 commit 3fa5cc4
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 390 deletions.
236 changes: 139 additions & 97 deletions app/cdash/tests/CMakeLists.txt

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions tests/Feature/GraphQL/BuildTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,22 +460,24 @@ public function testMultipleBasicWarningsAndBasicErrors(): void
*/
public function testBasicBuildFiltering(): void
{
/** @var array<Build> $builds */
$builds = [];
for ($i = 0; $i < 4; $i++) {
$this->project->builds()->create([
'name' => "build{$i}",
$builds[] = $this->project->builds()->create([
'name' => "build{$i}" . Str::uuid()->toString(),
'uuid' => Str::uuid()->toString(),
]);
}

$this->graphQL('
query {
query($buildname: String) {
projects {
edges {
node {
name
builds(filters: {
eq: {
name: "build2"
name: $buildname
}
}) {
edges {
Expand All @@ -488,7 +490,9 @@ public function testBasicBuildFiltering(): void
}
}
}
')->assertJson([
', [
'buildname' => $builds[2]->name,
])->assertJson([
'data' => [
'projects' => [
'edges' => [
Expand All @@ -499,7 +503,7 @@ public function testBasicBuildFiltering(): void
'edges' => [
[
'node' => [
'name' => 'build2',
'name' => $builds[2]->name,
],
],
],
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/GraphQL/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Project;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTruncation;
use Illuminate\Support\Str;
use Tests\TestCase;
use Tests\Traits\CreatesProjects;
Expand All @@ -13,6 +14,7 @@ class FilterTest extends TestCase
{
use CreatesProjects;
use CreatesUsers;
use DatabaseTruncation;

/**
* @var array<Project>
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/GraphQL/ProjectTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Project;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTruncation;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
use Tests\TestCase;
Expand All @@ -14,6 +15,7 @@ class ProjectTypeTest extends TestCase
{
use CreatesUsers;
use CreatesProjects;
use DatabaseTruncation;

/**
* @var array<Project>
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/GraphQL/SiteTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Project;
use App\Models\Site;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTruncation;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Tests\TestCase;
Expand All @@ -17,6 +18,7 @@ class SiteTypeTest extends TestCase
use CreatesUsers;
use CreatesProjects;
use CreatesSites;
use DatabaseTruncation;

/**
* @var array<Project>
Expand Down
60 changes: 0 additions & 60 deletions tests/Feature/IncreaseSiteInformationCPUColumnsSizeMigration.php

This file was deleted.

127 changes: 0 additions & 127 deletions tests/Feature/MeasurementPositionMigration.php

This file was deleted.

2 changes: 2 additions & 0 deletions tests/Feature/Monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Enums\ClassicPalette;
use App\Enums\HighContrastPalette;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTruncation;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\URL;
use LogicException;
Expand All @@ -15,6 +16,7 @@
class Monitor extends TestCase
{
use CreatesUsers;
use DatabaseTruncation;

protected User $normal_user;
protected User $admin_user;
Expand Down
3 changes: 3 additions & 0 deletions tests/Feature/PurgeUnusedProjectsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use CDash\Model\Build;
use CDash\Model\Project;
use Illuminate\Foundation\Testing\DatabaseTruncation;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class PurgeUnusedProjectsCommand extends TestCase
{
use DatabaseTruncation;

private Project $project1;
private Project $project2;

Expand Down
48 changes: 0 additions & 48 deletions tests/Feature/RemoveMeasurementCheckboxesMigration.php

This file was deleted.

Loading

0 comments on commit 3fa5cc4

Please sign in to comment.