From e8b145550ed49d4a3452867cd783cd2452a2d196 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 30 Sep 2020 19:28:30 +0200 Subject: [PATCH] Skip stream tests if ffmpeg is not installed --- .gitlab-ci.yml | 2 +- stream/srt/srt_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8773397..5c3c80c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ unit_tests: image: golang:1.15-alpine stage: test before_script: - - apk add --no-cache build-base ffmpeg gcc + - apk add --no-cache build-base gcc - apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing libsrt-dev script: - go test -v -covermode=count -coverprofile cover.cov ./... diff --git a/stream/srt/srt_test.go b/stream/srt/srt_test.go index cf16fc4..e1c1a84 100644 --- a/stream/srt/srt_test.go +++ b/stream/srt/srt_test.go @@ -23,6 +23,19 @@ func TestSplitHostPort(t *testing.T) { // TestServeSRT Serve a SRT server, stream content during 5 seconds and ensure that it is well received func TestServeSRT(t *testing.T) { + which := exec.Command("which", "ffmpeg") + if err := which.Start(); err != nil { + t.Fatal("Error while checking if ffmpeg got installed:", err) + } + state, err := which.Process.Wait() + if err != nil { + t.Fatal("Error while checking if ffmpeg got installed:", err) + } + if state.ExitCode() != 0 { + // FFMPEG is not installed + t.Skip("WARNING: FFMPEG is not installed. Skipping stream test") + } + go Serve(&Options{ListenAddress: ":9711", MaxClients: 2}) ffmpeg := exec.Command("ffmpeg",