Skip to content

Commit cb22a4e

Browse files
authored
Robot flake fixes 🤖❄️ (#69)
* use random port, always sleep hard before starting editor test * fix up some robot library usage * robot variable docs
1 parent f1d9a31 commit cb22a4e

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

atest/01_Editor.robot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ Editor Should Jump To Definition
9191
Set Tags feature:jump-to-definition
9292
${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol} xpath:(//span[@role="presentation"][contains(., "${symbol}")])[last()]
9393
Mouse Over ${sel}
94-
Run Keyword If "${OS}" == "Windows" Sleep 10s
94+
Sleep 10s
95+
Mouse Over ${sel}
9596
Wait Until Keyword Succeeds 10 x 0.1 s Click Element ${sel}
9697
Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel}
9798
${cursor} = Measure Cursor Position

atest/Keywords.robot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ Library SeleniumLibrary
44
Library OperatingSystem
55
Library Process
66
Library String
7+
Library ./Ports.py
78

89

910
*** Keywords ***
1011
Setup Server and Browser
12+
${port} = Get Unused Port
13+
Set Global Variable ${PORT} ${port}
14+
Set Global Variable ${URL} http://localhost:${PORT}${BASE}
1115
${accel} = Evaluate "COMMAND" if "${OS}" == "Darwin" else "CTRL"
1216
Set Global Variable ${ACCEL} ${accel}
1317
${token} = Generate Random String

atest/Ports.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
""" get a random port
2+
"""
3+
import socket
4+
5+
6+
def get_unused_port():
7+
""" Get an unused port by trying to listen to any random port.
8+
9+
Probably could introduce race conditions if inside a tight loop.
10+
"""
11+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
12+
sock.bind(("localhost", 0))
13+
sock.listen(1)
14+
port = sock.getsockname()[1]
15+
sock.close()
16+
return port

atest/Variables.robot

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
*** Variables ***
2-
${PORT} 18888
32
${SPLASH} id:jupyterlab-splash
3+
4+
# to help catch hard-coded paths
45
${BASE} /@est/
5-
${URL} http://localhost:${PORT}${BASE}
6+
7+
# override with `python scripts/atest.py --variable HEADLESS:0`
68
${HEADLESS} 1

0 commit comments

Comments
 (0)