summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-07-17 01:34:46 +0200
committerwm4 <wm4@nowhere>2020-07-20 21:02:17 +0200
commit0279a44d93a378fbdff393d6568a691817f83518 (patch)
treee81a2984f7d71cccb871f43c2c6e25c652548834 /test
parentc9742413ac5eeabfdd46503f67b7393c9bd99f49 (diff)
downloadmpv-0279a44d93a378fbdff393d6568a691817f83518.tar.bz2
mpv-0279a44d93a378fbdff393d6568a691817f83518.tar.xz
command: extend subprocess command
Add env and detach arguments. This means the command.c code must use the "new" mp_subprocess2(). So also take this as an opportunity to clean up. win32 support gets broken by it, because it never made the switch to the newer function. The new detach parameter makes the "run" command fully redundant, but I guess we'll keep it for simplicity. But change its implementation to use mp_subprocess2() (couldn't do this earlier, because win32). Privately, I'm going to use the "env" argument to add a key binding that starts a shell with a FILE environment variable set to the currently playing file, so this is very useful to me. Note: breaks windows, so for example youtube-dl on windows will not work anymore. mp_subprocess2() has to be implemented. The old functions are gone, and subprocess-win.c is not built anymore. It will probably work on Cygwin.
Diffstat (limited to 'test')
-rw-r--r--test/tests.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/tests.c b/test/tests.c
index d8df43f319..eb55bb302b 100644
--- a/test/tests.c
+++ b/test/tests.c
@@ -118,13 +118,19 @@ void assert_text_files_equal_impl(const char *file, int line,
char *path_ref = mp_tprintf(4096, "%s/%s", ctx->ref_path, ref);
char *path_new = mp_tprintf(4096, "%s/%s", ctx->out_path, new);
- char *errstr = NULL;
- int res = mp_subprocess((char*[]){"diff", "-u", "--", path_ref, path_new, 0},
- NULL, NULL, NULL, NULL, &errstr);
+ struct mp_subprocess_opts opts = {
+ .exe = "diff",
+ .args = (char*[]){"diff", "-u", "--", path_ref, path_new, 0},
+ .fds = { {0, .src_fd = 0}, {1, .src_fd = 1}, {2, .src_fd = 2} },
+ .num_fds = 3,
+ };
+
+ struct mp_subprocess_result res;
+ mp_subprocess2(&opts, &res);
- if (res) {
- if (res == 1)
- MP_WARN(ctx, "Note: %s\n", err);
+ if (res.error || res.exit_status) {
+ if (res.error)
+ MP_WARN(ctx, "Note: %s\n", mp_subprocess_err_str(res.error));
MP_FATAL(ctx, "Giving up.\n");
abort();
}