From dad7aee60f80ad9bb4b6413142c62f6f1d918a1f Mon Sep 17 00:00:00 2001 From: Jon Carstens Date: Fri, 9 Sep 2022 14:22:25 -0600 Subject: [PATCH] Ignore SCP return in tests SCP can sometimes return 1 even when it succeeds, so we'll just ignore the return and check the file exists and has the contents expected instead --- test/nerves_ssh_test.exs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/nerves_ssh_test.exs b/test/nerves_ssh_test.exs index eb9bd05..dcdde9f 100644 --- a/test/nerves_ssh_test.exs +++ b/test/nerves_ssh_test.exs @@ -144,7 +144,10 @@ defmodule NervesSSHTest do File.write!(download_path, "asdf") - {_output, 0} = + # SCP can sometimes return 1 even when it succeeds, + # so we'll just ignore the return here and rely on the file + # check below + _ = System.cmd("scp", [ "-o", "UserKnownHostsFile /dev/null", @@ -158,6 +161,7 @@ defmodule NervesSSHTest do "#{filename}" ]) + assert File.exists?(filename) assert File.read!(filename) == "asdf" end @@ -175,7 +179,10 @@ defmodule NervesSSHTest do File.write!(filename, "asdf") - {_output, 0} = + # SCP can sometimes return 1 even when it succeeds, + # so we'll just ignore the return here and rely on the file + # check below + _ = System.cmd("scp", [ "-o", "UserKnownHostsFile /dev/null", @@ -189,6 +196,7 @@ defmodule NervesSSHTest do "test_user@localhost:#{upload_path}" ]) + assert File.exists?(upload_path) assert File.read!(upload_path) == "asdf" end