Skip to content

Language server testing redesign #1846

@anderseknert

Description

@anderseknert

Below are the slowest tests in Regal at the time of writing this (descending from faster to slower). As is easily observed, almost all of them are in the language server. Not because the language server is slow, but because most of them depend on the language server first getting initiated. In other words, these aren't really unit tests. Which isn't necessarily a bad thing! These tests have caught a lot of issues, and sometimes in things we did not intend to test. But while we have an e2e test suite for the linter, we currently don't for the language server. We should create one and have most of these moved there. We should also explore how to best remodel the language server to lend itself better to unit testing, make those changes, and add units tests for every language server feature — preferably in Rego.

This is obviously no small task, so I suggest we deal with this incrementally, and create sub-tasks from this issue as we see fit.

TestLintWithUserConfig,0.22
TestRouteTextDocumentCodeAction,0.23
TestEmbeddedEOPA,0.26
TestTextDocumentSignatureHelp/concat_function_call,0.27
TestCheckAndWarn,0.37
TestHandleTextDocumentCodeAction,0.38
TestProcessBuiltinUpdateExitsOnMissingFile,0.38
TestTextDocumentSignatureHelp/count_function_call,0.38
TestLanguageServerFixRenameParams,0.39
TestLintWithCollectQueryAndAggregates,0.41
TestLoadWorkspaceContents/ignores_changed_cached_files_when_newOnly_is_true,0.41
TestEvalWorkspacePath,0.42
TestTemplateContentsForFile/empty_file_is_templated_based_on_root,0.42
TestTemplateContentsForFile/existing_contents_in_file,0.42
TestHandleTextDocumentCodeActionSourceExplorer,0.46
TestLintWithConfigIgnoreWildcards,0.46
TestTemplateContentsForFile/empty_deeply_nested_file_is_templated_based_on_root,0.46
TestLanguageServerFixRenameParamsWithConflict,0.48
TestLoadWorkspaceContents/loads_valid_rego_files_successfully,0.48
TestTemplateContentsForFileWithUnknownRoot,0.48
TestLoadWorkspaceContents/handles_file_read_permission_errors_gracefully,0.52
TestTextDocumentSignatureHelp,0.52
TestLoadWorkspaceContents/reloads_file_when_disk_content_differs_from_cache,0.54
TestLoadWorkspaceContents/handles_multiple_file_read_permission_errors,0.56
TestTemplateContentsForFile/v1_templating_using_rego_version_setting,0.56
TestLoadWorkspaceContents/continues_processing_when_some_files_have_parse_errors,0.57
TestLoadWorkspaceContents/handles_empty_workspace,0.58
TestLanguageServerFixRenameParamsWhenTargetOutsideRoot,0.59
TestEvalWorkspacePathInternalData,0.63
TestLoadWorkspaceContents/processes_all_files_when_even_with_cached_files,0.63
TestTemplateContentsForFile/existing_contents_on_disk,0.64
TestSendFileDiagnosticsEmptyArrays/parse_errors_only,0.65
TestSendFileDiagnosticsEmptyArrays/lint_errors_only,0.68
TestTemplateContentsForFile/v0_templating_using_rego_version_setting,0.69
TestTemplateContentsForFileInWorkspaceRoot,0.69
TestExecuteCommandOpaFmt/generic_client,0.75
TestNewFileTemplating,0.79
TestTemplateContentsForFile/empty_test_file_is_templated_based_on_root,0.81
TestExecuteCommandOpaFmt/IntelliJ_client,0.82
TestTemplateWorkerRaceConditionWithDidOpen,0.83
TestFormatting,0.87
TestSendFileDiagnosticsEmptyArrays/file_deleted_from_cache,0.9
TestLanguageServerCustomRule,1.06
TestRulesWithMetadataNotReportedForMissingMeta,1.07
TestSendFileDiagnosticsEmptyArrays/both_empty_in_cache,1.14
TestLanguageServerNoWorkspace,1.19
TestLanguageServerParentDirConfig,1.24
TestLanguageServerAggregateViolationFixedAndReintroducedInUnviolatingFileChange,1.71
TestLanguageServerUpdatesAggregateState,1.81
TestLanguageServerLintsUsingAggregateState,2.04
TestLanguageServerCachesEnabledRulesAndUsesDefaultConfig,2.15
TestLanguageServerSingleFile,2.81

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions