@@ -20,7 +20,16 @@ use crate::support::RlsStdout;
20
20
use std:: io:: Write ;
21
21
use std:: time:: Duration ;
22
22
23
- const RLS_TIMEOUT : Duration = Duration :: from_secs ( 30 ) ;
23
+ /// Returns a timeout for waiting for rls stdout messages
24
+ ///
25
+ /// Env var `RLS_TEST_WAIT_FOR_AGES` allows super long waiting for CI
26
+ fn rls_timeout ( ) -> Duration {
27
+ Duration :: from_secs ( if std:: env:: var ( "RLS_TEST_WAIT_FOR_AGES" ) . is_ok ( ) {
28
+ 300
29
+ } else {
30
+ 15
31
+ } )
32
+ }
24
33
25
34
#[ test]
26
35
fn cmd_test_infer_bin ( ) {
@@ -51,7 +60,7 @@ fn cmd_test_infer_bin() {
51
60
. unwrap ( ) ;
52
61
53
62
let json: Vec < _ > = rls
54
- . wait_until_done_indexing ( RLS_TIMEOUT )
63
+ . wait_until_done_indexing ( rls_timeout ( ) )
55
64
. to_json_messages ( )
56
65
. filter ( |json| json[ "method" ] != "window/progress" )
57
66
. collect ( ) ;
@@ -63,7 +72,7 @@ fn cmd_test_infer_bin() {
63
72
assert_eq ! ( json[ 1 ] [ "method" ] , "textDocument/publishDiagnostics" ) ;
64
73
assert_eq ! ( json[ 1 ] [ "params" ] [ "diagnostics" ] [ 0 ] [ "code" ] , "dead_code" ) ;
65
74
66
- rls. shutdown ( RLS_TIMEOUT ) ;
75
+ rls. shutdown ( rls_timeout ( ) ) ;
67
76
}
68
77
69
78
/// Test includes window/progress regression testing
@@ -159,7 +168,7 @@ fn cmd_test_simple_workspace() {
159
168
. unwrap ( ) ;
160
169
161
170
let json: Vec < _ > = rls
162
- . wait_until_done_indexing ( RLS_TIMEOUT )
171
+ . wait_until_done_indexing ( rls_timeout ( ) )
163
172
. to_json_messages ( )
164
173
. collect ( ) ;
165
174
assert ! ( json. len( ) >= 11 ) ;
@@ -198,7 +207,7 @@ fn cmd_test_simple_workspace() {
198
207
assert_eq ! ( json[ 10 ] [ "params" ] [ "title" ] , "Indexing" ) ;
199
208
200
209
let json = rls
201
- . shutdown ( RLS_TIMEOUT )
210
+ . shutdown ( rls_timeout ( ) )
202
211
. to_json_messages ( )
203
212
. nth ( 11 )
204
213
. expect ( "No shutdown response received" ) ;
@@ -292,7 +301,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() {
292
301
. unwrap ( )
293
302
} ;
294
303
295
- let stdout = rls. wait_until_done_indexing ( RLS_TIMEOUT ) ;
304
+ let stdout = rls. wait_until_done_indexing ( rls_timeout ( ) ) ;
296
305
297
306
let lib_diagnostic = rfind_diagnostics_with_uri ( & stdout, "library/src/lib.rs" ) ;
298
307
assert_eq ! (
@@ -332,7 +341,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() {
332
341
)
333
342
. unwrap ( ) ;
334
343
335
- let stdout = rls. wait_until_done_indexing_n ( 2 , RLS_TIMEOUT ) ;
344
+ let stdout = rls. wait_until_done_indexing_n ( 2 , rls_timeout ( ) ) ;
336
345
337
346
// lib unit tests have compile errors
338
347
let lib_diagnostic = rfind_diagnostics_with_uri ( & stdout, "library/src/lib.rs" ) ;
@@ -391,7 +400,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() {
391
400
)
392
401
. unwrap ( ) ;
393
402
394
- let stdout = rls. wait_until_done_indexing_n ( 3 , RLS_TIMEOUT ) ;
403
+ let stdout = rls. wait_until_done_indexing_n ( 3 , rls_timeout ( ) ) ;
395
404
let lib_diagnostic = rfind_diagnostics_with_uri ( & stdout, "library/src/lib.rs" ) ;
396
405
assert_eq ! (
397
406
lib_diagnostic[ "params" ] [ "diagnostics" ] [ 0 ] [ "code" ] ,
@@ -403,7 +412,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() {
403
412
"unused_variables"
404
413
) ;
405
414
406
- rls. shutdown ( RLS_TIMEOUT ) ;
415
+ rls. shutdown ( rls_timeout ( ) ) ;
407
416
}
408
417
409
418
#[ test]
@@ -453,7 +462,7 @@ fn cmd_test_complete_self_crate_name() {
453
462
)
454
463
. unwrap ( ) ;
455
464
456
- let stdout = rls. wait_until_done_indexing ( RLS_TIMEOUT ) ;
465
+ let stdout = rls. wait_until_done_indexing ( rls_timeout ( ) ) ;
457
466
458
467
let json: Vec < _ > = stdout
459
468
. to_json_messages ( )
@@ -497,7 +506,7 @@ fn cmd_test_complete_self_crate_name() {
497
506
. to_json_messages ( )
498
507
. any ( |json| json[ "result" ] [ 0 ] [ "detail" ] . is_string ( ) )
499
508
} ,
500
- RLS_TIMEOUT ,
509
+ rls_timeout ( ) ,
501
510
) ;
502
511
503
512
let json = stdout
@@ -507,7 +516,7 @@ fn cmd_test_complete_self_crate_name() {
507
516
508
517
assert_eq ! ( json[ "result" ] [ 0 ] [ "detail" ] , "pub fn function() -> usize" ) ;
509
518
510
- rls. shutdown ( RLS_TIMEOUT ) ;
519
+ rls. shutdown ( rls_timeout ( ) ) ;
511
520
}
512
521
513
522
#[ test]
@@ -587,7 +596,7 @@ fn test_completion_suggests_arguments_in_statements() {
587
596
. to_json_messages ( )
588
597
. any ( |json| json[ "result" ] [ 0 ] [ "detail" ] . is_string ( ) )
589
598
} ,
590
- RLS_TIMEOUT ,
599
+ rls_timeout ( ) ,
591
600
) ;
592
601
let json = stdout
593
602
. to_json_messages ( )
@@ -596,7 +605,7 @@ fn test_completion_suggests_arguments_in_statements() {
596
605
597
606
assert_eq ! ( json[ "result" ] [ 0 ] [ "insertText" ] , "function()" ) ;
598
607
599
- rls. shutdown ( RLS_TIMEOUT ) ;
608
+ rls. shutdown ( rls_timeout ( ) ) ;
600
609
}
601
610
602
611
#[ test]
@@ -667,7 +676,7 @@ fn test_use_statement_completion_doesnt_suggest_arguments() {
667
676
. to_json_messages ( )
668
677
. any ( |json| json[ "result" ] [ 0 ] [ "detail" ] . is_string ( ) )
669
678
} ,
670
- RLS_TIMEOUT ,
679
+ rls_timeout ( ) ,
671
680
) ;
672
681
let json = stdout
673
682
. to_json_messages ( )
@@ -676,7 +685,7 @@ fn test_use_statement_completion_doesnt_suggest_arguments() {
676
685
677
686
assert_eq ! ( json[ "result" ] [ 0 ] [ "insertText" ] , "function" ) ;
678
687
679
- rls. shutdown ( RLS_TIMEOUT ) ;
688
+ rls. shutdown ( rls_timeout ( ) ) ;
680
689
}
681
690
682
691
/// Test simulates typing in a dependency wrongly in a couple of ways before finally getting it
@@ -734,7 +743,7 @@ fn cmd_dependency_typo_and_fix() {
734
743
. unwrap ( ) ;
735
744
736
745
let publish = rls
737
- . wait_until_done_indexing ( RLS_TIMEOUT )
746
+ . wait_until_done_indexing ( rls_timeout ( ) )
738
747
. to_json_messages ( )
739
748
. rfind ( |m| m[ "method" ] == "textDocument/publishDiagnostics" )
740
749
. expect ( "No publishDiagnostics" ) ;
@@ -776,7 +785,7 @@ fn cmd_dependency_typo_and_fix() {
776
785
. unwrap ( ) ;
777
786
778
787
let publish = rls
779
- . wait_until_done_indexing_n ( 2 , RLS_TIMEOUT )
788
+ . wait_until_done_indexing_n ( 2 , rls_timeout ( ) )
780
789
. to_json_messages ( )
781
790
. rfind ( |m| m[ "method" ] == "textDocument/publishDiagnostics" )
782
791
. expect ( "No publishDiagnostics" ) ;
@@ -808,7 +817,7 @@ fn cmd_dependency_typo_and_fix() {
808
817
. unwrap ( ) ;
809
818
810
819
let publish = rls
811
- . wait_until_done_indexing_n ( 3 , RLS_TIMEOUT )
820
+ . wait_until_done_indexing_n ( 3 , rls_timeout ( ) )
812
821
. to_json_messages ( )
813
822
. rfind ( |m| m[ "method" ] == "textDocument/publishDiagnostics" )
814
823
. expect ( "No publishDiagnostics" ) ;
@@ -824,5 +833,5 @@ fn cmd_dependency_typo_and_fix() {
824
833
None
825
834
) ;
826
835
827
- rls. shutdown ( RLS_TIMEOUT ) ;
836
+ rls. shutdown ( rls_timeout ( ) ) ;
828
837
}
0 commit comments