From 84f9fce0c2fd18154fdc3d36da648313de042455 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 3 Nov 2015 18:44:33 +0000 Subject: [PATCH 1/1] Testing: Break out srcdump-save-check Originally I thought I would keep only one of the srcdump tests, but I have changed my mind. So we need to get rid of this clone-and-hack. srcdump-save-check was identical in the two scripts. Signed-off-by: Ian Jackson --- tests/autotest | 59 ++++++++++++++++++++++++++++++++++++++ tests/srcdump-login.at | 54 +--------------------------------- tests/srcdump-loginback.at | 54 +--------------------------------- 3 files changed, 61 insertions(+), 106 deletions(-) diff --git a/tests/autotest b/tests/autotest index b07913f..4737b1e 100755 --- a/tests/autotest +++ b/tests/autotest @@ -98,6 +98,65 @@ proc loginas {user {password sesame} {wanttxt ACCESSGRANTED}} { submitform-expect $wanttxt } +proc srcdump-save-check {} { + global tt + global outertar sd files + + set outertar $tt/t-srcdump.tgz + set sd $tt/t-srcdump.d + + send "\x15$outertar\r" + etxt "Download complete" + + exec mkdir $sd + + set files [exec tar -C $sd -zvxf - < $outertar] + + foreach f { + manifest.txt + licence.data + cgi-auth-flexible.pm + .gitignore + } { + set got($f) 0 + } + + if {[file exists .git]} { + set got(.git/objects/) 0 + } + + foreach f $files { + switch -glob -- $f { + licence.data - manifest.txt { + set got($f) 1 + } + *.tar { + foreach g [exec tar -C $sd -tf - < $sd/$f] { + switch -glob -- $g { + cgi-auth-flexible.pm - .gitignore - .git/objects/ { + set got($g) 1 + } + *~ { + error "file $g inside $f !" + } + .git/* { + } + *.db { + error "file $g inside $f outside .git !" + } + } + } + } + } + } + + foreach g [array names got] { + if {!$got($g)} { + error "file $g missing" + } + } +} + source $testfile puts "$id: ok" diff --git a/tests/srcdump-login.at b/tests/srcdump-login.at index 8fbfb8c..895fa36 100644 --- a/tests/srcdump-login.at +++ b/tests/srcdump-login.at @@ -29,56 +29,4 @@ submitform-expect "Viewing" loginas alice sesame "Save file to" -set outertar $tt/t-srcdump.tgz -set sd $tt/t-srcdump.d - -send "\x15$outertar\r" -etxt "Download complete" - -exec mkdir $sd - -set files [exec tar -C $sd -zvxf - < $outertar] - -foreach f { - manifest.txt - licence.data - cgi-auth-flexible.pm - .gitignore -} { - set got($f) 0 -} - -if {[file exists .git]} { - set got(.git/objects/) 0 -} - -foreach f $files { - switch -glob -- $f { - licence.data - manifest.txt { - set got($f) 1 - } - *.tar { - foreach g [exec tar -C $sd -tf - < $sd/$f] { - switch -glob -- $g { - cgi-auth-flexible.pm - .gitignore - .git/objects/ { - set got($g) 1 - } - *~ { - error "file $g inside $f !" - } - .git/* { - } - *.db { - error "file $g inside $f outside .git !" - } - } - } - } - } -} - -foreach g [array names got] { - if {!$got($g)} { - error "file $g missing" - } -} +srcdump-save-check diff --git a/tests/srcdump-loginback.at b/tests/srcdump-loginback.at index 76554ab..4a2e402 100644 --- a/tests/srcdump-loginback.at +++ b/tests/srcdump-loginback.at @@ -29,56 +29,4 @@ send "B/source available\r\r" etxt "Save file to" -set outertar $tt/t-srcdump.tgz -set sd $tt/t-srcdump.d - -send "\x15$outertar\r" -etxt "Download complete" - -exec mkdir $sd - -set files [exec tar -C $sd -zvxf - < $outertar] - -foreach f { - manifest.txt - licence.data - cgi-auth-flexible.pm - .gitignore -} { - set got($f) 0 -} - -if {[file exists .git]} { - set got(.git/objects/) 0 -} - -foreach f $files { - switch -glob -- $f { - licence.data - manifest.txt { - set got($f) 1 - } - *.tar { - foreach g [exec tar -C $sd -tf - < $sd/$f] { - switch -glob -- $g { - cgi-auth-flexible.pm - .gitignore - .git/objects/ { - set got($g) 1 - } - *~ { - error "file $g inside $f !" - } - .git/* { - } - *.db { - error "file $g inside $f outside .git !" - } - } - } - } - } -} - -foreach g [array names got] { - if {!$got($g)} { - error "file $g missing" - } -} +srcdump-save-check -- 2.30.2