Skip to content

Commit

Permalink
test: Try to fix flaky tests (#2198)
Browse files Browse the repository at this point in the history
  • Loading branch information
fox0430 authored Oct 25, 2024
1 parent 56a991f commit d1c15ab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _#2198: https://github.com/fox0430/moe/pull/2198

Fixed
.....

- `#2198`_ test: Try to fix flaky tests

3 changes: 2 additions & 1 deletion src/moepkg/settings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ proc initLspServerSettings(): LspServerSettings =
result.rustAnalyzer = initLspRustAnalyzerSettings()

proc initLspSettings(): LspSettings =
result.enable = true
when not defined unitTest:
result.enable = true

result.features = initLspFeatureSettings()

Expand Down
2 changes: 2 additions & 0 deletions tests/texmode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ suite "Ex mode: Write command":
const Command = @[ru"w"]
status.exModeCommand(Command)

discard lspClient.kill

suite "Ex mode: Change next buffer command":
test "Change next buffer command 1":
var status = initEditorStatus()
Expand Down
22 changes: 17 additions & 5 deletions tests/tlspclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# #
#[############################################################################]#

import std/[unittest, importutils, os, osproc, options, tables, json]
import std/[unittest, importutils, os, osproc, options, tables, json, strformat]

import pkg/results

Expand Down Expand Up @@ -93,12 +93,22 @@ suite "lsp: restart":
Command = "nimlangserver"
Trace = TraceValue.verbose

var client: LspClient
var
client: LspClient
beforePid: int

setup:
beforePid = -1

if isNimlangserverAvailable():
client = (waitFor initLspClient(Command)).get

teardown:
if beforePid > -1:
discard execCmd(fmt"kill -9 {$beforePid}")

discard client.kill

test "Basic 1":
if not isNimlangserverAvailable():
skip()
Expand All @@ -107,9 +117,9 @@ suite "lsp: restart":
let params = initInitializeParams(ServerName, "/", Trace)
check (waitFor client.initialize(BufferId, params)).isOk

let
beforePid = client.serverProcessId
beforeLogLen = client.log.len
beforePid = client.serverProcessId

let beforeLogLen = client.log.len

check client.running

Expand Down Expand Up @@ -1183,6 +1193,8 @@ suite "lsp: Send requests":
if dirExists(rootDir):
removeDir(rootDir)

discard client.kill

test "Send initialize":
if not isNimlangserverAvailable():
skip()
Expand Down
6 changes: 3 additions & 3 deletions tests/tlsphandler.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1883,11 +1883,11 @@ suite "lsp: handleLspResponse":
assert status.lspInitialize(workspaceRoot, LangId).isOk

var isTimeout = true
for _ in 0 .. 100:
const Timeout = 100
for _ in 0 .. 120:
const Timeout = 1000
let readable = lspClient.readable(Timeout).get
if not readable:
sleep 100
sleep 1000
else:
status.handleLspResponse

Expand Down

0 comments on commit d1c15ab

Please sign in to comment.