@@ -700,11 +700,27 @@ class TestRunner {
700
700
/**
701
701
* Clean up existing test resources before running
702
702
*/
703
- async cleanupExistingResources ( ) {
703
+ async cleanupExistingResources ( suiteNames = [ ] ) {
704
704
this . log ( "🧹 Checking for existing test functions..." , "warn" ) ;
705
705
706
706
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
+ }
708
724
709
725
for ( const projectId of projects ) {
710
726
this . log ( ` Checking project: ${ projectId } ` , "warn" ) ;
@@ -781,8 +797,8 @@ class TestRunner {
781
797
}
782
798
}
783
799
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 ) ;
786
802
787
803
// Clean up generated directory
788
804
if ( existsSync ( GENERATED_DIR ) ) {
@@ -794,11 +810,28 @@ class TestRunner {
794
810
/**
795
811
* Clean up orphaned Cloud Tasks queues from previous test runs
796
812
*/
797
- async cleanupOrphanedCloudTasksQueues ( ) {
813
+ async cleanupOrphanedCloudTasksQueues ( suiteNames = [ ] ) {
798
814
this . log ( " Checking for orphaned Cloud Tasks queues..." , "warn" ) ;
799
815
800
816
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
+
802
835
const region = DEFAULT_REGION ;
803
836
804
837
for ( const projectId of projects ) {
@@ -912,9 +945,9 @@ class TestRunner {
912
945
}
913
946
this . log ( "" ) ;
914
947
915
- // Clean up existing resources unless skipped
948
+ // Clean up existing resources unless skipped (only for relevant projects)
916
949
if ( ! this . skipCleanup ) {
917
- await this . cleanupExistingResources ( ) ;
950
+ await this . cleanupExistingResources ( suiteNames ) ;
918
951
}
919
952
920
953
// SDK should be pre-packed (by Cloud Build or manually)
0 commit comments