@@ -700,11 +700,27 @@ class TestRunner {
700700 /**
701701 * Clean up existing test resources before running
702702 */
703- async cleanupExistingResources ( ) {
703+ async cleanupExistingResources ( suiteNames = [ ] ) {
704704 this . log ( "🧹 Checking for existing test functions..." , "warn" ) ;
705705
706706 const { v1ProjectId, v2ProjectId } = this . getProjectIds ( ) ;
707- const projects = [ v1ProjectId , v2ProjectId ] ;
707+
708+ // Determine which project to clean based on suite names
709+ const projects = new Set ( ) ;
710+ if ( suiteNames . length === 0 ) {
711+ // If no suites specified, clean both (for --cleanup-orphaned flag)
712+ projects . add ( v1ProjectId ) ;
713+ projects . add ( v2ProjectId ) ;
714+ } else {
715+ // Only clean the project(s) for the suite(s) being run
716+ for ( const suiteName of suiteNames ) {
717+ if ( suiteName . startsWith ( 'v1_' ) ) {
718+ projects . add ( v1ProjectId ) ;
719+ } else if ( suiteName . startsWith ( 'v2_' ) ) {
720+ projects . add ( v2ProjectId ) ;
721+ }
722+ }
723+ }
708724
709725 for ( const projectId of projects ) {
710726 this . log ( ` Checking project: ${ projectId } ` , "warn" ) ;
@@ -781,8 +797,8 @@ class TestRunner {
781797 }
782798 }
783799
784- // Clean up orphaned Cloud Tasks queues
785- await this . cleanupOrphanedCloudTasksQueues ( ) ;
800+ // Clean up orphaned Cloud Tasks queues (only for relevant projects)
801+ await this . cleanupOrphanedCloudTasksQueues ( suiteNames ) ;
786802
787803 // Clean up generated directory
788804 if ( existsSync ( GENERATED_DIR ) ) {
@@ -794,11 +810,28 @@ class TestRunner {
794810 /**
795811 * Clean up orphaned Cloud Tasks queues from previous test runs
796812 */
797- async cleanupOrphanedCloudTasksQueues ( ) {
813+ async cleanupOrphanedCloudTasksQueues ( suiteNames = [ ] ) {
798814 this . log ( " Checking for orphaned Cloud Tasks queues..." , "warn" ) ;
799815
800816 const { v1ProjectId, v2ProjectId } = this . getProjectIds ( ) ;
801- const projects = [ v1ProjectId , v2ProjectId ] ;
817+
818+ // Determine which project to clean based on suite names
819+ const projects = new Set ( ) ;
820+ if ( suiteNames . length === 0 ) {
821+ // If no suites specified, clean both (for --cleanup-orphaned flag)
822+ projects . add ( v1ProjectId ) ;
823+ projects . add ( v2ProjectId ) ;
824+ } else {
825+ // Only clean the project(s) for the suite(s) being run
826+ for ( const suiteName of suiteNames ) {
827+ if ( suiteName . startsWith ( 'v1_' ) ) {
828+ projects . add ( v1ProjectId ) ;
829+ } else if ( suiteName . startsWith ( 'v2_' ) ) {
830+ projects . add ( v2ProjectId ) ;
831+ }
832+ }
833+ }
834+
802835 const region = DEFAULT_REGION ;
803836
804837 for ( const projectId of projects ) {
@@ -912,9 +945,9 @@ class TestRunner {
912945 }
913946 this . log ( "" ) ;
914947
915- // Clean up existing resources unless skipped
948+ // Clean up existing resources unless skipped (only for relevant projects)
916949 if ( ! this . skipCleanup ) {
917- await this . cleanupExistingResources ( ) ;
950+ await this . cleanupExistingResources ( suiteNames ) ;
918951 }
919952
920953 // SDK should be pre-packed (by Cloud Build or manually)
0 commit comments