From fbd51cb74eadef765d266d975bea52847cb07191 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Thu, 18 Nov 2021 13:07:26 +0100 Subject: [PATCH] add time.Sleep to cross-module tests --- internal/langserver/handlers/code_lens_test.go | 4 ++++ internal/langserver/handlers/complete_test.go | 6 ++---- internal/langserver/handlers/go_to_ref_target_test.go | 4 ++++ internal/langserver/handlers/references_test.go | 4 ++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/langserver/handlers/code_lens_test.go b/internal/langserver/handlers/code_lens_test.go index 05d918ccd..1c252c431 100644 --- a/internal/langserver/handlers/code_lens_test.go +++ b/internal/langserver/handlers/code_lens_test.go @@ -5,6 +5,7 @@ import ( "fmt" "path/filepath" "testing" + "time" "github.com/hashicorp/go-version" tfjson "github.com/hashicorp/terraform-json" @@ -261,6 +262,9 @@ variable "instances" { type = number } `, submodUri.URI())}) + // TODO remove once we support synchronous dependent tasks + // See https://github.com/hashicorp/terraform-ls/issues/719 + time.Sleep(2 * time.Second) ls.CallAndExpectResponse(t, &langserver.CallRequest{ Method: "textDocument/codeLens", ReqParams: fmt.Sprintf(`{ diff --git a/internal/langserver/handlers/complete_test.go b/internal/langserver/handlers/complete_test.go index 142e7f455..62cc0179c 100644 --- a/internal/langserver/handlers/complete_test.go +++ b/internal/langserver/handlers/complete_test.go @@ -717,11 +717,9 @@ output "test" { } }`, mainCfg, tmpDir.URI())}) - // module manifest-dependent tasks are scheduled & executed - // asynchronously and we currently have no way of waiting - // for them to complete. // TODO remove once we support synchronous dependent tasks - time.Sleep(1500 * time.Millisecond) + // See https://github.com/hashicorp/terraform-ls/issues/719 + time.Sleep(2 * time.Second) ls.CallAndExpectResponse(t, &langserver.CallRequest{ Method: "textDocument/completion", diff --git a/internal/langserver/handlers/go_to_ref_target_test.go b/internal/langserver/handlers/go_to_ref_target_test.go index ef14ed9bc..64c137600 100644 --- a/internal/langserver/handlers/go_to_ref_target_test.go +++ b/internal/langserver/handlers/go_to_ref_target_test.go @@ -4,6 +4,7 @@ import ( "fmt" "path/filepath" "testing" + "time" "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-ls/internal/langserver" @@ -154,6 +155,9 @@ func TestDefinition_moduleInputToVariable(t *testing.T) { "uri": "%s/main.tf" } }`, modUri.URI())}) + // TODO remove once we support synchronous dependent tasks + // See https://github.com/hashicorp/terraform-ls/issues/719 + time.Sleep(2 * time.Second) ls.CallAndExpectResponse(t, &langserver.CallRequest{ Method: "textDocument/definition", ReqParams: fmt.Sprintf(`{ diff --git a/internal/langserver/handlers/references_test.go b/internal/langserver/handlers/references_test.go index 8dc187fff..051499f47 100644 --- a/internal/langserver/handlers/references_test.go +++ b/internal/langserver/handlers/references_test.go @@ -4,6 +4,7 @@ import ( "fmt" "path/filepath" "testing" + "time" "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-ls/internal/langserver" @@ -178,6 +179,9 @@ variable "instances" { "uri": "%s/main.tf" } }`, submodUri.URI())}) + // TODO remove once we support synchronous dependent tasks + // See https://github.com/hashicorp/terraform-ls/issues/719 + time.Sleep(2 * time.Second) ls.CallAndExpectResponse(t, &langserver.CallRequest{ Method: "textDocument/references", ReqParams: fmt.Sprintf(`{