package require tcltest 2 namespace import tcltest::* set pwd [file normalize $argv0] set pwd [eval file join {*}[lrange [file split $pwd] 0 end-1]] source ../package_test_autoconf.tcl source $macports::autoconf::macports_tcl_dir/macports1.0/macports_fastload.tcl package require macports 1.0 array set ui_options {} #set ui_options(ports_debug) yes #set ui_options(ports_verbose) yes mportinit ui_options source ./library.tcl macports_worker_init package require portarchivefetch 1.0 namespace eval portutil { namespace eval autoconf { variable openssl_path "/usr/bin/openssl" } } test filter_sites { Filter sites unit test. } -setup { global os.platform os.major os.arch epoch destpath package.destpath configure.build_arch global subport version revision package.flat maintainers description categories global supported_archs portname porturl portdbpath portpath workpath distname filespath license env_init set portvariants {var1} set porturl http://www.fondu.sourceforge.net/fondu-060102_1var1.darwin_9.noarch.tgz } -body { if {[portarchivefetch::filter_sites] != "http://www.fondu.sourceforge.net/:tgz"} { return "FAIL: couldn't fetch file" } return "Filter sites successful." } -result "Filter sites successful." test checkarchivefiles { Check archive files unit test. } -setup { global os.platform os.major os.arch epoch destpath package.destpath configure.build_arch global subport version revision package.flat maintainers description categories global supported_archs portname porturl portdbpath portpath workpath distname filespath license env_init set urls {www.a.com www.b.com} set all_archive_files "" set archivefetch.fulldestpath $pwd/path set archive_sites {site1:zip site2:tgz} } -body { if {[catch {portarchivefetch::checkarchivefiles $urls}] != 0} { return "FAIL: cannot run checkarchivefiles" } if {[lindex $all_archive_files 0] != "fondu-060102_1var1.darwin_9.noarch.zip"} { return "FAIL: invalid archive file name" } if {[lindex $all_archive_files 1] != "fondu-060102_1var1.darwin_9.noarch.tgz"} { return "FAIL: invalid archive file name" } return "Check archive files successful." } -result "Check archive files successful." # test get_full_archive_sites_path # test checkfiles test fetchfiles { Fetch files unit test. } -constraints { root } -setup { global os.platform os.major os.arch epoch destpath package.destpath configure.build_arch global subport version revision package.flat maintainers description categories global supported_archs portname porturl portdbpath portpath workpath distname filespath license env_init array set ::portfetch::urlmap { fondu http://packages.macports.org/fondu/ } set portarchivefetch::archivefetch_urls {fondu fondu-060102_1.darwin_12.x86_64.tbz2} set target_state_fd [open $pwd/target w+] set mport [mportopen file://.] set workername [ditem_key $mport workername] set macportsuser macports set oldchannels [array get macports::channels] set macports::channels(msg) {} set macports::channels(notice) {} set macports::channels(warn) {} } -body { set archivefetch.pubkeys $pwd if {[catch {portarchivefetch::fetchfiles}] != 0} { return "FAIL: cannot fetch archive" } if {[file exists ${archivefetch.fulldestpath}/fondu-060102_1.darwin_12.x86_64.tbz2]} { return "FAIL: unverified archive not discarded" } set archivefetch.pubkeys ${macports::prefix}/share/macports/macports-pubkey.pem if {[portarchivefetch::fetchfiles] != 0} { return "FAIL: cannot fetch archive" } if {![file exists ${archivefetch.fulldestpath}/fondu-060102_1.darwin_12.x86_64.tbz2]} { return "FAIL: verified archive deleted" } return "Fetch files successful." } -cleanup { array set macports::channels $oldchannels close $target_state_fd file delete -force $pwd/target mportclose $mport file delete -force $portdbpath } -result "Fetch files successful." # test archivefetch_start # test archivefetch_main cleanupTests