Fix race condition in tests

This commit is contained in:
Jonatan Kłosko 2024-09-06 14:58:01 +07:00
parent 4ede27ca69
commit 94f7d3fc89

View file

@ -2122,6 +2122,12 @@ defmodule LivebookWeb.SessionLiveTest do
# Use the standalone runtime, to encapsulate env var changes # Use the standalone runtime, to encapsulate env var changes
Session.set_runtime(session.pid, Runtime.Standalone.new()) Session.set_runtime(session.pid, Runtime.Standalone.new())
# We start the runtime before adding the env var setting,
# otherwise a concurrent embedded runtime server could set PATH
# in this node and the standalone runtime would inherit it
Session.subscribe(session.id)
connect_and_await_runtime(session.pid)
separator = separator =
case :os.type() do case :os.type() do
{:win32, _} -> ";" {:win32, _} -> ";"
@ -2134,7 +2140,6 @@ defmodule LivebookWeb.SessionLiveTest do
attrs = params_for(:env_var, name: "PATH", value: tmp_dir) attrs = params_for(:env_var, name: "PATH", value: tmp_dir)
Settings.set_env_var(attrs) Settings.set_env_var(attrs)
Session.subscribe(session.id)
{:ok, view, _} = live(conn, ~p"/sessions/#{session.id}") {:ok, view, _} = live(conn, ~p"/sessions/#{session.id}")
section_id = insert_section(session.pid) section_id = insert_section(session.pid)