#4 Add a basic set of tests
Merged 7 years ago by ausil. Opened 7 years ago by lsedlar.
lsedlar/fedpkg-minimal tests  into  master

file added
+3
@@ -0,0 +1,3 @@ 

+ #!/bin/sh

+ 

+ echo "$(basename "$0")" "$@"

file added
+3
@@ -0,0 +1,3 @@ 

+ #!/bin/sh

+ 

+ echo "$(basename "$0")" "$@"

file added
+3
@@ -0,0 +1,3 @@ 

+ #!/bin/sh

+ 

+ echo "$(basename "$0")" "$@"

file added
+27
@@ -0,0 +1,27 @@ 

+ #!/bin/sh

+ 

+ set -e

+ 

+ HERE=$(pwd)/$(dirname "$0")

+ PATH="$HERE/../bin:$HERE/bin:$PATH"

+ export PATH

+ RET=0

+ 

+ for t in $HERE/test_*; do

+     output=$(mktemp)

+     diff=$(mktemp)

+     cd "$t"

+     fedpkg sources >"$output"

+     if diff -u expected "$output" >"$diff"; then

+         printf "%-40s 0K\n" "$(basename "$t")"

+     else

+         printf "%-40s FAIL\n" "$(basename "$t")"

+         echo "DIFF:"

+         cat "$diff"

+         echo ""

+         RET=$((RET + 1))

+     fi

+     cd "$HERE"

+     rm -f "$output" "$diff"

+ done

+ exit $RET

@@ -0,0 +1,2 @@ 

+ curl -L -H Pragma: -o ./github-linguist-4.8.18.gem -R -S --fail https://src.fedoraproject.org/repo/pkgs/test_md5_bsd/github-linguist-4.8.18.gem/md5/192de5f33807d72e573c54f61892fc69/github-linguist-4.8.18.gem

+ md5sum -c sources

@@ -0,0 +1,1 @@ 

+ MD5 (github-linguist-4.8.18.gem) = 192de5f33807d72e573c54f61892fc69

@@ -0,0 +1,2 @@ 

+ curl -L -H Pragma: -o ./entr-3.6.tar.gz -R -S --fail https://src.fedoraproject.org/repo/pkgs/test_md5_old/entr-3.6.tar.gz/072eed7153296a8fae6ebdedefed9fd4/entr-3.6.tar.gz

+ md5sum -c sources

@@ -0,0 +1,1 @@ 

+ 072eed7153296a8fae6ebdedefed9fd4  entr-3.6.tar.gz

@@ -0,0 +1,2 @@ 

+ curl -L -H Pragma: -o ./github-linguist-4.8.18.gem -R -S --fail https://src.fedoraproject.org/repo/pkgs/test_sha512_bsd/github-linguist-4.8.18.gem/sha512/d556ffe0062bc2c745c46e94929eab18c79fd221ffc1dd0c0ea5868428bd130d7b15eec618e9c3940b50c27559923911135770792864f3330a606132dc8819c0/github-linguist-4.8.18.gem

+ sha512sum -c sources

@@ -0,0 +1,1 @@ 

+ SHA512 (github-linguist-4.8.18.gem) = d556ffe0062bc2c745c46e94929eab18c79fd221ffc1dd0c0ea5868428bd130d7b15eec618e9c3940b50c27559923911135770792864f3330a606132dc8819c0

The test script modifies $PATH to point to the tested script first, and also adds a directory with mock scripts replacing curl and hash verification commands with echo. This way when the tests run fedpkg sources, the executed commands are just printed to stdout, where we can capture them and check they are as expected. There is no communication with any real service anywhere.

The tests cover three scenarios now:

  • MD5 hash with old style sources file
  • MD5 hash with BSD style sources file
  • SHA512 hash with BSD style sources file

To run the tests simply execute the run-tests.sh script.

Pull-Request has been merged by ausil

7 years ago