Revision: 108646 https://trac.macports.org/changeset/108646 Author: marius@macports.org Date: 2013-07-29 03:29:46 -0700 (Mon, 29 Jul 2013) Log Message: ----------- portuninstall.test: added test file Added Paths: ----------- branches/gsoc13-tests/src/port1.0/tests/portuninstall.test Added: branches/gsoc13-tests/src/port1.0/tests/portuninstall.test =================================================================== --- branches/gsoc13-tests/src/port1.0/tests/portuninstall.test (rev 0) +++ branches/gsoc13-tests/src/port1.0/tests/portuninstall.test 2013-07-29 10:29:46 UTC (rev 108646) @@ -0,0 +1,146 @@ +package require tcltest 2 +namespace import tcltest::* + +set pwd [file normalize $argv0] +set pwd [eval file join {*}[lrange [file split $pwd] 0 end-1]] + +package require macports 1.0 +mportinit + +source ../portinstall.tcl +source ../../registry2.0/portuninstall.tcl +source ../port_autoconf.tcl + +proc registry_exists {name version {revision 0} {variants ""}} { + global macports::registry.format + return [${macports::registry.format}::entry_exists $name $version $revision $variants] +} + +proc findBinary {prog {autoconf_hint ""}} { + if {${autoconf_hint} != "" && [file executable ${autoconf_hint}]} { + return ${autoconf_hint} + } else { + if {[catch {set cmd_path [macports::binaryInPath ${prog}]} t] == + + return ${cmd_path} + } else { + return -code error "${result} or at its MacPorts guration time tion, did you move it?" + } + } +} + +proc uninstall_main {args} { + global subport version revision portvariants user_options + registry_uninstall::uninstall $subport $version $revision $portvariants [array get user_options] + return 0 +} + +proc run_destroot {} { + global pwd os_platform os_version os_arch + + set os_platform darwin + set os.platform darwin + set macosx_version 10.8 + set os_version 11 + set os_arch i386 + set os.major 10 + set supported_archs {} + set configure.build_arch build_arch + set portarchivetype tgz + + set subport fondu + set version 3.0 + + set portpath $pwd + set portdbpath $pwd/dbpath + set portbuildpath $pwd + set destpath $pwd/work/destroot + + + # destroot setup + file mkdir $pwd/$subport + file copy -force $pwd/Portfile /tmp/ + set mport [mportopen file://.] + + proc getportbuildpath {id {portname ""}} { + global portdbpath + regsub {://} $id {.} port_path + regsub -all {/} $port_path {_} port_path + return [file join $portdbpath build $port_path $portname] + } + + proc getportworkpath_from_buildpath {portbuildpath} { + return [file join $portbuildpath work] + } + + proc getportworkpath_from_portdir {portpath {portname ""}} { + return [getportworkpath_from_buildpath [getportbuildpath $portpath tname]] + } + + source $pwd/../portmain.tcl + + # sets up PortInfo array + if {[eval_variants variations] != 0} { + mportclose $mport + error "Error evaluating variants" + } + + # set $version var + set workername [ditem_key $mport workername] + + # run destroot + $workername eval eval_targets destroot +} + + +# test uninstall_start + + +test uninstall_main { + Uninstall main unit test. +} -body { + if {[getuid] != 0} {return "FAIL: not root, skipping test"} + + set os.platform darwin + set macosx_version 10.8 + set os_version 11 + set os_arch i386 + set os.major 10 + set supported_archs {} + set configure.build_arch build_arch + set portarchivetype tgz + + set subport fondu + set version 4.0 + + set portpath $pwd + set portdbpath $pwd/dbpath + set portbuildpath $pwd + set destpath $pwd/work/destroot + + run_destroot + + # portinstall setup + interp alias {} _cd {} cd + set macosx_deployment_target $pwd/deploy_target + file link -symbolic $pwd/$subport/work $pwd/work + + if {[portinstall::install_main] != 0} { + return "FAIL: cannot install port" + } + + if {[uninstall_main] != 0} { + return "FAIL: cannot uninstall port" + } + return "Uninstall main successful." + +} -cleanup { + file delete -force $pwd/$subport/work + file delete -force $pwd/$subport + file delete -force $portdbpath + file delete -force $pwd/work + +} -result "Uninstall main successful." + + +cleanupTests