Discover CommandOption type and ffmpeg.GlobalCommandOptions array, that is processed before running ffmpeg or ffprobe commands.
Add tests.
This commit is contained in:
Denis Borzenko
2023-02-28 23:46:11 +03:00
parent 2a41acb422
commit bbf2881ff4
4 changed files with 39 additions and 1 deletions

View File

@@ -9,6 +9,19 @@ import (
func TestCompileWithOptions(t *testing.T) {
out := Input("dummy.mp4").Output("dummy2.mp4")
cmd := out.Compile(SeparateProcessGroup())
assert.Equal(t, cmd.SysProcAttr.Pgid, 0)
assert.Equal(t, 0, cmd.SysProcAttr.Pgid)
assert.True(t, cmd.SysProcAttr.Setpgid)
}
func TestGlobalCommandOptions(t *testing.T) {
out := Input("dummy.mp4").Output("dummy2.mp4")
GlobalCommandOptions = append(GlobalCommandOptions, func(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true, Pgid: 0}
})
defer func() {
GlobalCommandOptions = GlobalCommandOptions[0 : len(GlobalCommandOptions)-1]
}()
cmd := out.Compile()
assert.Equal(t, 0, cmd.SysProcAttr.Pgid)
assert.True(t, cmd.SysProcAttr.Setpgid)
}