Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 904ebea

Browse files
committedOct 5, 2018
Apply CI specific long timeout
* Remove unneeded new empty string * Use timeout 15 for devs, 300 for CI
1 parent 224c775 commit 904ebea

File tree

4 files changed

+32
-21
lines changed

4 files changed

+32
-21
lines changed
 

‎.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ env:
2222
global:
2323
- RUSTFLAGS=--cfg=enable_tooltip_tests
2424
- RUST_BACKTRACE=1
25+
- RLS_TEST_WAIT_FOR_AGES=1

‎appveyor.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ environment:
88
PROJECT_NAME: rls
99
RUSTFLAGS: --cfg=enable_tooltip_tests
1010
RUST_BACKTRACE: 1
11+
RLS_TEST_WAIT_FOR_AGES: 1
1112
matrix:
1213
- TARGET: i686-pc-windows-msvc
1314
CHANNEL: nightly

‎src/actions/post_build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl PostBuildHandler {
9999
warn!("Not reporting: {} {:?}", error, stdout);
100100
} else {
101101
let stdout_msg = if stdout.is_empty() {
102-
"".to_string()
102+
stdout
103103
} else {
104104
format!("({})", stdout)
105105
};

‎tests/tests.rs

+29-20
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ use crate::support::RlsStdout;
2020
use std::io::Write;
2121
use std::time::Duration;
2222

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+
}
2433

2534
#[test]
2635
fn cmd_test_infer_bin() {
@@ -51,7 +60,7 @@ fn cmd_test_infer_bin() {
5160
.unwrap();
5261

5362
let json: Vec<_> = rls
54-
.wait_until_done_indexing(RLS_TIMEOUT)
63+
.wait_until_done_indexing(rls_timeout())
5564
.to_json_messages()
5665
.filter(|json| json["method"] != "window/progress")
5766
.collect();
@@ -63,7 +72,7 @@ fn cmd_test_infer_bin() {
6372
assert_eq!(json[1]["method"], "textDocument/publishDiagnostics");
6473
assert_eq!(json[1]["params"]["diagnostics"][0]["code"], "dead_code");
6574

66-
rls.shutdown(RLS_TIMEOUT);
75+
rls.shutdown(rls_timeout());
6776
}
6877

6978
/// Test includes window/progress regression testing
@@ -159,7 +168,7 @@ fn cmd_test_simple_workspace() {
159168
.unwrap();
160169

161170
let json: Vec<_> = rls
162-
.wait_until_done_indexing(RLS_TIMEOUT)
171+
.wait_until_done_indexing(rls_timeout())
163172
.to_json_messages()
164173
.collect();
165174
assert!(json.len() >= 11);
@@ -198,7 +207,7 @@ fn cmd_test_simple_workspace() {
198207
assert_eq!(json[10]["params"]["title"], "Indexing");
199208

200209
let json = rls
201-
.shutdown(RLS_TIMEOUT)
210+
.shutdown(rls_timeout())
202211
.to_json_messages()
203212
.nth(11)
204213
.expect("No shutdown response received");
@@ -292,7 +301,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() {
292301
.unwrap()
293302
};
294303

295-
let stdout = rls.wait_until_done_indexing(RLS_TIMEOUT);
304+
let stdout = rls.wait_until_done_indexing(rls_timeout());
296305

297306
let lib_diagnostic = rfind_diagnostics_with_uri(&stdout, "library/src/lib.rs");
298307
assert_eq!(
@@ -332,7 +341,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() {
332341
)
333342
.unwrap();
334343

335-
let stdout = rls.wait_until_done_indexing_n(2, RLS_TIMEOUT);
344+
let stdout = rls.wait_until_done_indexing_n(2, rls_timeout());
336345

337346
// lib unit tests have compile errors
338347
let lib_diagnostic = rfind_diagnostics_with_uri(&stdout, "library/src/lib.rs");
@@ -391,7 +400,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() {
391400
)
392401
.unwrap();
393402

394-
let stdout = rls.wait_until_done_indexing_n(3, RLS_TIMEOUT);
403+
let stdout = rls.wait_until_done_indexing_n(3, rls_timeout());
395404
let lib_diagnostic = rfind_diagnostics_with_uri(&stdout, "library/src/lib.rs");
396405
assert_eq!(
397406
lib_diagnostic["params"]["diagnostics"][0]["code"],
@@ -403,7 +412,7 @@ fn cmd_changing_workspace_lib_retains_bin_diagnostics() {
403412
"unused_variables"
404413
);
405414

406-
rls.shutdown(RLS_TIMEOUT);
415+
rls.shutdown(rls_timeout());
407416
}
408417

409418
#[test]
@@ -453,7 +462,7 @@ fn cmd_test_complete_self_crate_name() {
453462
)
454463
.unwrap();
455464

456-
let stdout = rls.wait_until_done_indexing(RLS_TIMEOUT);
465+
let stdout = rls.wait_until_done_indexing(rls_timeout());
457466

458467
let json: Vec<_> = stdout
459468
.to_json_messages()
@@ -497,7 +506,7 @@ fn cmd_test_complete_self_crate_name() {
497506
.to_json_messages()
498507
.any(|json| json["result"][0]["detail"].is_string())
499508
},
500-
RLS_TIMEOUT,
509+
rls_timeout(),
501510
);
502511

503512
let json = stdout
@@ -507,7 +516,7 @@ fn cmd_test_complete_self_crate_name() {
507516

508517
assert_eq!(json["result"][0]["detail"], "pub fn function() -> usize");
509518

510-
rls.shutdown(RLS_TIMEOUT);
519+
rls.shutdown(rls_timeout());
511520
}
512521

513522
#[test]
@@ -587,7 +596,7 @@ fn test_completion_suggests_arguments_in_statements() {
587596
.to_json_messages()
588597
.any(|json| json["result"][0]["detail"].is_string())
589598
},
590-
RLS_TIMEOUT,
599+
rls_timeout(),
591600
);
592601
let json = stdout
593602
.to_json_messages()
@@ -596,7 +605,7 @@ fn test_completion_suggests_arguments_in_statements() {
596605

597606
assert_eq!(json["result"][0]["insertText"], "function()");
598607

599-
rls.shutdown(RLS_TIMEOUT);
608+
rls.shutdown(rls_timeout());
600609
}
601610

602611
#[test]
@@ -667,7 +676,7 @@ fn test_use_statement_completion_doesnt_suggest_arguments() {
667676
.to_json_messages()
668677
.any(|json| json["result"][0]["detail"].is_string())
669678
},
670-
RLS_TIMEOUT,
679+
rls_timeout(),
671680
);
672681
let json = stdout
673682
.to_json_messages()
@@ -676,7 +685,7 @@ fn test_use_statement_completion_doesnt_suggest_arguments() {
676685

677686
assert_eq!(json["result"][0]["insertText"], "function");
678687

679-
rls.shutdown(RLS_TIMEOUT);
688+
rls.shutdown(rls_timeout());
680689
}
681690

682691
/// 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() {
734743
.unwrap();
735744

736745
let publish = rls
737-
.wait_until_done_indexing(RLS_TIMEOUT)
746+
.wait_until_done_indexing(rls_timeout())
738747
.to_json_messages()
739748
.rfind(|m| m["method"] == "textDocument/publishDiagnostics")
740749
.expect("No publishDiagnostics");
@@ -776,7 +785,7 @@ fn cmd_dependency_typo_and_fix() {
776785
.unwrap();
777786

778787
let publish = rls
779-
.wait_until_done_indexing_n(2, RLS_TIMEOUT)
788+
.wait_until_done_indexing_n(2, rls_timeout())
780789
.to_json_messages()
781790
.rfind(|m| m["method"] == "textDocument/publishDiagnostics")
782791
.expect("No publishDiagnostics");
@@ -808,7 +817,7 @@ fn cmd_dependency_typo_and_fix() {
808817
.unwrap();
809818

810819
let publish = rls
811-
.wait_until_done_indexing_n(3, RLS_TIMEOUT)
820+
.wait_until_done_indexing_n(3, rls_timeout())
812821
.to_json_messages()
813822
.rfind(|m| m["method"] == "textDocument/publishDiagnostics")
814823
.expect("No publishDiagnostics");
@@ -824,5 +833,5 @@ fn cmd_dependency_typo_and_fix() {
824833
None
825834
);
826835

827-
rls.shutdown(RLS_TIMEOUT);
836+
rls.shutdown(rls_timeout());
828837
}

0 commit comments

Comments
 (0)
This repository has been archived.