[108620] branches/gsoc13-tests/src/port1.0/tests/portinstall.test
marius at macports.org
marius at macports.org
Sun Jul 28 09:39:25 PDT 2013
Revision: 108620
https://trac.macports.org/changeset/108620
Author: marius at macports.org
Date: 2013-07-28 09:39:24 -0700 (Sun, 28 Jul 2013)
Log Message:
-----------
portinstall.test: added test file
Added Paths:
-----------
branches/gsoc13-tests/src/port1.0/tests/portinstall.test
Added: branches/gsoc13-tests/src/port1.0/tests/portinstall.test
===================================================================
--- branches/gsoc13-tests/src/port1.0/tests/portinstall.test (rev 0)
+++ branches/gsoc13-tests/src/port1.0/tests/portinstall.test 2013-07-28 16:39:24 UTC (rev 108620)
@@ -0,0 +1,215 @@
+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 install_start {
+ Install start unit test.
+} -body {
+ if {[getuid] != 0} {return "FAIL: not root, skipping test"}
+
+ set subport subport
+ set version 1.0
+ set revision 2
+ set portvariants {var1}
+ set prefix prefix
+ set add_users no
+
+ if {[catch {portinstall::install_start}] != 0} {
+ return "FAIL: problem with install start"
+ }
+ return "Install start successful."
+} -result "Install start successful."
+
+
+test create_archive {
+ Create archive 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 3.0
+ set create $pwd/create
+ set portbuildpath $pwd
+ set destpath $pwd/work/destroot
+ 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 {[catch {portinstall::install_main}] != 0} {
+ return "FAIL: cannot install port"
+ }
+
+ if {[catch {portinstall::create_archive $create tgz}] != 0} {
+ return "FAIL: cannot create archive"
+ }
+ return "Create archive successful."
+
+} -cleanup {
+ set res [uninstall_main]
+
+ file delete -force $create
+ file delete -force $pwd/$subport/work
+ file delete -force $pwd/$subport
+ file delete -force $portdbpath
+ file delete -force $pwd/work
+
+} -result "Create archive successful."
+
+
+# test extract_contents
+
+
+test install_main {
+ Install 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 3.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"
+ }
+ return "Install main successful."
+
+} -cleanup {
+ set res [uninstall_main]
+
+ file delete -force $pwd/$subport/work
+ file delete -force $pwd/$subport
+ file delete -force $portdbpath
+ file delete -force $pwd/work
+
+} -result "Install main successful."
+
+
+cleanupTests
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130728/4fbfc232/attachment-0001.html>
More information about the macports-changes
mailing list