Use os.execv instead of subprocess.run when no further action is taken.
This prevents the underlying file from being marked busy while a long-running action is happening (e.g. eureka is open).
This commit is contained in:
parent
21bdcf3e17
commit
edbf4f2a0e
7 changed files with 23 additions and 25 deletions
|
|
@ -1,16 +1,16 @@
|
|||
import cliff.app
|
||||
import dcc.play
|
||||
import logging
|
||||
import os
|
||||
import mockito.matchers
|
||||
import pathlib
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def test_play(when):
|
||||
def test_play(expect):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
tdp = pathlib.Path(td)
|
||||
tdp.joinpath("config.toml").write_text(
|
||||
|
|
@ -26,9 +26,14 @@ def test_play(when):
|
|||
scp.mkdir()
|
||||
scp.joinpath("config.toml").touch()
|
||||
scp.joinpath("scythe.wad").touch()
|
||||
zero = subprocess.CompletedProcess
|
||||
zero.returncode = 0
|
||||
when(subprocess).run(
|
||||
dcc.play.Play.__init__ = lambda self: None
|
||||
dcc.play.Play.get_epilog = lambda self: ""
|
||||
rig = dcc.play.Play()
|
||||
rig._hooks = []
|
||||
parser = rig.get_parser("test_play")
|
||||
parsed_args = parser.parse_args(args=["--doom", td, "scythe", "01"])
|
||||
with expect(os, times=1).execv(
|
||||
tdp.joinpath("dsda-doom").joinpath("exe"),
|
||||
[
|
||||
tdp.joinpath("dsda-doom").joinpath("exe"),
|
||||
"-iwad",
|
||||
|
|
@ -42,11 +47,5 @@ def test_play(when):
|
|||
"-warp",
|
||||
"01",
|
||||
]
|
||||
).thenReturn(zero)
|
||||
dcc.play.Play.__init__ = lambda self: None
|
||||
dcc.play.Play.get_epilog = lambda self: ""
|
||||
rig = dcc.play.Play()
|
||||
rig._hooks = []
|
||||
parser = rig.get_parser("test_play")
|
||||
parsed_args = parser.parse_args(args=["--doom", td, "scythe", "01"])
|
||||
assert rig.run(parsed_args) == 0
|
||||
).thenReturn(None):
|
||||
assert rig.run(parsed_args) is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue