diff --git a/dcc/eureka.py b/dcc/eureka.py index 4d7b9cd..392f596 100644 --- a/dcc/eureka.py +++ b/dcc/eureka.py @@ -1,6 +1,6 @@ import dcc.doom_base import dcc.config -import os +import subprocess class Eureka(dcc.doom_base.WadMap): @@ -24,7 +24,7 @@ class Eureka(dcc.doom_base.WadMap): if complevel == "11" or complevel == "21": port = "mbf" - os.execvp("eureka", + subprocess.run( ["eureka"] + ["-iwad", iwad] + ["-w", parsed_args.map] + ["-p", port] + [mw] ) diff --git a/dcc/fabricate.py b/dcc/fabricate.py index 8c279ef..3f4266b 100644 --- a/dcc/fabricate.py +++ b/dcc/fabricate.py @@ -1,8 +1,8 @@ import contextlib import dcc.config import dcc.doom_base -import os import shutil +import subprocess import tempfile @@ -18,7 +18,7 @@ class Fabricate(dcc.doom_base.WadMap): command = [self.dsda] if not parsed_args.fg and shutil.which("xvfb-run") is not None: command = ["xvfb-run"] + command - os.execvp(command[0], + subprocess.run( command + self.dsda_preamble() + ["-timedemo", self.demo_in_path()] + ["-viddump", self.video_path()] diff --git a/dcc/pb.py b/dcc/pb.py index 661d538..a1def16 100644 --- a/dcc/pb.py +++ b/dcc/pb.py @@ -1,8 +1,8 @@ import dcc.config import dcc.doom_base -import os +import subprocess class PB(dcc.doom_base.WadMap): def take_action(self, parsed_args): - os.execvp("ffplay", ["ffplay", self.video_path()]) + subprocess.run(["ffplay", self.video_path()]) diff --git a/dcc/play.py b/dcc/play.py index 5459b6e..ea0af3c 100644 --- a/dcc/play.py +++ b/dcc/play.py @@ -1,8 +1,8 @@ import dcc.config import dcc.doom_base -import os +import subprocess class Play(dcc.doom_base.WadMap): def take_action(self, parsed_args): - os.execv(self.dsda, [self.dsda] + self.dsda_preamble()) + subprocess.run([self.dsda] + self.dsda_preamble()) diff --git a/dcc/record.py b/dcc/record.py index 21a5bd5..525d177 100644 --- a/dcc/record.py +++ b/dcc/record.py @@ -1,11 +1,11 @@ import dcc.config import dcc.doom_base -import os +import subprocess class Record(dcc.doom_base.WadMap): def take_action(self, parsed_args): - os.execv(self.dsda, + subprocess.run( [self.dsda] + self.dsda_preamble() + ["-record", self.demo_out_path()] ) diff --git a/dcc/rib.py b/dcc/rib.py index ffcc16a..7e00265 100644 --- a/dcc/rib.py +++ b/dcc/rib.py @@ -1,6 +1,7 @@ import dcc.doom_base import pathlib import os +import subprocess import time @@ -41,7 +42,7 @@ class RIB(dcc.doom_base.WadMap): + f"and map {parsed_args.map} (tried to look in {demodir})" ) - os.execv(self.dsda, + subprocess.run( [self.dsda] + self.dsda_preamble(warp=False) + ["-playdemo", demo] + ["-skiptic", str(-35 * parsed_args.secs_before)] diff --git a/tests/play_test.py b/tests/play_test.py index 1fa3956..4dbaa31 100644 --- a/tests/play_test.py +++ b/tests/play_test.py @@ -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(expect): +def test_play(when): with tempfile.TemporaryDirectory() as td: tdp = pathlib.Path(td) tdp.joinpath("config.toml").write_text( @@ -26,14 +26,9 @@ def test_play(expect): scp.mkdir() scp.joinpath("config.toml").touch() scp.joinpath("scythe.wad").touch() - 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"), + zero = subprocess.CompletedProcess + zero.returncode = 0 + when(subprocess).run( [ tdp.joinpath("dsda-doom").joinpath("exe"), "-iwad", @@ -47,5 +42,11 @@ def test_play(expect): "-warp", "01", ] - ).thenReturn(None): - assert rig.run(parsed_args) is None + ).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