@@ -585,9 +585,9 @@ impl HelperState {
585
585
}
586
586
587
587
fn find_jobserver_auth ( var : & str ) -> Option < ( & str , usize ) > {
588
- [ "--jobserver-fds =" , "--jobserver-auth =" ]
588
+ [ "--jobserver-auth =" , "--jobserver-fds =" ]
589
589
. iter ( )
590
- . map ( |& arg| var. find ( arg) . map ( |pos| ( arg, pos) ) )
590
+ . map ( |& arg| var. rfind ( arg) . map ( |pos| ( arg, pos) ) )
591
591
. find_map ( |pos| pos)
592
592
}
593
593
@@ -597,3 +597,32 @@ fn no_helper_deadlock() {
597
597
let _y = x. clone ( ) ;
598
598
std:: mem:: drop ( x. into_helper_thread ( |_| { } ) . unwrap ( ) ) ;
599
599
}
600
+
601
+ #[ test]
602
+ fn test_find_jobserver_auth ( ) {
603
+ let cases = [
604
+ (
605
+ "--jobserver-auth= --jobserver-auth=" ,
606
+ ( "--jobserver-auth=" , 18 ) ,
607
+ ) ,
608
+ (
609
+ "--jobserver-fds= --jobserver-fds=" ,
610
+ ( "--jobserver-fds=" , 17 ) ,
611
+ ) ,
612
+ (
613
+ "--jobserver-auth= --jobserver-fds= --jobserver-auth=" ,
614
+ ( "--jobserver-auth=" , 35 ) ,
615
+ ) ,
616
+ (
617
+ "--jobserver-fds= --jobserver-auth= --jobserver-fds=" ,
618
+ ( "--jobserver-auth=" , 17 ) ,
619
+ ) ,
620
+ ] ;
621
+ for ( var, expected) in cases {
622
+ let actual = find_jobserver_auth ( var) . unwrap ( ) ;
623
+ assert_eq ! (
624
+ actual, expected,
625
+ "expect {expected:?}, got {actual:?}, input `{var:?}`"
626
+ ) ;
627
+ }
628
+ }
0 commit comments