Skip to content
Permalink
Browse files

tests: Avoid bogus error message during test runs

The distcheck unit test caused remote network traffic, which is bad from
a testing perspective. Additionally, it printed error messages to
stderr.

Avoid both of these problems by replacing the curl command with a mock
for the time of the test. This will also speed up the test.

Drop the unit test for the filesize distcheck.type, since there is no
good way to actually test whether it succeeds.

Closes: https://trac.macports.org/ticket/52218
  • Loading branch information
neverpanic committed Mar 12, 2018
1 parent a2d0c9c commit 4c11f3bea113e305776751e98d5236e34175a972
Showing with 32 additions and 14 deletions.
  1. +32 −14 src/port1.0/tests/portdistcheck.test
@@ -18,9 +18,7 @@ source ./library.tcl
macports_worker_init


test distcheck_main {
Distcheck main unit test.
} -setup {
set distcheck_fixture_setup {
set portpath $pwd
set filespath $pwd/files

@@ -34,20 +32,40 @@ test distcheck_main {
set porturl "http://distfiles.macports.org/gcc_select/"
set master_sites $porturl
set extract.suffix .tar.gz

} -body {
set fetch.type standard
set distcheck.type moddate
if {[portdistcheck::distcheck_main] != ""} {
return "FAIL: unable to download or check file, type moddate"
}
set distcheck.type filesize
if {[portdistcheck::distcheck_main] != ""} {
return "FAIL: unable to download or check file, type filesize"

# replace curl with a mock
rename curl _save_curl
proc curl {operation args} {
global _test_isnewer
switch $operation {
isnewer {
return ${_test_isnewer}
}
}
}
}
set distcheck_fixture_cleanup {
# restore original curl
rename curl ""
rename _save_curl curl
}

return "Distcheck main successful."
} -result "Distcheck main successful."
test distcheck_moddate_newer {
Check that files on servers that are newer than the Portfile cause a warning.
} -setup $distcheck_fixture_setup -cleanup $distcheck_fixture_cleanup -body {
set distcheck.type moddate
set _test_isnewer 1
return [portdistcheck::distcheck_main]
} -errorOutput "Warning: port gcc_select: .* is newer than Portfile" -match regexp

test distcheck_moddate_not_newer {
Check that files on server that are not newer than the Portfile do not cause a warning
} -setup $distcheck_fixture_setup -cleanup $distcheck_fixture_cleanup -body {
set distcheck.type moddate
set _test_isnewer 0
return [portdistcheck::distcheck_main]
} -errorOutput ""


cleanupTests

0 comments on commit 4c11f3b

Please sign in to comment.
You can’t perform that action at this time.