[111325] trunk/base

marius at macports.org marius at macports.org
Wed Sep 18 17:14:10 PDT 2013


Revision: 111325
          https://trac.macports.org/changeset/111325
Author:   marius at macports.org
Date:     2013-09-18 17:14:10 -0700 (Wed, 18 Sep 2013)
Log Message:
-----------
Merged test framework developed in GSoC 13.

Modified Paths:
--------------
    trunk/base/HACKING
    trunk/base/configure
    trunk/base/configure.ac
    trunk/base/src/macports1.0/Makefile
    trunk/base/src/package1.0/Makefile
    trunk/base/src/port1.0/Makefile
    trunk/base/src/port1.0/portchecksum.tcl
    trunk/base/src/port1.0/portutil.tcl
    trunk/base/src/registry2.0/tests/entry.tcl
    trunk/base/tests/test/checksums-1/Portfile

Added Paths:
-----------
    trunk/base/src/macports1.0/macports_test_autoconf.tcl.in
    trunk/base/src/macports1.0/tests/Portfile
    trunk/base/src/macports1.0/tests/macports.test
    trunk/base/src/macports1.0/tests/macports_dlist.test
    trunk/base/src/macports1.0/tests/macports_util.test
    trunk/base/src/macports1.0/tests/sources.conf
    trunk/base/src/macports1.0/tests/test.tcl
    trunk/base/src/package1.0/package_test_autoconf.tcl.in
    trunk/base/src/package1.0/tests/
    trunk/base/src/package1.0/tests/Portfile
    trunk/base/src/package1.0/tests/library.tcl
    trunk/base/src/package1.0/tests/portarchivefetch.test
    trunk/base/src/package1.0/tests/portdmg.test
    trunk/base/src/package1.0/tests/portdpkg.test
    trunk/base/src/package1.0/tests/portmdmg.test
    trunk/base/src/package1.0/tests/portmpkg.test
    trunk/base/src/package1.0/tests/portpkg.test
    trunk/base/src/package1.0/tests/test.tcl
    trunk/base/src/port1.0/port_test_autoconf.tcl.in
    trunk/base/src/port1.0/tests/Portfile
    trunk/base/src/port1.0/tests/library.tcl
    trunk/base/src/port1.0/tests/portactivate.test
    trunk/base/src/port1.0/tests/portchecksum.test
    trunk/base/src/port1.0/tests/portclean.test
    trunk/base/src/port1.0/tests/portdeactivate.test
    trunk/base/src/port1.0/tests/portdepends.test
    trunk/base/src/port1.0/tests/portdistcheck.test
    trunk/base/src/port1.0/tests/portinstall.test
    trunk/base/src/port1.0/tests/portload.test
    trunk/base/src/port1.0/tests/portmain.test
    trunk/base/src/port1.0/tests/portpatch.test
    trunk/base/src/port1.0/tests/porttest.test
    trunk/base/src/port1.0/tests/portuninstall.test
    trunk/base/src/port1.0/tests/portutil.test
    trunk/base/src/port1.0/tests/statefile
    trunk/base/src/port1.0/tests/test.tcl
    trunk/base/tests/Makefile
    trunk/base/tests/test/case-insensitive-deactivate/DESCRIPTION
    trunk/base/tests/test/case-insensitive-deactivate/test.tcl
    trunk/base/tests/test/checksums-1/DESCRIPTION
    trunk/base/tests/test/checksums-1/test.tcl
    trunk/base/tests/test/dependencies-a/DESCRIPTION
    trunk/base/tests/test/dependencies-a/test.tcl
    trunk/base/tests/test/dependencies-b/DESCRIPTION
    trunk/base/tests/test/dependencies-b/test.tcl
    trunk/base/tests/test/dependencies-c/DESCRIPTION
    trunk/base/tests/test/dependencies-c/test.tcl
    trunk/base/tests/test/dependencies-d/DESCRIPTION
    trunk/base/tests/test/dependencies-d/test.tcl
    trunk/base/tests/test/dependencies-e/DESCRIPTION
    trunk/base/tests/test/dependencies-e/test.tcl
    trunk/base/tests/test/envvariables/DESCRIPTION
    trunk/base/tests/test/envvariables/test.tcl
    trunk/base/tests/test/library.tcl
    trunk/base/tests/test/site-tags/DESCRIPTION
    trunk/base/tests/test/site-tags/test.tcl
    trunk/base/tests/test/statefile-unknown-version/DESCRIPTION
    trunk/base/tests/test/statefile-unknown-version/test.tcl
    trunk/base/tests/test/statefile-version1/DESCRIPTION
    trunk/base/tests/test/statefile-version1/test.tcl
    trunk/base/tests/test/statefile-version1-outdated/DESCRIPTION
    trunk/base/tests/test/statefile-version1-outdated/test.tcl
    trunk/base/tests/test/statefile-version2/DESCRIPTION
    trunk/base/tests/test/statefile-version2/test.tcl
    trunk/base/tests/test/statefile-version2-invalid/DESCRIPTION
    trunk/base/tests/test/statefile-version2-invalid/test.tcl
    trunk/base/tests/test/statefile-version2-outdated/DESCRIPTION
    trunk/base/tests/test/statefile-version2-outdated/test.tcl
    trunk/base/tests/test/svn-and-patchsites/DESCRIPTION
    trunk/base/tests/test/svn-and-patchsites/test.tcl
    trunk/base/tests/test/trace/DESCRIPTION
    trunk/base/tests/test/trace/test.tcl
    trunk/base/tests/test/universal/DESCRIPTION
    trunk/base/tests/test/universal/Portfile.in
    trunk/base/tests/test/universal/test.tcl
    trunk/base/tests/test/variants/DESCRIPTION
    trunk/base/tests/test/variants/test.tcl
    trunk/base/tests/test/xcodeversion/DESCRIPTION
    trunk/base/tests/test/xcodeversion/test.tcl
    trunk/base/tests/test.tcl

Removed Paths:
-------------
    trunk/base/src/macports1.0/tests/macports_dlist.tcl
    trunk/base/src/macports1.0/tests/macports_util.tcl
    trunk/base/src/package1.0/tests/Portfile
    trunk/base/src/package1.0/tests/library.tcl
    trunk/base/src/package1.0/tests/portarchivefetch.test
    trunk/base/src/package1.0/tests/portdmg.test
    trunk/base/src/package1.0/tests/portdpkg.test
    trunk/base/src/package1.0/tests/portmdmg.test
    trunk/base/src/package1.0/tests/portmpkg.test
    trunk/base/src/package1.0/tests/portpkg.test
    trunk/base/src/package1.0/tests/test.tcl
    trunk/base/src/port1.0/tests/common.tcl
    trunk/base/src/port1.0/tests/portdestroot.tcl
    trunk/base/src/port1.0/tests/portfetch.tcl
    trunk/base/src/port1.0/tests/portutil.tcl
    trunk/base/tests/Makefile
    trunk/base/tests/test/case-insensitive-deactivate/Makefile
    trunk/base/tests/test/checksums-1/master
    trunk/base/tests/test/dependencies-c/master
    trunk/base/tests/test/dependencies-d/master
    trunk/base/tests/test/dependencies-e/error_expected
    trunk/base/tests/test/dependencies-e/master
    trunk/base/tests/test/envvariables/Makefile
    trunk/base/tests/test/envvariables/master
    trunk/base/tests/test/site-tags/master
    trunk/base/tests/test/statefile-unknown-version/Makefile
    trunk/base/tests/test/statefile-unknown-version/master
    trunk/base/tests/test/statefile-version1/Makefile
    trunk/base/tests/test/statefile-version1/master
    trunk/base/tests/test/statefile-version1-outdated/Makefile
    trunk/base/tests/test/statefile-version1-outdated/master
    trunk/base/tests/test/statefile-version2/Makefile
    trunk/base/tests/test/statefile-version2/master
    trunk/base/tests/test/statefile-version2-invalid/Makefile
    trunk/base/tests/test/statefile-version2-invalid/master
    trunk/base/tests/test/statefile-version2-outdated/Makefile
    trunk/base/tests/test/statefile-version2-outdated/master
    trunk/base/tests/test/svn-and-patchsites/master
    trunk/base/tests/test/universal/Makefile
    trunk/base/tests/test/universal/Portfile
    trunk/base/tests/test/universal/master
    trunk/base/tests/test/universal-2/
    trunk/base/tests/test/variants/master
    trunk/base/tests/test/xcodeversion/master

Property Changed:
----------------
    trunk/base/
    trunk/base/portmgr/fedora/macports.spec
    trunk/base/src/macports1.0/
    trunk/base/src/package1.0/
    trunk/base/src/pextlib1.0/Makefile.in
    trunk/base/src/pextlib1.0/sha2.c
    trunk/base/src/pextlib1.0/sha2.h
    trunk/base/src/pextlib1.0/sha256cmd.c
    trunk/base/src/pextlib1.0/sha256cmd.h
    trunk/base/src/port1.0/
    trunk/base/src/registry2.0/receipt_sqlite.tcl


Property changes on: trunk/base
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/gsoc11-rev-upgrade/base:78828-88375
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692
   + /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/gsoc11-rev-upgrade/base:78828-88375
/branches/gsoc13-tests:106692-111324
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692

Modified: trunk/base/HACKING
===================================================================
--- trunk/base/HACKING	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/HACKING	2013-09-19 00:14:10 UTC (rev 111325)
@@ -70,3 +70,6 @@
 
  *  All other files (documentation, etc) SHOULD NOT use a modeline as it
     is probably meant for human consumption.
+
+ -  When adding new features, always add test cases.
+    See "https://trac.macports.org/wiki/Tests".

Modified: trunk/base/configure
===================================================================
--- trunk/base/configure	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/configure	2013-09-19 00:14:10 UTC (rev 111325)
@@ -10096,7 +10096,7 @@
 
 
 # Output
-ac_config_files="$ac_config_files Doxyfile Makefile Mk/macports.autoconf.mk doc/base.mtree doc/macosx.mtree doc/macports.conf doc/prefix.mtree doc/pubkeys.conf portmgr/freebsd/Makefile setupenv.bash src/Makefile src/machista1.0/Makefile src/macports1.0/macports_autoconf.tcl src/macports1.0/macports_fastload.tcl src/pextlib1.0/Makefile src/port1.0/port_autoconf.tcl src/programs/Makefile src/registry2.0/registry_autoconf.tcl"
+ac_config_files="$ac_config_files Doxyfile Makefile Mk/macports.autoconf.mk doc/base.mtree doc/macosx.mtree doc/macports.conf doc/prefix.mtree doc/pubkeys.conf portmgr/freebsd/Makefile setupenv.bash src/Makefile src/machista1.0/Makefile src/macports1.0/macports_autoconf.tcl src/macports1.0/macports_test_autoconf.tcl src/macports1.0/macports_fastload.tcl src/package1.0/package_test_autoconf.tcl src/pextlib1.0/Makefile src/port1.0/port_autoconf.tcl src/port1.0/port_test_autoconf.tcl src/programs/Makefile src/registry2.0/registry_autoconf.tcl"
 
 
 ac_config_files="$ac_config_files src/pkg_mkindex.sh"
@@ -10807,9 +10807,12 @@
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     "src/machista1.0/Makefile") CONFIG_FILES="$CONFIG_FILES src/machista1.0/Makefile" ;;
     "src/macports1.0/macports_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/macports1.0/macports_autoconf.tcl" ;;
+    "src/macports1.0/macports_test_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/macports1.0/macports_test_autoconf.tcl" ;;
     "src/macports1.0/macports_fastload.tcl") CONFIG_FILES="$CONFIG_FILES src/macports1.0/macports_fastload.tcl" ;;
+    "src/package1.0/package_test_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/package1.0/package_test_autoconf.tcl" ;;
     "src/pextlib1.0/Makefile") CONFIG_FILES="$CONFIG_FILES src/pextlib1.0/Makefile" ;;
     "src/port1.0/port_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/port1.0/port_autoconf.tcl" ;;
+    "src/port1.0/port_test_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/port1.0/port_test_autoconf.tcl" ;;
     "src/programs/Makefile") CONFIG_FILES="$CONFIG_FILES src/programs/Makefile" ;;
     "src/registry2.0/registry_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/registry2.0/registry_autoconf.tcl" ;;
     "src/pkg_mkindex.sh") CONFIG_FILES="$CONFIG_FILES src/pkg_mkindex.sh" ;;

Modified: trunk/base/configure.ac
===================================================================
--- trunk/base/configure.ac	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/configure.ac	2013-09-19 00:14:10 UTC (rev 111325)
@@ -396,9 +396,12 @@
 	src/Makefile
 	src/machista1.0/Makefile
 	src/macports1.0/macports_autoconf.tcl
+	src/macports1.0/macports_test_autoconf.tcl
 	src/macports1.0/macports_fastload.tcl
+	src/package1.0/package_test_autoconf.tcl
 	src/pextlib1.0/Makefile
 	src/port1.0/port_autoconf.tcl
+	src/port1.0/port_test_autoconf.tcl
 	src/programs/Makefile
 	src/registry2.0/registry_autoconf.tcl
 ])


Property changes on: trunk/base/portmgr/fedora/macports.spec
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/portmgr/fedora/macports.spec:37343-46937
/branches/gsoc11-rev-upgrade/base/portmgr/fedora/macports.spec:78828-88375
/branches/universal-sanity/base/portmgr/fedora/macports.spec:51872-52323
/branches/variant-descs-14482/base/portmgr/fedora/macports.spec:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base/portmgr/fedora/macports.spec.in:30388-57826
/users/perry/base-bugs_and_notes/portmgr/fedora/macports.spec:45682-46060
/users/perry/base-select/portmgr/fedora/macports.spec:44044-44692
   + /branches/gsoc08-privileges/base/portmgr/fedora/macports.spec:37343-46937
/branches/gsoc11-rev-upgrade/base/portmgr/fedora/macports.spec:78828-88375
/branches/gsoc13-tests/portmgr/fedora/macports.spec:106692-111324
/branches/universal-sanity/base/portmgr/fedora/macports.spec:51872-52323
/branches/variant-descs-14482/base/portmgr/fedora/macports.spec:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base/portmgr/fedora/macports.spec.in:30388-57826
/users/perry/base-bugs_and_notes/portmgr/fedora/macports.spec:45682-46060
/users/perry/base-select/portmgr/fedora/macports.spec:44044-44692


Property changes on: trunk/base/src/macports1.0
___________________________________________________________________
Modified: svn:ignore
   - *.dylib
macports_autoconf.tcl
macports_fastload.tcl
pkgIndex.tcl

   + *.dylib
macports_autoconf.tcl
macports_test_autoconf.tcl
macports_fastload.tcl
pkgIndex.tcl


Modified: trunk/base/src/macports1.0/Makefile
===================================================================
--- trunk/base/src/macports1.0/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/macports1.0/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -16,8 +16,7 @@
 pkgIndex.tcl: $(SRCS)
 
 test::
-	${TCLSH} tests/macports_dlist.tcl
-	${TCLSH} tests/macports_util.tcl
+	$(TCLSH) ./tests/test.tcl -nocolor
 
 distclean:: clean
 	rm -f macports_autoconf.tcl macports_fastload.tcl ${SHLIB_NAME}

Copied: trunk/base/src/macports1.0/macports_test_autoconf.tcl.in (from rev 111324, branches/gsoc13-tests/src/macports1.0/macports_test_autoconf.tcl.in)
===================================================================
--- trunk/base/src/macports1.0/macports_test_autoconf.tcl.in	                        (rev 0)
+++ trunk/base/src/macports1.0/macports_test_autoconf.tcl.in	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,37 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
+# macports-autoconf.tcl.in
+# $Id: macports_autoconf.tcl.in 90070 2012-02-20 21:54:35Z jberry at macports.org $
+#
+# Copyright (c) 2006 - 2009, 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Apple Inc. nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+namespace eval macports::autoconf {
+    variable macports_tcl_dir "@macports_tcl_dir@"
+    variable prefix "@prefix@"
+}

Copied: trunk/base/src/macports1.0/tests/Portfile (from rev 111324, branches/gsoc13-tests/src/macports1.0/tests/Portfile)
===================================================================
--- trunk/base/src/macports1.0/tests/Portfile	                        (rev 0)
+++ trunk/base/src/macports1.0/tests/Portfile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,40 @@
+# $Id: Portfile 85472 2011-10-14 01:52:18Z dports at macports.org $
+
+PortSystem              1.0
+
+name                    fondu
+version                 060102
+revision                1
+platforms               darwin
+categories              print
+license                 BSD
+maintainers             nomaintainer
+homepage                http://fondu.sourceforge.net/
+master_sites            http://fondu.sourceforge.net/
+
+description             A set of programs to interconvert between Mac font \
+                        formats and pfb, ttf, otf and bdf files on UNIX.
+
+long_description        Dealing with Mac fonts is hard on other operating \
+                        systems because Mac fonts are stored in the resource \
+                        fork, and other operating systems do not support \
+                        this concept. Fondu will extract the resource fork \
+                        from either a MacBinary file or a BinHex file. Ufond \
+                        will create a resource fork inside a MacBinary file.
+
+checksums               md5 e20861beacddc1ab392bef7813641bf8
+extract.suffix          .tgz
+distfiles               [suffix ${name}_src-${version}]
+
+post-patch {
+    reinplace "s|^CFLAGS = -g \$(WFLAGS)|CFLAGS = -g \$(WFLAGS) ${configure.cppflags} ${configure.cflags} ${configure.ldflags} [get_canonical_archflags]|g" ${worksrcpath}/Makefile.in
+}
+
+configure.args          --bindir=${prefix}/bin \
+                        --mandir=${prefix}/share/man
+
+post-destroot {
+    eval xinstall -m 644 [glob ${worksrcpath}/*.1] ${destroot}${prefix}/share/man/man1/
+}
+
+test.run		yes

Copied: trunk/base/src/macports1.0/tests/macports.test (from rev 111324, branches/gsoc13-tests/src/macports1.0/tests/macports.test)
===================================================================
--- trunk/base/src/macports1.0/tests/macports.test	                        (rev 0)
+++ trunk/base/src/macports1.0/tests/macports.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,793 @@
+package require tcltest 2
+namespace import tcltest::*
+eval ::tcltest::configure $::argv
+
+set pwd [file normalize $argv0]
+set pwd [eval file join {*}[lrange [file split $pwd] 0 end-1]]
+
+source ../macports_test_autoconf.tcl
+source $macports::autoconf::macports_tcl_dir/macports1.0/macports_fastload.tcl
+package require macports 1.0
+
+# use custom macports.conf and sources.conf
+makeDirectory $pwd/tmpdir
+makeDirectory $pwd/tmpdir/share
+makeDirectory $pwd/tmpdir/var/macports/registry
+set fd [open $pwd/tmpdir/macports.conf w+]
+puts $fd "portdbpath $pwd/tmpdir/var/macports"
+puts $fd "prefix $pwd/tmpdir"
+puts $fd "variants_conf $pwd/tmpdir/variants.conf"
+puts $fd "sources_conf $pwd/sources.conf"
+puts $fd "applications_dir $pwd/tmpdir/Applications"
+puts $fd "frameworks_dir $pwd/tmpdir/Library/Frameworks"
+close $fd
+set env(PORTSRC) $pwd/tmpdir/macports.conf
+file link -symbolic $pwd/tmpdir/share/macports $macports::autoconf::prefix/share/macports
+close [open $pwd/tmpdir/variants.conf w+]
+
+# Debug options
+array set ui_options {}
+#set ui_options(ports_debug)   yes
+#set ui_options(ports_verbose) yes
+mportinit ui_options
+
+source ../../port1.0/portutil.tcl
+source ../../port1.0/portuninstall.tcl
+source ../../port1.0/portinstall.tcl
+source ../../registry2.0/portuninstall.tcl
+source ../../port1.0/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 uninstall_main {args} {
+    global subport version revision portvariants user_options
+    registry_uninstall::uninstall $subport $version $revision $portvariants [array get user_options]
+    return 0
+}
+
+proc findBinary {prog {autoconf_hint ""}} {
+    if {${autoconf_hint} != "" && [file executable ${autoconf_hint}]} {
+        return ${autoconf_hint}
+    } else {
+        if {[catch {set cmd_path [macports::binaryInPath ${prog}]} result] == 0} {
+            return ${cmd_path}
+        } else {
+            return -code error "${result} or at its MacPorts guration time tion, did you move it?"
+        }
+    }
+}
+
+
+
+test mportclose {
+    Mport close unit test.
+} -body {
+    set mport [mportopen file://.]
+    if {[catch {mportclose $mport}] != 0} {
+	   return "FAIL: cannot run mportclose"
+    }
+    if {[ditem_key $mport workername] != ""} {
+	   return "FAIL: port not closed"
+    }
+    return "Mport close successful."
+} -result "Mport close successful."
+
+
+test mportinfo {
+    Mport info uni test.
+} -setup {
+    set mport [mportopen file://.]
+} -body {
+    set res [mportinfo $mport]
+    if {[lindex $res 2] != "canonical_active_variants"} {
+        return "FAIL: cannot get ::PortInfo"
+    }
+    return "Mport info successful."
+} -cleanup {
+    mportclose $mport
+} -result "Mport info successful."
+
+
+test mportopen_installed {
+    Mport installed unit test.
+} -constraints {
+    root
+} -setup {
+    set os.platform darwin
+    set macosx_version 10.8
+    set os.major 10
+    set os_version 11
+    set os_arch i386
+
+    set supported_archs {}
+    set configure.build_arch build_arch
+    set portarchivetype tgz
+
+    set destpath $pwd/work/destroot
+    set portdbpath $pwd/portdbpath
+    set workpath $pwd/fondu/work
+    set portpath $pwd
+
+    set subport fondu
+    set version 3.0
+    set revision 1
+    set epoch i386
+
+    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 $portname]]
+    }
+
+    source $pwd/../../port1.0/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
+
+    # portinstall setup
+    interp alias {} _cd {} cd
+    set macosx_deployment_target $pwd/deploy_target
+    file mkdir $pwd/$subport
+    file link -symbolic $pwd/$subport/work $pwd/work
+
+    if {[catch {portinstall::install_main}] != 0} {
+        return "FAIL: cannot install port"
+    }
+
+    set variants {}
+    set options {}
+
+} -body {
+    set res [mportopen_installed $subport $version $revision $variants $options]
+    if {![string match "ditem_*" $res]} {
+	   return "FAIL: installed port not opened"
+    }
+
+    if {[catch {mportclose_installed $res}] != 0} {
+	   return "FAIL: cannot close port"
+    }
+    if {[catch {mportclose_installed $res}] != 1} {
+	   return "FAIL: installed port not closed"
+    }
+    return "Installed port open successful."
+
+} -cleanup {
+    set res [uninstall_main]
+    mportclose $mport
+
+    file delete -force $pwd/work
+    file delete -force $pwd/$subport
+} -result "Installed port open successful."
+
+
+test ui_isset {
+    Ui is set unit test.
+} -body {
+    namespace eval macports {
+	array set ui_options { test yes }
+    }
+    if {[macports::ui_isset test] != 1} {
+	   return "FAIL: set option not detected"
+    }
+    if {[macports::ui_isset port] != 0} {
+	   return "FAIL: unset option detected"
+    }
+    return "ui_isset successful."
+} -result "ui_isset successful."
+
+
+test global_option_isset {
+    Global option is set unit test.
+} -body {
+    namespace eval macports {
+	array set global_options { test yes }
+    }
+    if {[macports::global_option_isset test] != 1} {
+	   return "FAIL: set option not detected"
+    }
+    if {[macports::global_option_isset port] != 0} {
+	   return "FAIL: unset option detected"
+    }
+    return "Global option isset successful."
+} -result "Global option isset successful."
+
+
+test init_logging {
+    Init logging unit test.
+} -constraints {
+    root
+} -setup {
+    set mport [mportopen file://.]
+} -body {
+    if {[macports::init_logging $mport] != 0} {
+	   return "FAIL: incorrect channels"
+    }
+    if {$macports::channels(any) != "stdout debuglog"} {
+	   return "FAIL: incorrect channels(any)"
+    }
+    if {$macports::channels(debug) != "debuglog"} {
+	   return "FAIL: incorrect channels(debug)"
+    }
+    return "Init logging successful."
+} -cleanup {
+    mportclose $mport
+} -result "Init logging successful."
+
+
+test ch_logging {
+    Channel logging unit test. Assumes main.log filename.
+} -constraints {
+    root
+} -setup {
+    set mport [mportopen file://.]
+
+    set portname [_mportkey $mport subport]
+    set portpath [_mportkey $mport portpath]
+    set logname [macports::getportlogpath $portpath $portname]
+    file delete -force $logname
+
+} -body {
+    if {[macports::ch_logging $mport] != 0} {
+	   return "FAIL: channels not set"
+    }
+    if {![file exists $logname]} {
+	   return "FAIL: logname dir missing"
+    }
+    if {![file exists $logname/main.log]} {
+	   return "FAIL: main.log missing"
+    }
+    return "Channel logging successful."
+
+} -cleanup {
+    mportclose $mport
+} -result "Channel logging successful."
+
+
+test push_log {
+    Push log unit test.
+} -constraints {
+    root
+} -setup {
+    set mport [mportopen file://.]
+} -body {
+    set ::logenabled 1
+    if {[catch {macports::push_log $mport}] != 0} {
+	   return "FAIL: cannot push log"
+    }
+    if {[lindex $::logstack 0] != [list $::debuglog $::debuglogname]} {
+	   return "FAIL: incorrect logstack"
+    }
+    return "Push log successful."
+} -cleanup {
+    mportclose $mport
+} -result "Push log successful."
+
+
+# test pop_log
+# test set_phase
+# test ui_message
+# test ui_init
+# test ui_prefix_default
+# test ui_channels_default
+# test ui_warn_once
+# test puts
+
+
+test findBinary {
+    Find binary unit test.
+} -body {
+    if {[macports::findBinary pwd ls] != "/bin/pwd"} {
+	   return "FAIL: wrong binary"
+    }
+    if {[macports::findBinary pwd /bin/ls] != "/bin/ls"} {
+	   return "FAIL: wrong binary"
+    }
+    return "Find binary successful."
+} -result "Find binary successful."
+
+
+test binaryInPath {
+    Binary in path unit test.
+} -body {
+    if {[catch {macports::binaryInPath zz}] != 1} {
+	   return "FAIL: invalid binary found"
+    }
+    if {[macports::binaryInPath ls] != "/bin/ls"} {
+	   return "FAIL: wrong binary found"
+    }
+    return "Binary in path successful."
+} -result "Binary in path successful."
+
+
+# test getoption
+
+
+test setxcodeinfo {
+    Set XCode info unit test.
+} -constraints {
+    root
+} -body {
+    unset macports::xcodeversion
+
+    if {[macports::setxcodeinfo a b c] != ""} {
+	   return "FAIL: xcode binary not found"
+    }
+    if {![info exists macports::xcodeversion]} {
+	   return "FAIL: xcodeversion unset"
+    }
+    return "Set XCode version successful."
+} -result "Set XCode version successful."
+
+
+test set_developer_dir {
+    Set developer dir unit test. Tests only for correct xcode-select dir.
+} -constraints {
+    root
+} -body {
+    unset macports::developer_dir
+
+    if {[macports::set_developer_dir a b c] != ""} {
+	   return "FAIL: cannot set dev dir"
+    }
+    if {![info exists macports::developer_dir]} {
+	   return "FAIL: developer_dir var no set"
+    }
+    return "Set developer dir successful."
+} -result "Set developer dir successful."
+
+
+test _is_valid_developer_dir {
+    Check valid dev dir unit test.
+} -body {
+    set macports::set_developer /Applications/Xcode.app/Contents/Developer
+    if {[macports::_is_valid_developer_dir $macports::developer_dir] != 1} {
+	   return "FAIL: valid dir not detected"
+    }
+    return "Valid dev dir successful."
+} -result "Valid dev dir successful."
+
+
+# test mportinit
+
+
+test mportshutdown {
+    Mport shutdown unit test.
+} -setup {
+    unset macports::ping_cache
+
+    set time [expr [clock seconds] - 86100]
+    set time_exp [expr [clock seconds] - 87000]
+    set macports::portdbpath $pwd/portdbpath
+    set macports::ping_cache(host1) [list test $time]
+    set macports::ping_cache(host2) [list test $time_exp]
+
+    file mkdir $macports::portdbpath
+    close [open $macports::portdbpath/pingtimes w+]
+
+} -body {
+    if {[mportshutdown] != ""} {
+	   return "FAIL: errors occured"
+    }
+
+    set res ""
+    append res "host1 \{test " $time "\}"
+    set fd [open $macports::portdbpath/pingtimes r]
+
+    if {[gets $fd] != $res} {
+	   return "FAIL: wrong value saved"
+    }
+    close $fd
+    return "Mportshutdown successful."
+
+} -cleanup {
+    file delete -force $macports::portdbpath
+} -result "Mportshutdown successful."
+
+
+test copy_xcode_plist {
+    Copy xcode plist unit test.
+} -constraints {
+    root
+} -body {
+    set target $pwd/target
+
+    if {[macports::copy_xcode_plist $target] != ""} {
+	   return "FAIL: cannot copy xcode plist"
+    }
+    if {![file exists $target/Library/Preferences/com.apple.dt.Xcode.plist]} {
+	   return "FAIL: missing plist file"
+    }
+    return "Copy xcode plist successful."
+} -cleanup {
+    file delete -force $target
+} -result "Copy xcode plist successful."
+
+
+test worker_init {
+    Worker init unit test.
+} -setup {
+    set name [interp create]
+    set portpath $pwd/portpath
+    set porturl http://www.macports.org
+    set portbuildpath $pwd/build
+    set options {a b}
+    set variations {1 2}
+} -body {
+    macports::worker_init $name $portpath $porturl $portbuildpath $options $variations
+    if {$name != "interp0"} {
+	   return "FAIL: wrong workername"
+    }
+    if {[$name eval source Portfile] != "yes"} {
+	   return "FAIL: cannot load Portfile"
+    }
+    if {[$name eval findBinary ls] != "/bin/ls"} {
+	   return "FAIL: alias not created"
+    }
+    if {[$name eval return \$os_arch] != "i386"} {
+	   return "FAIL: var not set"
+    }
+    return "Worker init successful."
+} -result "Worker init successful."
+
+
+test create_thread {
+    Create thread unit test.
+} -body {
+    unset macports::portinterp_options
+    set macports::portinterp_options {a b}
+
+    set res [macports::create_thread]
+    if {![string match "tid0x*" $res]} {
+	   return "FAIL: cannot create thread"
+    }
+    return "Create thread successful."
+} -result "Create thread successful."
+
+
+# test get_tar_flags
+# test fetch_port
+
+
+test getprotocol {
+    Get protocol unit test.
+} -body {
+    if {[macports::getprotocol http://www.macports.org] != "http"} {
+	   return "FAIL: wrong protocol"
+    }
+    return "Get protocol successful."
+} -result "Get protocol successful."
+
+
+# test getportdir
+
+
+test getportresourcepath {
+    Get port resource path. Doesn't check for 'file' protocol.
+} -body {
+    set macports::portdbpath $pwd/portdbpath
+    set url "http://packages.macports.org/fondu/fondu-060102_1.darwin_12.x86_64.tbz2"
+    set default_path $pwd/portdbpath/sources/rsync.macports.org/release/tarballs/ports/_resources
+    set fallback_path $pwd/portdbpath/sources/packages.macports.org/fondu/fondu-060102_1.darwin_12.x86_64.tbz2/_resources
+
+    if {[macports::getportresourcepath $url "" yes] != $default_path} {
+	   return "FAIL: wrong resource path"
+    }
+    if {[macports::getportresourcepath $url "" no] != $fallback_path} {
+	   return "FAIL: wrong fallback path"
+    }
+    if {[macports::getportresourcepath $url "test" no] != "${fallback_path}/test"} {
+	   return "FAIL: wrong fallback path with subdir"
+    }
+
+    return "Get resource path successful."
+} -result "Get resource path successful."
+
+
+test getdefaultportresourcepath {
+    Get default port resource path unit test.
+} -body {
+    set path test/path
+    set macports::sources_default file://$pwd
+    if {[macports::getdefaultportresourcepath $path] != "${pwd}/_resources/${path}"} {
+	   return "FAIL: wrong file res path"
+    }
+
+    set macports::sources_default http://$pwd
+    set default_source_url [lindex ${macports::sources_default} 0]
+    set right_path [macports::getsourcepath $default_source_url]/_resources/test/path
+    if {[macports::getdefaultportresourcepath $path] != $right_path} {
+	   return "FAIL: wrong http res path"
+    }
+    return "Default res path successful."
+} -result "Default res path successful."
+
+
+# test mportopen
+
+
+# Covered by mportopen_installed
+# test mportclose_installed
+
+
+test mporttraverse {
+    Mport traverse unit test. Uses 3rd column of the Portfile.
+} -setup {
+    file mkdir $pwd/porttree
+    file mkdir $pwd/porttree/cat1/fondu
+    file mkdir $pwd/porttree/cat2/fondu
+
+    file copy -force $pwd/Portfile $pwd/porttree/cat1/fondu/Portfile
+    file copy -force $pwd/Portfile $pwd/porttree/cat2/fondu/Portfile
+
+    proc test_proc {file} {
+	   global pwd res
+	   set fd [open ${pwd}/porttree/${file}/Portfile r]
+	   gets $fd line
+	   append res [lindex [split $line " "] 3]
+    }
+
+    global res
+    set res ""
+} -body {
+    mporttraverse test_proc $pwd/porttree
+    if {$res != "8547285472"} {
+	   return "FAIL: porttree not traversed"
+    }
+    return "Mport traverse successful."
+} -cleanup {
+    file delete -force $pwd/porttree
+} -result "Mport traverse successful."
+
+
+# test _mportsearchpath
+# test _mportinstalled
+# test _mportactive
+# test _portnameactive
+# test _mportispresent
+# test _mporterrorifconflictsinstalled
+# test _mportexec
+# test mportexec
+# test _upgrade_mport_deps
+# test _get_registry_archs
+# test getsourcepath
+# test _source_is_snapshot
+# test getportbuildpath
+# test getportlogpath
+# test getportworkpath_from_buildpath
+# test getportworkpath_from_portdir
+# test getindex
+# test mportsync
+# test mportsearch
+# test mportlookup
+# test mportlistall
+# test _mports_load_quickindex
+# test mports_generate_quickindex
+
+
+# test _mportkey
+# test mportdepends
+# test _mport_supports_archs
+# test _mport_archs
+# test _active_supports_archs
+# test _active_archs
+# test _explain_arch_mismatch
+# test _mport_has_deptypes
+# test _target_needs_deps
+# test _deptypes_for_target
+# test selfupdate
+# test upgrade
+# test _upgrade
+# test _upgrade_dependencies
+
+
+test mportselect {
+    Mport select unit test.
+} -setup {
+    set macports::prefix $pwd/prefix
+
+    file mkdir $macports::prefix/etc/select/group
+    set f1 [open $macports::prefix/etc/select/group/file1 w+]
+    set f2 [open $macports::prefix/etc/select/group/file2 w+]
+    set f3 [open $macports::prefix/srcs w+]
+    puts $f1 "srcs\n"
+    close $f1
+    close $f2
+    close $f3
+
+    set fd [open $macports::prefix/etc/select/group/base w+]
+    puts $fd "a\nb"
+    close $fd
+} -body {
+    if {[mportselect list group] != {file1 file2}} {
+	   return "FAIL: files not listed"
+    }
+    if {[mportselect set group file1] != ""} {
+	   reutrn "FAIL: cannot set links"
+    }
+    if {![file exists $macports::prefix/a]} {
+	   return "FAIL: link not created"
+    }
+    if {[mportselect show group] != "file1"} {
+	   return "FAIL: file not selected"
+    }
+    return "Mport select successful."
+
+} -cleanup {
+    file delete -force $macports::prefix
+} -result "Mport select successful."
+
+
+test gettmpdir {
+    Get tmp dir unit test.
+} -body {
+    global env
+    set env(TMPDIR) temporal
+    if {[macports::gettmpdir] != "temporal"} {
+	   return "FAIL: set temp dir not detected"
+    }
+    unset env(TMPDIR)
+    if {[macports::gettmpdir] != "/tmp"} {
+	   return "FAIL: default value not set"
+    }
+    return "Get tmp dir successful."
+} -result "Get tmp dir successful."
+
+
+test arch_runnable {
+    Arch runnable unit test.
+} -body {
+    set macports::os_major 12
+    set macports::os_arch i386
+    set macports::os_platform darwin
+    if {[macports::arch_runnable ppc1] != no} {
+	   return "FAIL: major:12 arch:i386 arch:ppc* not detected"
+    }
+    if {[macports::arch_runnable ppc64] != no} {
+	   return "FAIL: major:12 arch:i386 arch:ppc64 not detected"
+    }
+    set macports::os_major 7
+    set macports::os_arch i386
+    set macports::os_platform darwin
+    if {[macports::arch_runnable x86_64] != no} {
+	   return "FAIL: major:7 arch:i386 arch:x86_64 not detected"
+    }
+    set macports::os_major 12
+    set macports::os_arch i386
+    set macports::os_platform darwin
+    if {[macports::arch_runnable x86_64] != yes} {
+	   return "FAIL: major:12 arch:i386 arch:x86_64 not detected"
+    }
+    return "Arch runnable successful."
+} -result "Arch runnable successful."
+
+
+# test revupgrade
+# test revupgrade_scanandrebuild
+
+
+test path_is_in_prefix {
+    Path is in prefix unit test.
+} -body {
+    set macports::applications_dir appdir
+    if {[macports::path_is_in_prefix appdir/test/port] != yes} {
+	   return "FAIL: application dir not detected"
+    }
+    set macports::prefix prefix
+    if {[macports::path_is_in_prefix prefix/test/port] != yes} {
+	   return "FAIL: prefix not detected"
+    }
+    if {[macports::path_is_in_prefix test/port] != no} {
+	   return "FAIL: no prefix detected"
+    }
+    return "Path prefix successful."
+} -result "Path prefix successful."
+
+
+test revupgrade_handle_special_paths {
+    Revupgrade handle special paths unit test.
+} -body {
+    set res [macports::revupgrade_handle_special_paths fname test_path]
+    if {$res != "test_path"} {
+	   return "FAIL: wrong path"
+    }
+    set res [macports::revupgrade_handle_special_paths fname @loader_path/test_load]
+    if {$res != "./test_load"} {
+	   return "FAIL: wrong load path"
+    }
+    return "Revupgrade handle special path successful."
+} -result "Revupgrade handle special path successful."
+
+
+# test revupgrade_buildgraph
+
+
+test get_pingtime {
+    Get ping time unit test.
+} -setup {
+    set time [expr [clock seconds] - 86300]
+    set macports::ping_cache(macports.org) [list MacPorts $time]
+    set macports::host_blacklisted(macports_blacklist) [list black $time]
+    set macports::host_preferred(macports_pref) [list pref $time]
+
+} -body {
+    if {[macports::get_pingtime macports.org] != "MacPorts"} {
+	   return "FAIL: wrong ping time"
+    }
+    if {[macports::get_pingtime macports_blacklist] != -1} {
+	   return "FAIL: wrong time for blacklisted host"
+    }
+    if {[macports::get_pingtime macports_pref] != 1} {
+	   return "FAIL: wrong time for preferred host"
+    }
+    return "Get ping time successful."
+} -result "Get ping time successful."
+
+
+test set_pingtime {
+    Set ping time unit test.
+} -body {
+    set macports::ping_cache(macports) {}
+    if {[lindex [macports::set_pingtime macports 007] 0] != 007} {
+	   return "FAIL: ping time not set"
+    }
+    return "Set ping time successful."
+} -result "Set ping time successful."
+
+
+test get_archive_sites_conf_values {
+    Get archive sites conf values unit test.
+} -setup {
+    file mkdir $pwd/archive_sites
+    set fd [open $pwd/archive_sites/archive_sites.conf w+]
+    puts $fd "name fondu"
+    puts $fd "urls macports.org"
+    puts $fd "type tgz"
+    close $fd
+
+    set macports::autoconf::macports_conf_path $pwd/archive_sites
+
+} -body {
+    set res [macports::get_archive_sites_conf_values]
+    if {[lindex [split $res " "] 1] != "macports.org:nosubdir"} {
+	   return "FAIL: name not set"
+    }
+    if {[lindex [split $res " "] 3] != "tgz"} {
+	   return "FAIL: wrong type set"
+    }
+
+    set macports::archive_sites_conf_values {a b c}
+    if {[macports::get_archive_sites_conf_values] != {a b c}} {
+	   return "FAIL: wrong  result for bad conf file"
+    }
+    return "Get archive sites conf values successful."
+
+} -cleanup {
+    file delete -force $pwd/archive_sites
+} -result "Get archive sites conf values successful."
+
+
+cleanupTests

Deleted: trunk/base/src/macports1.0/tests/macports_dlist.tcl
===================================================================
--- trunk/base/src/macports1.0/tests/macports_dlist.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/macports1.0/tests/macports_dlist.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,114 +0,0 @@
-#!/usr/bin/env tclsh
-# macports1.0/test_dlist.tcl
-# $Id$
-#
-# Copyright (c) 2007 The MacPorts Project
-# Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-
-# Test suite for macports_dlist package.
-
-#lappend auto_path .
-#package require macports_dlist 1.0
-source macports_dlist.tcl
-
-puts ""
-puts "Testing ditem"
-
-puts -nonewline "Checking ditem_create... "
-if {[catch {ditem_create} ditem] || $ditem == ""} {
-	puts "failed: $ditem"
-} else {
-	puts "ok"
-}
-
-puts -nonewline "Checking ditem_key... "
-if {[catch {ditem_key $ditem provides "foo"} value] || $value != "foo"} {
-	puts "failed: $value"
-} else {
-	puts "ok"
-}
-
-puts -nonewline "Checking ditem_append... "
-if {[catch {ditem_append $ditem provides "bar"} value] || $value != {foo bar}} {
-	puts "failed: $value"
-} else {
-	puts "ok"
-}
-
-puts -nonewline "Checking ditem_contains... "
-set value2 ""
-if {[catch {ditem_contains $ditem provides "foo"} value] || $value != 1 ||
-	[catch {ditem_contains $ditem provides "zzz"} value2] || $value2 != 0} {
-	puts "failed: ${value}\n${value2}"
-} else {
-	puts "ok"
-}
-
-puts ""
-puts "Testing dlist"
-
-puts -nonewline "Checking dlist_search... "
-if {[catch {dlist_search [list $ditem] provides "bar"} value] || $value != $ditem} {
-	puts "failed: $value"
-} else {
-	puts "ok"
-}
-
-puts -nonewline "Checking dlist_has_pending... "
-if {[catch {dlist_has_pending [list $ditem] "foo"} value] || $value != 1} {
-	puts "failed: $value"
-} else {
-	puts "ok"
-}
-
-puts -nonewline "Checking dlist_count_unmet... "
-array set status [list foo 1 bar 0]
-if {[catch {dlist_count_unmet [list] status "foo"} value] || $value != 0 ||
-	[catch {dlist_count_unmet [list] status "bar"} value2] || $value2 != 1} {
-	puts "failed: ${value}\n${value2}"
-} else {
-	puts "ok"
-}
-
-# Replicate Shantonu's Bug #354 to test dlist functionality.
-# https://trac.macports.org/ticket/354
-# A depends on B, C.
-# B depends on C.
-# C has no dependencies.
-
-set A [ditem_create]
-ditem_key $A provides A
-ditem_append $A requires B
-ditem_append $A requires C
-
-set B [ditem_create]
-ditem_key $B provides B
-ditem_append $B requires C
-
-set C [ditem_create]
-ditem_key $C provides C
-
-array set status [list]
-puts -nonewline "Checking dlist_get_next... "
-if {[catch {dlist_get_next [list $A $B $C] status} value] || $value != $C} {
-	puts "failed: ${value}"
-} else {
-	puts "ok"
-}
-
-puts -nonewline "Checking dlist_eval... "
-proc handler {ditem} { puts -nonewline "[ditem_key $ditem provides] " }
-if {[catch {dlist_eval [list $A $B $C] {} handler} value] || $value != {}} {
-	puts "failed: ${value}"
-} else {
-	puts "ok"
-}
-
-puts -nonewline "Checking dlist_append_dependents... "
-if {[catch {dlist_append_dependents [list $A $B $C] $B {}} value] || $value != [list $B $C]} {
-	puts "failed: ${value}"
-} else {
-	puts "ok"
-}
-
-

Copied: trunk/base/src/macports1.0/tests/macports_dlist.test (from rev 111324, branches/gsoc13-tests/src/macports1.0/tests/macports_dlist.test)
===================================================================
--- trunk/base/src/macports1.0/tests/macports_dlist.test	                        (rev 0)
+++ trunk/base/src/macports1.0/tests/macports_dlist.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,215 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source ../macports_test_autoconf.tcl
+source $macports::autoconf::macports_tcl_dir/macports1.0/macports_fastload.tcl
+package require macports 1.0
+
+# Debug options
+array set ui_options {}
+#set ui_options(ports_debug)   yes
+#set ui_options(ports_verbose) yes
+mportinit ui_options
+
+source ../macports_dlist.tcl
+
+
+test dlist_match_multi {
+    Dlist match multi unit test.
+} -setup {
+    set mport [mportopen file://.]
+    set crit {
+	   provides fondu
+	   porturl file://.
+    }
+    set crit2 { provides fondu2 }
+
+} -body {
+    if {[dlist_match_multi $mport $crit] != $mport} {
+	   return "FAIL: correct dlist not matched"
+    }
+    if {[dlist_match_multi $mport $crit2] != ""} {
+	   return "FAIL: incorrect dlist matched"
+    }
+    return "dlist match successful."
+} -cleanup {
+    mportclose $mport
+} -result "dlist match successful."
+
+
+test dlist_search {
+    Dlist search unit test.
+} -setup {
+    set mport [mportopen file://.]
+} -body {
+    if {[dlist_search $mport provides fondu] != $mport} {
+	   return "FAIL: matching item not found"
+    }
+    if {[dlist_search $mport provides fondu2] != ""} {
+	   return "FAIL: wrong item detected"
+    }
+    return "dlist successful."
+} -cleanup {
+    mportclose $mport
+} -result "dlist successful."
+
+
+test dlist_delete {
+    Dlist delete unit test.
+} -setup {
+    set mport [mportopen file://.]
+    set dlist [list]
+    lappend dlist $mport
+} -body {
+    if {[dlist_delete dlist $mport] != ""} {
+	   return "FAIL: cannot run dlist_delete"
+    }
+    if {$dlist != ""} {
+	   return "FAIL: port not removed from list"
+    }
+    return "Dlist delete successful."
+} -cleanup {
+    mportclose $mport
+} -result "Dlist delete successful."
+
+
+test dlist_has_pending {
+    Dlist has pending unit test.
+} -setup {
+    set mport [mportopen file://.]
+} -body {
+    if {[dlist_has_pending $mport fondu] != 1} {
+	   return "FAIL: not detected"
+    }
+    if {[dlist_has_pending $mport provides] != 0} {
+	   return "FAIL: incorrect detected"
+    }
+    return "dlist pending successful."
+} -cleanup {
+    mportclose $mport
+} -result "dlist pending successful."
+
+
+test dlist_count_unmet {
+    Dlist count unmet unit test.
+} -setup {
+    set mport [mportopen file://.]
+    array set statusdict {
+	   vara 0
+	   varb 0
+	   varc 1
+    }
+    set tokens {vara varb vard}
+} -body {
+    if {[dlist_count_unmet $mport statusdict $tokens] != 3} {
+	   return "FAIL: wrong unmet number"
+    }
+    return "count unmet successful."
+} -cleanup {
+    mportclose $mport
+} -result "count unmet successful."
+
+
+# test ditem_create
+# test ditem_delete
+
+
+test ditem_key {
+    Ditem key unit test.
+} -setup {
+    set mport [mportopen file://.]
+} -body {
+    if {[ditem_key $mport {provides}] != "fondu"} {
+	   return "FAIL: wrong key value"
+    }
+    if {[ditem_key $mport {wants}] != ""} {
+	   return "FAIL: wrong key detected"
+    }
+    return "ditem key successful."
+} -cleanup {
+    mportclose $mport
+} -result "ditem key successful."
+
+
+# test ditem_append
+# test ditem_append_unique
+# test ditem_contains
+
+
+test dlist_append_dependents {
+    Dlist append dependents unit test.
+} -setup {
+    set mport [mportopen file://.]
+    set result {fondu2}
+} -body {
+    if {[dlist_append_dependents $mport provides $result] != {fondu2 provides}} {
+	   return "FAIL: wrong depends"
+    }
+    return "Append depends successful."
+} -cleanup {
+    mportclose $mport
+} -result "Append depends successful."
+
+
+test dlist_get_next {
+    Dlist get next unit test.
+} -setup {
+    set mport [mportopen file://.]
+    set dict {fondu}
+} -body {
+    if {[dlist_get_next $mport $dict] != $mport} {
+	   return "FAIL: wrong dlist"
+    }
+    return "dlist get next successful."
+} -cleanup {
+    mportclose $mport
+} -result "dlist get next successful."
+
+
+test dlist_eval {
+    Dlist eval unit test.
+} -setup {
+    set mport [mportopen file://.]
+    proc cond {arg} {
+	   if {[string match "ditem_*" $arg] != 0} {
+            return 0
+	   } else {
+            return 1
+	   }
+    }
+    proc handler {arg} {}
+} -body {
+    if {[dlist_eval $mport cond handler] != ""} {
+	   return "FAIL: wrong value returned"
+    }
+    return "dlist eval successful."
+} -cleanup {
+    mportclose $mport
+} -result "dlist eval successful."
+
+
+# test ditem_create
+# test ditem_delete
+# test ditem_key
+# test ditem_append
+# test ditem_append_unique
+
+
+test ditem_contains {
+    Ditem contains unit test.
+} -setup {
+    set mport [mportopen file://.]
+} -body {
+    if {[ditem_contains $mport provides] != 1} {
+	   return "FAIL: valid key not detected"
+    }
+    if {[ditem_contains $mport wants] != 0} {
+	   return "FAIL: invalid key detected"
+    }
+    return "ditem contains successful."
+} -cleanup {
+    mportclose $mport
+} -result "ditem contains successful."
+
+
+cleanupTests

Deleted: trunk/base/src/macports1.0/tests/macports_util.tcl
===================================================================
--- trunk/base/src/macports1.0/tests/macports_util.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/macports1.0/tests/macports_util.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,476 +0,0 @@
-# test_util.tcl
-# $Id$
-#
-# Comprehensive test file for macports_util.tcl
-# Written by Kevin Ballard <eridius at macports.org>
-
-source ./macports_util.tcl
-
-array set options {t 0 w 0}
-
-set ::traceNest ""
-set ::traceSquelch 0
-set ::traceSquelchNest ""
-proc dotrace {args} {
-    global traceNest options
-    flush stdout
-    set command [lindex $args 0]
-    if {$options(w) > 0} {
-        # trim command to 1 line
-        if {[llength [set lines [split $command "\n"]]] > 1} {
-            set command "[lindex $lines 0] [ansi fg-blue]...[ansi reset]"
-        }
-    }
-    set op [lindex $args end]
-    switch $op {
-        enter { append traceNest "#" }
-        enterstep { append traceNest "+" }
-    }
-    switch $op {
-        enter {
-            puts stderr "[ansi fg-yellow inverse]$traceNest>[ansi reset] $command"
-            set ::traceSquelch 0
-        }
-        enterstep {
-            if {!$::traceSquelch} {
-                puts stderr "[ansi fg-yellow]$traceNest>[ansi reset] $command"
-                if {[llength [info procs [lindex [split $command] 0]]] > 0} {
-                    # it's a proc, lets start squelching
-                    set ::traceSquelch 1
-                    set ::traceSquelchNest $::traceNest
-                }
-            }
-        }
-        leave -
-        leavestep {
-            if {$op eq "leavestep" && $::traceSquelch && $::traceNest eq $::traceSquelchNest} {
-                set ::traceSquelch 0
-            }
-            if {$op eq "leave" || !$::traceSquelch} {
-                set code [lindex $args 1]
-                set result [lindex $args 2]
-                if {$options(w) > 0} {
-                    # trim result just like command
-                    if {[llength [set lines [split $result "\n"]]] > 1} {
-                        set result "[lindex $lines 0] [ansi fg-blue]...[ansi reset]"
-                    }
-                }
-                if {$op eq "leave"} {
-                    set prefix "[ansi fg-blue inverse]$traceNest"
-                } else {
-                    set prefix "[ansi fg-blue]$traceNest"
-                }
-                if {$code != 0} {
-                    puts stderr "$prefix =\[$code\]>[ansi reset] $result"
-                } else {
-                    puts stderr "$prefix =>[ansi reset] $result"
-                }
-            }
-        }
-    }
-    switch $op {
-        leave -
-        leavestep {
-            set traceNest [string range $traceNest 0 end-1]
-        }
-    }
-}
-while {[llength $argv] > 0} {
-    set arg [lshift argv]
-    if {$arg eq "--"} {
-        break
-    } elseif {[string match -* $arg]} {
-        set arg [string range $arg 1 end]
-        while {[string length $arg] > 0} {
-            set opt [string index $arg 0]
-            set arg [string range $arg 1 end]
-            switch $opt {
-                t { incr options(t) }
-                w { incr options(w) }
-                default {
-                    error "Unknown option: -$opt"
-                }
-            }
-        }
-    } else {
-        lunshift argv $arg
-        break
-    }
-}
-if {$options(t) > 0} {
-    set ops {enter leave}
-    if {$options(t) > 1} {
-        lappend ops enterstep leavestep
-    }
-    set util_list {ldindex lpop lpush lshift lunshift try throw}
-    if {[llength $argv] > 0} {
-        set list $argv
-        if {[set idx [lsearch -exact $list *]] != -1} {
-            set list [eval lreplace [list $list] $idx $idx $util_list]
-        }
-    } else {
-        set list $util_list
-    }
-    foreach arg $list {
-        trace add execution $arg $ops dotrace
-    }
-}
-
-proc init {name value} {
-    set name [list $name]
-    set value [list $value]
-    uplevel 1 [subst -nocommands {
-        set $name $value
-        set $name-bak [set $name]
-    }]
-}
-
-proc restore {name} {
-    set name [list $name]
-    uplevel 1 [subst -nocommands {
-        if {[info exists $name-bak]} {
-            set $name [set $name-bak]
-        } else {
-            unset $name
-        }
-    }]
-}
-
-array set kStateToAnsiTable {
-    error fg-magenta
-    expected fg-cyan
-    correct fg-green
-    wrong fg-red
-}
-
-array set kAnsiTable {
-    reset           0
-    
-    bold            1
-    dim             2
-    underline       4
-    blink           5
-    inverse         7
-    hidden          8
-    
-    fg-black        30
-    fg-red          31
-    fg-green        32
-    fg-yellow       33
-    fg-blue         34
-    fg-magenta      35
-    fg-cyan         36
-    fg-white        37
-    fg-default      39
-    
-    bg-black        40
-    bg-red          41
-    bg-green        42
-    bg-yellow       43
-    bg-blue         44
-    bg-magenta      45
-    bg-cyan         46
-    bg-white        47
-    bg-default      49
-}
-
-proc ansi {args} {
-    global kAnsiTable
-    if {[llength $args] == 0} {
-        error "wrong # args: should be \"ansi code ...\""
-    }
-    set colors {}
-    foreach code $args {
-        lappend colors $kAnsiTable($code)
-    }
-    return "\033\[[join $colors ";"]m"
-}
-
-proc state {code} {
-    global kStateToAnsiTable
-    return [ansi $kStateToAnsiTable($code)]
-}
-
-proc line {cmd expected args} {
-    uplevel 1 [list block $cmd $cmd $expected] $args
-}
-
-proc block {name cmd expected args} {
-    if {[set err [catch {uplevel 1 $cmd} value]]} {
-        set savedErrorInfo $::errorInfo
-        set savedErrorCode $::errorCode
-        if {$expected eq "-error" && $err == 1} {
-            if {[llength $args] > 0} {
-                set errCode [lindex $args 0]
-                if {$errCode == $savedErrorCode} {
-                    if {[llength $args] > 1} {
-                        set errMsg [lindex $args 1]
-                        if {$errMsg == $value} {
-                            set code expected
-                        } else {
-                            set code error
-                        }
-                    } else {
-                        set code expected
-                    }
-                } else {
-                    set code error
-                }
-            } else {
-                set code expected
-            }
-        } elseif {$expected eq "-return" && $err == 2} {
-            if {[llength $args] > 0} {
-                set errMsg [lindex $args 0]
-                if {$errMsg == $value} {
-                    set code expected
-                } else {
-                    set code error
-                }
-            } else {
-                set code expected
-            }
-        } elseif {$expected eq "-break" && $err == 3} {
-            set code expected
-        } else {
-            set code error
-        }
-    } elseif {$value == $expected} {
-        set code correct
-    } else {
-        set code wrong
-    }
-    if {$code eq "error"} {
-        append value "\n$savedErrorInfo"
-    }
-    puts "[state $code]$name =[if {$err != 0} {format \[$err\]}]> $value[ansi reset]"
-}
-
-proc var {name expected} {
-    set exists [uplevel 1 info exists [list $name]]
-    if {!$exists} {
-        set value "does not exist"
-        if {$expected eq "-unset"} {
-            set code expected
-        } else {
-            set code error
-        }
-    } else {
-        set value [uplevel 1 set [list $name]]
-        if {$value == $expected} {
-            set code correct
-        } else {
-            set code wrong
-        }
-    }
-    puts "[state $code]$name: $value[ansi reset]"
-}
-
-if {[set err [catch {
-    namespace eval test {
-        namespace eval vars {}
-        init vars::ary(one) {1 2 {3 4}}
-        init vars::ary(zero) {1 {2 3 {"4 5" 6} 7} 8 9}
-        
-        var vars::ary(zero) {1 {2 3 {"4 5" 6} 7} 8 9}
-        line {ldindex vars::ary(zero) 1 2 0} {4 5}
-        var vars::ary(zero) {1 {2 3 6 7} 8 9}
-        line {ldindex vars::ary(zero) 1 1 0} 3
-        var vars::ary(zero) {1 {2 {} 6 7} 8 9}
-        line {ldindex vars::ary(zero) 1 2} 6
-        var vars::ary(zero) {1 {2 {} 7} 8 9}
-        line {ldindex vars::ary(zero) 1} {2 {} 7}
-        var vars::ary(zero) {1 8 9}
-        line {ldindex vars::ary(zero)} {1 8 9}
-        var vars::ary(zero) {}
-        
-        var vars::ary(one) {1 2 {3 4}}
-        line {lpop vars::ary(one)} {3 4}
-        var vars::ary(one) {1 2}
-        line {lpop vars::ary(one)} 2
-        var vars::ary(one) 1
-        line {lpop vars::ary(one)} 1
-        var vars::ary(one) {}
-        line {lpop vars::ary(one)} {}
-        var vars::ary(one) {}
-        
-        line {lpop vars::foo} -error NONE {can't read "vars::foo": no such variable}
-        
-        restore vars::ary(one)
-        var vars::ary(one) {1 2 {3 4}}
-        line {lshift vars::ary(one)} 1
-        var vars::ary(one) {2 {3 4}}
-        line {lshift vars::ary(one)} 2
-        var vars::ary(one) {{3 4}}
-        line {lshift vars::ary(one)} {3 4}
-        var vars::ary(one) {}
-        line {lshift vars::ary(one)} {}
-        var vars::ary(one) {}
-        
-        line {lshift vars::foo} -error NONE {can't read "vars::foo": no such variable}
-        
-        var vars::ary(two) -unset
-        line {lpush vars::ary(two) 1} 1
-        var vars::ary(two) 1
-        line {lpush vars::ary(two) 2 3 4 5} {1 2 3 4 5}
-        var vars::ary(two) {1 2 3 4 5}
-        line {lpush vars::ary(two) "this is a test"} {1 2 3 4 5 {this is a test}}
-        var vars::ary(two) {1 2 3 4 5 {this is a test}}
-        line {lpop vars::ary(two)} {this is a test}
-        var vars::ary(two) {1 2 3 4 5}
-        
-        line {lpush "foo bar" 3} {3}
-        var {foo bar} 3
-        
-        restore vars::ary(two)
-        var vars::ary(two) -unset
-        line {lunshift vars::ary(two) 5} 5
-        var vars::ary(two) 5
-        line {lunshift vars::ary(two) 4} {4 5}
-        var vars::ary(two) {4 5}
-        line {lunshift vars::ary(two) 1 2 3} {1 2 3 4 5}
-        var vars::ary(two) {1 2 3 4 5}
-        line {lunshift vars::ary(two) "this is a test"} {{this is a test} 1 2 3 4 5}
-        var vars::ary(two) {{this is a test} 1 2 3 4 5}
-        line {lshift vars::ary(two)} {this is a test}
-        var vars::ary(two) {1 2 3 4 5}
-        
-        # now test the try/throw stuff
-        line {throw} -error NONE {error: throw with no parameters outside of a catch}
-        line {throw 1 2 3 4} -error NONE {wrong # args: should be "throw ?type? ?message? ?info?"}
-        line {try {format 3} catch {} {}} -error NONE {invalid syntax in catch clause: type-list must contain at least one type}
-        line {try {format 3} finally {format 4} test} -error NONE {trailing args after finally clause}
-        block {basic try} {
-            try {
-                error "random error"
-            }
-        } -error NONE "random error"
-        block {try-finally} {
-            try {
-                error "try-finally error"
-            } finally {
-                set myVar "finally clause worked"
-            }
-        } -error NONE "try-finally error"
-        var myVar "finally clause worked"
-        block {try-finally-error} {
-            try {
-                error "try-finally error"
-            } finally {
-                error "finally error"
-            }
-        } -error NONE "finally error"
-        block {try-catch} {
-            try {
-                error "try-catch error"
-            } catch NONE {
-                format "catch clause worked"
-            }
-        } "catch clause worked"
-        block {try-catch-throw} {
-            try {
-                error "try-catch error"
-            } catch NONE {
-                set myVar "thrown"
-                throw
-            }
-        } -error NONE "try-catch error" ;# really should test errorInfo but that's messy
-        var myVar "thrown"
-        unset myVar
-        block {try-catch-finally} {
-            try {
-                error "try-catch-finally error"
-            } catch NONE {
-                set myVar "thrown"
-                throw
-            } finally {
-                lappend myVar "finally"
-            }
-        } -error NONE "try-catch-finally error"
-        var myVar "thrown finally"
-        block {try-catch-all} {
-            try {
-                error "this is a test"
-            } catch * {
-                format "catch-all worked"
-            }
-        } "catch-all worked"
-        block {try-catch-return} {
-            try {
-                error "this is a test"
-            } catch * {
-                return "catch-return worked"
-            }
-        } -return "catch-return worked"
-        block {try-catch-break} {
-            try {
-                error "this is a test"
-            } catch * {
-                break
-            }
-        } -break
-        block {try-catch-multiple} {
-            try {
-                error "this is a test"
-            } catch POSIX {
-                error "POSIX catch"
-            } catch * {
-                format "catch-all"
-            }
-        } "catch-all"
-        unset myVar
-        block {try-catch-multiple-finally} {
-            try {
-                error "this is a test"
-            } catch * {
-                lappend myVar "catch-all 1"
-            } catch * {
-                lappend myVar "catch-all 2"
-            } finally {
-                lappend myVar "finally"
-            }
-        } [list {catch-all 1}]
-        var myVar [list "catch-all 1" "finally"]
-        block {try-catch-types} {
-            try {
-                error "try-catch-types error" {} {MYERR arg1 arg2}
-            } catch POSIX {
-                error "POSIX catch"
-            } catch {{MY* arg*} code} {
-                format "caught code $code"
-            }
-        } "caught code MYERR arg1 arg2"
-        block {try-catch-vars} {
-            try {
-                error "random error"
-            } catch {* code msg info} {
-                set list {}
-                if {$code eq "NONE"} {
-                    lappend list "code: correct"
-                }
-                if {$msg eq "random error"} {
-                    lappend list "msg: correct"
-                }
-                if {[string match "random error\n*" $info]} {
-                    lappend list "info: probably correct"
-                }
-                join $list ", "
-            }
-        } "code: correct, msg: correct, info: probably correct"
-        block {try-break-catch} {
-            try {
-                break
-            } catch {*} {
-                error "catch triggered"
-            }
-        } -break
-        
-        # ensure the stack is sound
-        var ::_trycatch::catchStack {}
-    }
-} result]]} {
-    puts ""
-    puts "error: $result"
-    puts "code: $err"
-    puts $::errorInfo
-}

Copied: trunk/base/src/macports1.0/tests/macports_util.test (from rev 111324, branches/gsoc13-tests/src/macports1.0/tests/macports_util.test)
===================================================================
--- trunk/base/src/macports1.0/tests/macports_util.test	                        (rev 0)
+++ trunk/base/src/macports1.0/tests/macports_util.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,161 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source ../macports_test_autoconf.tcl
+source $macports::autoconf::macports_tcl_dir/macports1.0/macports_fastload.tcl
+package require macports 1.0
+
+
+test method_wrap {
+    Method wrap unit test.
+} -setup {
+    proc test_proc {a} {
+	   if { $a == 1} {
+	       return -code error $a -errorcode 7
+	   } else {
+            return $a
+	   }
+    }
+
+} -body {
+    macports_util::method_wrap test_proc
+    if {[test_proc 1] != 7} {
+	   return "FAIL: no wrap around method"
+    }
+    if {[test_proc arg] != "arg"} {
+	   return "FAIL: no wrap around method"
+    }
+    return "Method wrap successful."
+} -result "Method wrap successful."
+
+
+test ldindex {
+    Ldindex unit test.
+} -body {
+    set list {0 1 2 3}
+    if {[ldindex list 1] != 1} {
+	   return "FAIL: element not poped"
+    }
+    if {$list != {0 2 3}} {
+	   return "FAIL: wrong list remaining"
+    }
+    if {[catch {ldindex list 4}] != 1} {
+	   return "FAIL: error not detected"
+    }
+    if {[ldindex list] != {0 2 3}} {
+	   return "FAIL: not all elements poped"
+    }
+    if {$list != ""} {
+	   return "FAIL: list not emptied"
+    }
+    return "ldindex successful."
+} -result "ldindex successful."
+
+
+test lpop {
+    Lpop unit test.
+} -body {
+    set list {0 1 2}
+    if {[lpop list] != 2} {
+	   return "FAIL: element not poped"
+    }
+    if {$list != {0 1}} {
+	   return "FAIL: wrong element poped"
+    }
+    return "lpop successful."
+} -result "lpop successful."
+
+
+test lpush {
+    Lpush unit test.
+} -body {
+    set list {0 1}
+    if {[lpush list 2] != {0 1 2}} {
+	   return "FAIL: element not appended"
+    }
+    if {[lpush list 3 4] != {0 1 2 3 4}} {
+	   return "FAIL: multiple elements not appended"
+    }
+    if {[lpush list1 0] != 0} {
+	   return "FAIL: list not created"
+    }
+    return "lpop successful."
+} -result "lpop successful."
+
+
+test lshift {
+    Lshift unit test.
+} -body {
+    set list {0 1 2}
+    set list1 {}
+
+    if {[lshift list] != 0} {
+	   return "FAIL: wrong element poped"
+    }
+    if {$list != {1 2}} {
+	   return "FAIL: wrong list remaining"
+    }
+    if {[lshift list1] != ""} {
+	   return "FAIL: empty list not detected"
+    }
+    return "lshift successful."
+} -result "lshift successful."
+
+
+test lunshift {
+    Lunshift unit test.
+} -body {
+    set list {3 4}
+
+    if {[lunshift list 2] != {2 3 4}} {
+	   return "FAIL: element not inserted"
+    }
+    if {[lunshift list 0 1] != {0 1 2 3 4}} {
+	   return "FAIL: multiple elements not inserted"
+    }
+    if {[lunshift list2 0] != 0} {
+	   return "FAIL: list not created"
+    }
+    return "lunshift successful."
+} -result "lunshift successful."
+
+
+
+test throw {
+    Throw unit test.
+} -setup {
+    proc test_proc {arg} {
+	   catch {throw $arg} res
+	   return $res
+    }
+} -body {
+    if {[test_proc {7 msg info}] != "error: 7 msg info"} {
+	   return "FAIL: wrong error returneed"
+    }
+    if {[catch {test_proc ""}] != 0} {
+	   return "FAIL: wrong value returned"
+    }
+    return "throw successful."
+} -result "throw successful."
+
+
+test try {
+    Try unit test.
+} -setup {
+    proc test_proc {} {try {return 7} catch * {return 6}}
+    proc test_proc2 {} {try {error "msg" "info" 3} catch * {return 6}}
+} -body {
+    if {[test_proc] != 7} {
+	   return "FAIL: try clause not working"
+    }
+    if {[test_proc2] != 6} {
+	   reutrn "FAIL: catch clause not working"
+    }
+    if {[catch {try}] != 1} {
+	   return "FAIL: no args err not detected"
+    }
+    return "try successful."
+} -result "try successful."
+
+
+cleanupTests

Copied: trunk/base/src/macports1.0/tests/sources.conf (from rev 111324, branches/gsoc13-tests/src/macports1.0/tests/sources.conf)
===================================================================
--- trunk/base/src/macports1.0/tests/sources.conf	                        (rev 0)
+++ trunk/base/src/macports1.0/tests/sources.conf	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,28 @@
+# $Id$
+# MacPorts system-wide configuration file for ports tree sources.
+#
+# To change how MacPorts fetches base, see rsync_server and rsync_dir in
+# macports.conf.
+# To add a local source, add a "file://" entry.
+#
+#   Example: file:///Users/landonf/misc/MacPorts/ports
+#
+# To prevent a source from synchronizing when `port sync` is used,
+# append "[nosync]" at the end.
+#
+#   Example: file:///Users/landonf/misc/MacPorts/ports [nosync]
+#
+# Note that MacPorts parses source URLs in order; when a port appears in
+# multiple sources, it installs the first occurrence. For local sources
+# to shadow remote ones, "file://" URLs must come before other URLs.
+# A list of rsync mirrors is available at
+# https://trac.macports.org/wiki/Mirrors#Portfiles.
+#
+# If an "rsync://" URL points to a .tar file, a signed .rmd160 file must
+# exist in the same directory on the server and will be used to verify
+# its integrity.
+#
+# For proper functionality of various resources (port groups, mirror
+# sites, etc.), the primary MacPorts source must always be tagged
+# "[default]", even if switched from the default "rsync://" URL.
+rsync://rsync.macports.org/release/tarballs/ports.tar [default]

Copied: trunk/base/src/macports1.0/tests/test.tcl (from rev 111324, branches/gsoc13-tests/src/macports1.0/tests/test.tcl)
===================================================================
--- trunk/base/src/macports1.0/tests/test.tcl	                        (rev 0)
+++ trunk/base/src/macports1.0/tests/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,131 @@
+# Global vars
+set arguments ""
+set test_name ""
+set color_out ""
+set tcl ""
+set err ""
+
+# Get tclsh path.
+set autoconf ../../Mk/macports.autoconf.mk
+set fp [open $autoconf r]
+while {[gets $fp line] != -1} {
+    if {[string match "TCLSH*" $line] != 0} {
+        set tcl [lrange [split $line " "] 1 1]
+    }
+}
+
+proc print_help {arg} {
+    if { $arg == "tests" } {
+        puts "The list of available tests is:"
+	cd tests
+	set test_suite [glob *.test]
+        foreach test $test_suite {
+            puts [puts -nonewline "  "]$test
+        }
+    } else {
+        puts "Usage: tclsh test.tcl \[-debug level\] \[-t test\] \[-l\]\n"
+        puts "  -debug LVL : sets the level of printed debug info \[0-3\]"
+        puts "  -t TEST    : run a specific test"
+        puts "  -nocolor   : disable color output (for automatic testing)"
+        puts "  -l         : print the list of available tests"
+        puts "  -h, -help  : print this message\n"
+    }
+}
+
+# Process args
+foreach arg $argv {
+    if { $arg == "-h" || $arg == "-help" } {
+        print_help ""
+        exit 0
+    } elseif { $arg == "-debug" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set level [lindex $argv $index]
+        if { $level >= 0 && $level <= 3 } {
+            append arguments "-debug " $level
+        } else {
+            puts "Invalid debug level."
+            exit 1
+        }
+    } elseif { $arg == "-t" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set test_name [lindex $argv $index]
+        set no 0
+	cd tests
+	set test_suite [glob *.test]
+        foreach test $test_suite {
+            if { $test_name != $test } {
+                set no [expr $no + 1]
+            }
+        }
+        if { $no == [llength $test_suite] } {
+            print_help tests
+            exit 1
+        }
+    } elseif { $arg == "-l" } {
+        print_help tests
+        exit 0
+    } elseif { $arg == "-nocolor" } {
+        set color_out "no"
+    }
+}
+
+
+# Run tests
+if { $test_name != ""} {
+    set result [eval exec $tcl $test_name $arguments]
+    puts $result
+
+} else {
+    cd tests
+    set test_suite [glob *.test]
+
+    foreach test $test_suite {
+        set result [eval exec $tcl $test $arguments]
+	set lastline [lindex [split $result "\n"] end]
+
+	if {[lrange [split $lastline "\t"] 1 1] != "Total"} {
+	    set lastline [lindex [split $result "\n"] end-2]
+	    set errmsg [lindex [split $result "\n"] end]
+	}
+
+	set splitresult [split $lastline "\t"]
+        set total [lindex $splitresult 2]
+        set pass [lindex $splitresult 4]
+        set skip [lindex $splitresult 6]
+        set fail [lindex $splitresult 8]
+
+	# Format output
+	if {$total < 10} { set total "0${total}"}
+	if {$pass < 10} { set pass "0${pass}"}
+	if {$skip < 10} { set skip "0${skip}"}
+	if {$fail < 10} { set fail "0${fail}"}
+
+        # Check for errors.
+        if { $fail != 0 } { set err "yes" }
+
+        set out ""
+        if { ($fail != 0 || $skip != 0) && $color_out == "" } {
+            # Color failed tests.
+            append out "\x1b\[1;31mTotal:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  \x1b\[0m" $test
+        } else {
+            append out "Total:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  " $test
+        }
+
+        # Print results and constrints for auto-skipped tests.
+        puts $out
+        if { $skip != 0 } {
+            set out "    Constraint: "
+            append out [string trim $errmsg "\t {}"]
+            puts $out
+        }
+	if { $fail != 0 } {
+	    set end [expr [string first $test $result 0] - 1]
+	    puts [string range $result 0 $end]
+	}
+    }
+}
+
+# Return 1 if errors were found.
+if {$err != ""} { exit 1 }
+
+return 0


Property changes on: trunk/base/src/package1.0
___________________________________________________________________
Modified: svn:ignore
   - pkgIndex.tcl

   + pkgIndex.tcl
package_test_autoconf.tcl


Modified: trunk/base/src/package1.0/Makefile
===================================================================
--- trunk/base/src/package1.0/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -17,6 +17,10 @@
 distclean:: clean
 
 test::
+ifeq ($(shell id -u),0)
+	$(prefix)/bin/port sync
+endif
+	$(TCLSH) ./tests/test.tcl -nocolor
 
 install:: all
 	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} ${INSTALLDIR}

Copied: trunk/base/src/package1.0/package_test_autoconf.tcl.in (from rev 111324, branches/gsoc13-tests/src/package1.0/package_test_autoconf.tcl.in)
===================================================================
--- trunk/base/src/package1.0/package_test_autoconf.tcl.in	                        (rev 0)
+++ trunk/base/src/package1.0/package_test_autoconf.tcl.in	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,37 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
+# macports-autoconf.tcl.in
+# $Id: macports_autoconf.tcl.in 90070 2012-02-20 21:54:35Z jberry at macports.org $
+#
+# Copyright (c) 2006 - 2009, 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Apple Inc. nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+namespace eval macports::autoconf {
+    variable macports_tcl_dir "@macports_tcl_dir@"
+    variable prefix "@prefix@"
+}

Deleted: trunk/base/src/package1.0/tests/Portfile
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/Portfile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/Portfile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,40 +0,0 @@
-# $Id: Portfile 85472 2011-10-14 01:52:18Z dports at macports.org $
-
-PortSystem              1.0
-
-name                    fondu
-version                 060102
-revision                1
-platforms               darwin
-categories              print
-license                 BSD
-maintainers             nomaintainer
-homepage                http://fondu.sourceforge.net/
-master_sites            http://fondu.sourceforge.net/
-
-description             A set of programs to interconvert between Mac font \
-                        formats and pfb, ttf, otf and bdf files on UNIX.
-
-long_description        Dealing with Mac fonts is hard on other operating \
-                        systems because Mac fonts are stored in the resource \
-                        fork, and other operating systems do not support \
-                        this concept. Fondu will extract the resource fork \
-                        from either a MacBinary file or a BinHex file. Ufond \
-                        will create a resource fork inside a MacBinary file.
-
-checksums               md5 e20861beacddc1ab392bef7813641bf8
-extract.suffix          .tgz
-distfiles               [suffix ${name}_src-${version}]
-
-post-patch {
-    reinplace "s|^CFLAGS = -g \$(WFLAGS)|CFLAGS = -g \$(WFLAGS) ${configure.cppflags} ${configure.cflags} ${configure.ldflags} [get_canonical_archflags]|g" ${worksrcpath}/Makefile.in
-}
-
-configure.args          --bindir=${prefix}/bin \
-                        --mandir=${prefix}/share/man
-
-post-destroot {
-    eval xinstall -m 644 [glob ${worksrcpath}/*.1] ${destroot}${prefix}/share/man/man1/
-}
-
-test.run		yes

Copied: trunk/base/src/package1.0/tests/Portfile (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/Portfile)
===================================================================
--- trunk/base/src/package1.0/tests/Portfile	                        (rev 0)
+++ trunk/base/src/package1.0/tests/Portfile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,40 @@
+# $Id: Portfile 85472 2011-10-14 01:52:18Z dports at macports.org $
+
+PortSystem              1.0
+
+name                    fondu
+version                 060102
+revision                1
+platforms               darwin
+categories              print
+license                 BSD
+maintainers             nomaintainer
+homepage                http://fondu.sourceforge.net/
+master_sites            http://fondu.sourceforge.net/
+
+description             A set of programs to interconvert between Mac font \
+                        formats and pfb, ttf, otf and bdf files on UNIX.
+
+long_description        Dealing with Mac fonts is hard on other operating \
+                        systems because Mac fonts are stored in the resource \
+                        fork, and other operating systems do not support \
+                        this concept. Fondu will extract the resource fork \
+                        from either a MacBinary file or a BinHex file. Ufond \
+                        will create a resource fork inside a MacBinary file.
+
+checksums               md5 e20861beacddc1ab392bef7813641bf8
+extract.suffix          .tgz
+distfiles               [suffix ${name}_src-${version}]
+
+post-patch {
+    reinplace "s|^CFLAGS = -g \$(WFLAGS)|CFLAGS = -g \$(WFLAGS) ${configure.cppflags} ${configure.cflags} ${configure.ldflags} [get_canonical_archflags]|g" ${worksrcpath}/Makefile.in
+}
+
+configure.args          --bindir=${prefix}/bin \
+                        --mandir=${prefix}/share/man
+
+post-destroot {
+    eval xinstall -m 644 [glob ${worksrcpath}/*.1] ${destroot}${prefix}/share/man/man1/
+}
+
+test.run		yes

Deleted: trunk/base/src/package1.0/tests/library.tcl
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/library.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/library.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,106 +0,0 @@
-proc env_init {} {
-    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 porturl workpath distname license filespath portpath pwd
-    global portname
-
-    set os.platform darwin
-    set os.major 9
-    set os.arch i386
-    set epoch 1
-
-    set workpath $pwd/work   
-    set destpath $pwd/pkg
-    set portpath $pwd
-    set portdbpath $pwd/dbpath
-    set filespath $pwd/files
-    set configure.build_arch build_arch
-    set package.destpath $pwd/pkg
-
-    set portname fondu   
-    set subport fondu
-    set version 060102
-    set distname fondu_src-060102
-    set revision 1
-    set license MIT
-    set package.flat no
-    set maintainers {test at macports.org}
-    set description test.description
-    set categories test
-    set supported_archs noarch
-    set porturl "http://fondu.sourceforge.net/"
-}
-
-##
-# This is basically a copy of macports::worker_init, but without using
-# sub-interpreters
-proc macports_worker_init {} {
-    interp alias {} _cd {} cd
-
-    proc PortSystem {version} {
-        package require port $version
-    }
-
-    # Clearly separate slave interpreters and the master interpreter.
-    interp alias {} mport_exec      {} mportexec
-    interp alias {} mport_open      {} mportopen
-    interp alias {} mport_close     {} mportclose
-    interp alias {} mport_lookup    {} mportlookup
-    interp alias {} mport_info      {} mportinfo
-
-    # Export some utility functions defined here.
-    interp alias {} macports_create_thread          {} macports::create_thread
-    interp alias {} getportworkpath_from_buildpath  {} macports::getportworkpath_from_buildpath
-    interp alias {} getportresourcepath             {} macports::getportresourcepath
-    interp alias {} getportlogpath                  {} macports::getportlogpath
-    interp alias {} getdefaultportresourcepath      {} macports::getdefaultportresourcepath
-    interp alias {} getprotocol                     {} macports::getprotocol
-    interp alias {} getportdir                      {} macports::getportdir
-    interp alias {} findBinary                      {} macports::findBinary
-    interp alias {} binaryInPath                    {} macports::binaryInPath
-
-    # New Registry/Receipts stuff
-    interp alias {} registry_new                    {} registry::new_entry
-    interp alias {} registry_open                   {} registry::open_entry
-    interp alias {} registry_write                  {} registry::write_entry
-    interp alias {} registry_prop_store             {} registry::property_store
-    interp alias {} registry_prop_retr              {} registry::property_retrieve
-    interp alias {} registry_exists                 {} registry::entry_exists
-    interp alias {} registry_exists_for_name        {} registry::entry_exists_for_name
-    interp alias {} registry_activate               {} portimage::activate
-    interp alias {} registry_deactivate             {} portimage::deactivate
-    interp alias {} registry_deactivate_composite   {} portimage::deactivate_composite
-    interp alias {} registry_uninstall              {} registry_uninstall::uninstall
-    interp alias {} registry_register_deps          {} registry::register_dependencies
-    interp alias {} registry_fileinfo_for_index     {} registry::fileinfo_for_index
-    interp alias {} registry_fileinfo_for_file      {} registry::fileinfo_for_file
-    interp alias {} registry_bulk_register_files    {} registry::register_bulk_files
-    interp alias {} registry_active                 {} registry::active
-    interp alias {} registry_file_registered        {} registry::file_registered
-    interp alias {} registry_port_registered        {} registry::port_registered
-    interp alias {} registry_list_depends           {} registry::list_depends
-
-    # deferred options processing.
-    interp alias {} getoption {} macports::getoption
-
-    # ping cache
-    interp alias {} get_pingtime {} macports::get_pingtime
-    interp alias {} set_pingtime {} macports::set_pingtime
-
-    # archive_sites.conf handling
-    interp alias {} get_archive_sites_conf_values {} macports::get_archive_sites_conf_values
-
-    foreach opt $macports::portinterp_options {
-        if {![info exists $opt]} {
-            global macports::$opt
-            set ::$opt macports::$opt
-        }
-        if {[info exists $opt]} {
-            set system_options($opt) $opt
-            set ::$opt $opt
-        }
-    }
-
-    # We don't need to handle portinterp_deferred_options, they're
-    # automatically handled correctly.
-}

Copied: trunk/base/src/package1.0/tests/library.tcl (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/library.tcl)
===================================================================
--- trunk/base/src/package1.0/tests/library.tcl	                        (rev 0)
+++ trunk/base/src/package1.0/tests/library.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,106 @@
+proc env_init {} {
+    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 porturl workpath distname license filespath portpath pwd
+    global portname
+
+    set os.platform darwin
+    set os.major 9
+    set os.arch i386
+    set epoch 1
+
+    set workpath $pwd/work   
+    set destpath $pwd/pkg
+    set portpath $pwd
+    set portdbpath $pwd/dbpath
+    set filespath $pwd/files
+    set configure.build_arch build_arch
+    set package.destpath $pwd/pkg
+
+    set portname fondu   
+    set subport fondu
+    set version 060102
+    set distname fondu_src-060102
+    set revision 1
+    set license MIT
+    set package.flat no
+    set maintainers {test at macports.org}
+    set description test.description
+    set categories test
+    set supported_archs noarch
+    set porturl "http://fondu.sourceforge.net/"
+}
+
+##
+# This is basically a copy of macports::worker_init, but without using
+# sub-interpreters
+proc macports_worker_init {} {
+    interp alias {} _cd {} cd
+
+    proc PortSystem {version} {
+        package require port $version
+    }
+
+    # Clearly separate slave interpreters and the master interpreter.
+    interp alias {} mport_exec      {} mportexec
+    interp alias {} mport_open      {} mportopen
+    interp alias {} mport_close     {} mportclose
+    interp alias {} mport_lookup    {} mportlookup
+    interp alias {} mport_info      {} mportinfo
+
+    # Export some utility functions defined here.
+    interp alias {} macports_create_thread          {} macports::create_thread
+    interp alias {} getportworkpath_from_buildpath  {} macports::getportworkpath_from_buildpath
+    interp alias {} getportresourcepath             {} macports::getportresourcepath
+    interp alias {} getportlogpath                  {} macports::getportlogpath
+    interp alias {} getdefaultportresourcepath      {} macports::getdefaultportresourcepath
+    interp alias {} getprotocol                     {} macports::getprotocol
+    interp alias {} getportdir                      {} macports::getportdir
+    interp alias {} findBinary                      {} macports::findBinary
+    interp alias {} binaryInPath                    {} macports::binaryInPath
+
+    # New Registry/Receipts stuff
+    interp alias {} registry_new                    {} registry::new_entry
+    interp alias {} registry_open                   {} registry::open_entry
+    interp alias {} registry_write                  {} registry::write_entry
+    interp alias {} registry_prop_store             {} registry::property_store
+    interp alias {} registry_prop_retr              {} registry::property_retrieve
+    interp alias {} registry_exists                 {} registry::entry_exists
+    interp alias {} registry_exists_for_name        {} registry::entry_exists_for_name
+    interp alias {} registry_activate               {} portimage::activate
+    interp alias {} registry_deactivate             {} portimage::deactivate
+    interp alias {} registry_deactivate_composite   {} portimage::deactivate_composite
+    interp alias {} registry_uninstall              {} registry_uninstall::uninstall
+    interp alias {} registry_register_deps          {} registry::register_dependencies
+    interp alias {} registry_fileinfo_for_index     {} registry::fileinfo_for_index
+    interp alias {} registry_fileinfo_for_file      {} registry::fileinfo_for_file
+    interp alias {} registry_bulk_register_files    {} registry::register_bulk_files
+    interp alias {} registry_active                 {} registry::active
+    interp alias {} registry_file_registered        {} registry::file_registered
+    interp alias {} registry_port_registered        {} registry::port_registered
+    interp alias {} registry_list_depends           {} registry::list_depends
+
+    # deferred options processing.
+    interp alias {} getoption {} macports::getoption
+
+    # ping cache
+    interp alias {} get_pingtime {} macports::get_pingtime
+    interp alias {} set_pingtime {} macports::set_pingtime
+
+    # archive_sites.conf handling
+    interp alias {} get_archive_sites_conf_values {} macports::get_archive_sites_conf_values
+
+    foreach opt $macports::portinterp_options {
+        if {![info exists $opt]} {
+            global macports::$opt
+            set ::$opt macports::$opt
+        }
+        if {[info exists $opt]} {
+            set system_options($opt) $opt
+            set ::$opt $opt
+        }
+    }
+
+    # We don't need to handle portinterp_deferred_options, they're
+    # automatically handled correctly.
+}

Deleted: trunk/base/src/package1.0/tests/portarchivefetch.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portarchivefetch.test	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/portarchivefetch.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,135 +0,0 @@
-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

Copied: trunk/base/src/package1.0/tests/portarchivefetch.test (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/portarchivefetch.test)
===================================================================
--- trunk/base/src/package1.0/tests/portarchivefetch.test	                        (rev 0)
+++ trunk/base/src/package1.0/tests/portarchivefetch.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,135 @@
+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

Deleted: trunk/base/src/package1.0/tests/portdmg.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portdmg.test	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/portdmg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,59 +0,0 @@
-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
-
-source ../portdmg.tcl
-source ../../port1.0/port_autoconf.tcl
-
-
-# test dmg_main
-
-
-test package_dmg {
-    Package dmg unit test.
-} -setup {
-    set os.major 10
-    set os.arch i386
-
-    set subport fondu
-    set version 060102
-    set revision 1
-    set package.destpath $pwd/pkg
-    set UI_PREFIX >
-
-    file mkdir $pwd/pkg
-    close [open $pwd/pkg/fondu-060102.pkg w+]
-
-} -body {
-    if {[portdmg::dmg_main] != 0} {
-	return "FAIL: cannot create dmg"
-    }
-    if {![file exists $pwd/pkg/fondu-060102-1.dmg]} {
-	return "FAIL: missing .dmg file"
-    }
-    if {![file exists $pwd/pkg/fondu-060102-1/fondu-060102.pkg]} {
-	return "FAIL: invalid package.destpath"
-    }
-    return "Package dmg successful."
-
-} -cleanup {
-    file delete -force $pwd/pkg
-
-} -result "Package dmg successful."
-
-
-cleanupTests

Copied: trunk/base/src/package1.0/tests/portdmg.test (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/portdmg.test)
===================================================================
--- trunk/base/src/package1.0/tests/portdmg.test	                        (rev 0)
+++ trunk/base/src/package1.0/tests/portdmg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,59 @@
+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
+
+source ../portdmg.tcl
+source ../../port1.0/port_autoconf.tcl
+
+
+# test dmg_main
+
+
+test package_dmg {
+    Package dmg unit test.
+} -setup {
+    set os.major 10
+    set os.arch i386
+
+    set subport fondu
+    set version 060102
+    set revision 1
+    set package.destpath $pwd/pkg
+    set UI_PREFIX >
+
+    file mkdir $pwd/pkg
+    close [open $pwd/pkg/fondu-060102.pkg w+]
+
+} -body {
+    if {[portdmg::dmg_main] != 0} {
+	return "FAIL: cannot create dmg"
+    }
+    if {![file exists $pwd/pkg/fondu-060102-1.dmg]} {
+	return "FAIL: missing .dmg file"
+    }
+    if {![file exists $pwd/pkg/fondu-060102-1/fondu-060102.pkg]} {
+	return "FAIL: invalid package.destpath"
+    }
+    return "Package dmg successful."
+
+} -cleanup {
+    file delete -force $pwd/pkg
+
+} -result "Package dmg successful."
+
+
+cleanupTests

Deleted: trunk/base/src/package1.0/tests/portdpkg.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portdpkg.test	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/portdpkg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,75 +0,0 @@
-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
-
-source ../portdpkg.tcl
-source ../../port1.0/port_autoconf.tcl
-
-
-test main {
-    Port dpkg main unit test.
-} -constraints { ![catch {exec which dpkg-deb}]
-
-} -setup {
-    set os.platform darwin
-    set os.major 10
-    set os.arch i386
-    set epoch 1
-
-    set destpath $pwd/pkg
-    set configure.build_arch build_arch
-    set package.destpath $pwd/pkg
-
-    set subport fondu
-    set version 060102
-    set revision 1
-    set maintainers {test at macports.org}
-    set description test.description
-    set categories test
-    set supported_archs noarch
-
-
-} -body {
-    if {[catch {portdpkg::main}] != 0} {
-		return "FAIL: cannot create dmg"
-    }
-    if {![file exists $pwd/pkg/fondu_060102-1_all.deb]} {
-		return "FAIL: missing .deb file"
-    }
-    return "Package deb successful."
-
-} -cleanup {
-    file delete -force $pwd/pkg
-
-} -result "Package deb successful."
-
-
-test make_dependency_list {
-    Make dependency list unit test.
-} -setup {
-    set subport fondu
-    set version 060102
-    set revision 1
-} -body {
-    if {[portdpkg::make_dependency_list $subport] != "fondu/060102"} {
-		return "FAIL: could not make dependency list"
-    }
-    return "Make dependency list successful."
-} -result "Make dependency list successful."
-
-
-cleanupTests

Copied: trunk/base/src/package1.0/tests/portdpkg.test (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/portdpkg.test)
===================================================================
--- trunk/base/src/package1.0/tests/portdpkg.test	                        (rev 0)
+++ trunk/base/src/package1.0/tests/portdpkg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,75 @@
+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
+
+source ../portdpkg.tcl
+source ../../port1.0/port_autoconf.tcl
+
+
+test main {
+    Port dpkg main unit test.
+} -constraints { ![catch {exec which dpkg-deb}]
+
+} -setup {
+    set os.platform darwin
+    set os.major 10
+    set os.arch i386
+    set epoch 1
+
+    set destpath $pwd/pkg
+    set configure.build_arch build_arch
+    set package.destpath $pwd/pkg
+
+    set subport fondu
+    set version 060102
+    set revision 1
+    set maintainers {test at macports.org}
+    set description test.description
+    set categories test
+    set supported_archs noarch
+
+
+} -body {
+    if {[catch {portdpkg::main}] != 0} {
+		return "FAIL: cannot create dmg"
+    }
+    if {![file exists $pwd/pkg/fondu_060102-1_all.deb]} {
+		return "FAIL: missing .deb file"
+    }
+    return "Package deb successful."
+
+} -cleanup {
+    file delete -force $pwd/pkg
+
+} -result "Package deb successful."
+
+
+test make_dependency_list {
+    Make dependency list unit test.
+} -setup {
+    set subport fondu
+    set version 060102
+    set revision 1
+} -body {
+    if {[portdpkg::make_dependency_list $subport] != "fondu/060102"} {
+		return "FAIL: could not make dependency list"
+    }
+    return "Make dependency list successful."
+} -result "Make dependency list successful."
+
+
+cleanupTests

Deleted: trunk/base/src/package1.0/tests/portmdmg.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portmdmg.test	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/portmdmg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,61 +0,0 @@
-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
-
-source ../portmdmg.tcl
-source ../portmpkg.tcl
-source ../../port1.0/port_autoconf.tcl
-
-
-# test dmg_main
-
-
-test package_mdmg {
-    Package mdmg unit test.
-} -setup {
-    set os.major 10
-    set os.arch i386
-
-    set subport fondu
-    set portepoch i386
-    set version 060102
-    set revision 1
-    set package.destpath $pwd/pkg
-    set UI_PREFIX >
-
-    file mkdir $pwd/pkg
-    close [open $pwd/pkg/fondu-i386_060102_1.mpkg w+]
-
-} -body {
-    if {[portmdmg::package_mdmg $subport $portepoch $version $revision] != 0} {
-		return "FAIL: cannot create mdmg"
-    }
-    if {![file exists $pwd/pkg/fondu-060102-1.dmg]} {
-		return "FAIL: missing .dmg file"
-    }
-    if {![file exists $pwd/pkg/fondu-060102-1/fondu-i386_060102_1.mpkg]} {
-		return "FAIL: invalid package.destpath"
-    }
-    return "Package dmg successful."
-
-} -cleanup {
-    file delete -force $pwd/pkg
-
-} -result "Package dmg successful."
-
-
-cleanupTests

Copied: trunk/base/src/package1.0/tests/portmdmg.test (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/portmdmg.test)
===================================================================
--- trunk/base/src/package1.0/tests/portmdmg.test	                        (rev 0)
+++ trunk/base/src/package1.0/tests/portmdmg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,61 @@
+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
+
+source ../portmdmg.tcl
+source ../portmpkg.tcl
+source ../../port1.0/port_autoconf.tcl
+
+
+# test dmg_main
+
+
+test package_mdmg {
+    Package mdmg unit test.
+} -setup {
+    set os.major 10
+    set os.arch i386
+
+    set subport fondu
+    set portepoch i386
+    set version 060102
+    set revision 1
+    set package.destpath $pwd/pkg
+    set UI_PREFIX >
+
+    file mkdir $pwd/pkg
+    close [open $pwd/pkg/fondu-i386_060102_1.mpkg w+]
+
+} -body {
+    if {[portmdmg::package_mdmg $subport $portepoch $version $revision] != 0} {
+		return "FAIL: cannot create mdmg"
+    }
+    if {![file exists $pwd/pkg/fondu-060102-1.dmg]} {
+		return "FAIL: missing .dmg file"
+    }
+    if {![file exists $pwd/pkg/fondu-060102-1/fondu-i386_060102_1.mpkg]} {
+		return "FAIL: invalid package.destpath"
+    }
+    return "Package dmg successful."
+
+} -cleanup {
+    file delete -force $pwd/pkg
+
+} -result "Package dmg successful."
+
+
+cleanupTests

Deleted: trunk/base/src/package1.0/tests/portmpkg.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portmpkg.test	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/portmpkg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,84 +0,0 @@
-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 portmpkg 1.0
-package require portpkg 1.0
-
-
-test mpkg_main {
-    Port mpkg main 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 porturl
-    env_init
-
-    file mkdir $destpath
-    close [open $destpath/fondu-1_060102_1.pkg w+]
-
-} -body {
-    if {[portmpkg::mpkg_main] != 0} {
-		return "FAIL: cannot create pkg"
-    }
-    if {![file exists $destpath/fondu-1_060102_1.mpkg/Contents/PkgInfo]} {
-		return "FAIL: missing PkgInfo file"
-    }
-    if {![file exists $destpath/fondu-1_060102_1.mpkg/Contents/Info.plist]} {
-		return "FAIL: missing Info.plist file"
-    }
-    if {![file exists $destpath/fondu-1_060102_1.mpkg/Contents/Resources]} {
-		return "FAIL: missing Resources dir"
-    }
-    if {![file exists $destpath/fondu-1_060102_1.mpkg/Contents/Packages/fondu-1_060102_1.pkg]} {
-		return "FAIL: missing pkg file"
-    }
-    return "Package mpkg successful."
-
-} -cleanup {
-    file delete -force $destpath
-
-} -result "Package mpkg successful."
-
-
-test make_dependency_list {
-    Make dependency list 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 porturl
-    env_init
-
-    set destination $pwd/destination
-} -body {
-    set res [portmpkg::make_dependency_list $subport $destination]
-    if { $res != "{fondu 0 060102 1 ditem_4}" } {
-		return "FAIL: invalid dependency list"
-    }
-    return "Dependency list successful."
-
-} -result "Dependency list successful."
-
-
-# Covered by mpkg_main
-# test make_one_package
-# test epoch_namestr
-# test revision_namestr
-# test package_mpkg
-
-
-cleanupTests

Copied: trunk/base/src/package1.0/tests/portmpkg.test (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/portmpkg.test)
===================================================================
--- trunk/base/src/package1.0/tests/portmpkg.test	                        (rev 0)
+++ trunk/base/src/package1.0/tests/portmpkg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,84 @@
+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 portmpkg 1.0
+package require portpkg 1.0
+
+
+test mpkg_main {
+    Port mpkg main 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 porturl
+    env_init
+
+    file mkdir $destpath
+    close [open $destpath/fondu-1_060102_1.pkg w+]
+
+} -body {
+    if {[portmpkg::mpkg_main] != 0} {
+		return "FAIL: cannot create pkg"
+    }
+    if {![file exists $destpath/fondu-1_060102_1.mpkg/Contents/PkgInfo]} {
+		return "FAIL: missing PkgInfo file"
+    }
+    if {![file exists $destpath/fondu-1_060102_1.mpkg/Contents/Info.plist]} {
+		return "FAIL: missing Info.plist file"
+    }
+    if {![file exists $destpath/fondu-1_060102_1.mpkg/Contents/Resources]} {
+		return "FAIL: missing Resources dir"
+    }
+    if {![file exists $destpath/fondu-1_060102_1.mpkg/Contents/Packages/fondu-1_060102_1.pkg]} {
+		return "FAIL: missing pkg file"
+    }
+    return "Package mpkg successful."
+
+} -cleanup {
+    file delete -force $destpath
+
+} -result "Package mpkg successful."
+
+
+test make_dependency_list {
+    Make dependency list 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 porturl
+    env_init
+
+    set destination $pwd/destination
+} -body {
+    set res [portmpkg::make_dependency_list $subport $destination]
+    if { $res != "{fondu 0 060102 1 ditem_4}" } {
+		return "FAIL: invalid dependency list"
+    }
+    return "Dependency list successful."
+
+} -result "Dependency list successful."
+
+
+# Covered by mpkg_main
+# test make_one_package
+# test epoch_namestr
+# test revision_namestr
+# test package_mpkg
+
+
+cleanupTests

Deleted: trunk/base/src/package1.0/tests/portpkg.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portpkg.test	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/portpkg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,62 +0,0 @@
-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 portmpkg 1.0
-package require portpkg 1.0
-
-
-test pkg_main {
-    Port pkg main 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 porturl
-    env_init
-
-    file mkdir $destpath
-    close [open $destpath/fondu-1_060102_1.pkg w+]
-
-    set contents_dir $destpath/fondu-1_060102_1.mpkg/Contents/
-    set packages_dir $destpath/fondu-1_060102_1.mpkg/Contents/Packages
-    set res_dir $destpath/fondu-1_060102_1.mpkg/Contents/Resources
-
-    set mport [mportopen file://.]
-    set workername [ditem_key $mport workername]
-
-} -body {
-    if {[$workername eval eval_targets pkg] != 0} {
-        return "FAIL: cannot create pkg. Maybe should update ports tree ?"
-    }
-
-    if {![file exists $pwd/work/fondu-060102_1.pkg]} {
-        return "FAIL: missing pkg file"
-    }
-
-    return "Package pkg successful."
-
-} -cleanup {
-    mportclose $mport
-    file delete -force $destpath
-    file delete -force $pwd/work
-    
-} -result "Package pkg successful."
-
-
-cleanupTests

Copied: trunk/base/src/package1.0/tests/portpkg.test (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/portpkg.test)
===================================================================
--- trunk/base/src/package1.0/tests/portpkg.test	                        (rev 0)
+++ trunk/base/src/package1.0/tests/portpkg.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,62 @@
+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 portmpkg 1.0
+package require portpkg 1.0
+
+
+test pkg_main {
+    Port pkg main 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 porturl
+    env_init
+
+    file mkdir $destpath
+    close [open $destpath/fondu-1_060102_1.pkg w+]
+
+    set contents_dir $destpath/fondu-1_060102_1.mpkg/Contents/
+    set packages_dir $destpath/fondu-1_060102_1.mpkg/Contents/Packages
+    set res_dir $destpath/fondu-1_060102_1.mpkg/Contents/Resources
+
+    set mport [mportopen file://.]
+    set workername [ditem_key $mport workername]
+
+} -body {
+    if {[$workername eval eval_targets pkg] != 0} {
+        return "FAIL: cannot create pkg. Maybe should update ports tree ?"
+    }
+
+    if {![file exists $pwd/work/fondu-060102_1.pkg]} {
+        return "FAIL: missing pkg file"
+    }
+
+    return "Package pkg successful."
+
+} -cleanup {
+    mportclose $mport
+    file delete -force $destpath
+    file delete -force $pwd/work
+    
+} -result "Package pkg successful."
+
+
+cleanupTests

Deleted: trunk/base/src/package1.0/tests/test.tcl
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/test.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/package1.0/tests/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,136 +0,0 @@
-# Global vars
-set arguments ""
-set test_name ""
-set color_out ""
-set tcl ""
-set err ""
-
-# Get tclsh path.
-set autoconf ../../Mk/macports.autoconf.mk
-set fp [open $autoconf r]
-while {[gets $fp line] != -1} {
-    if {[string match "TCLSH*" $line] != 0} {
-        set tcl [lrange [split $line " "] 1 1]
-    }
-}
-
-proc print_help {arg} {
-    if { $arg == "tests" } {
-        puts "The list of available tests is:"
-	cd tests
-	set test_suite [glob *.test]
-        foreach test $test_suite {
-            puts [puts -nonewline "  "]$test
-        }
-    } else {
-        puts "Usage: tclsh test.tcl \[-debug level\] \[-t test\] \[-l\]\n"
-        puts "  -debug LVL : sets the level of printed debug info \[0-3\]"
-        puts "  -t TEST    : run a specific test"
-        puts "  -nocolor   : disable color output (for automatic testing)"
-        puts "  -l         : print the list of available tests"
-        puts "  -h, -help  : print this message\n"
-    }
-}
-
-# Process args
-foreach arg $argv {
-    if { $arg == "-h" || $arg == "-help" } {
-        print_help ""
-        exit 0
-    } elseif { $arg == "-debug" } {
-        set index [expr [lsearch $argv $arg] + 1]
-        set level [lindex $argv $index]
-        if { $level >= 0 && $level <= 3 } {
-            append arguments "-debug " $level
-        } else {
-            puts "Invalid debug level."
-            exit 1
-        }
-    } elseif { $arg == "-t" } {
-        set index [expr [lsearch $argv $arg] + 1]
-        set test_name [lindex $argv $index]
-        set no 0
-	cd tests
-	set test_suite [glob *.test]
-        foreach test $test_suite {
-            if { $test_name != $test } {
-                set no [expr $no + 1]
-            }
-        }
-        if { $no == [llength $test_suite] } {
-            print_help tests
-            exit 1
-        }
-    } elseif { $arg == "-l" } {
-        print_help tests
-        exit 0
-    } elseif { $arg == "-nocolor" } {
-        set color_out "no"
-    }
-}
-
-
-# Run tests
-if { $test_name != ""} {
-    set result [eval exec $tcl $test_name $arguments]
-    puts $result
-
-} else {
-    cd tests
-    set test_suite [glob *.test]
-
-    foreach test $test_suite {
-        set result [eval exec -ignorestderr $tcl $test $arguments]
-		set lastline [lindex [split $result "\n"] end]
-
-	if {[lrange [split $lastline "\t"] 1 1] != "Total"} {
-		if {[lrange [split $lastline "\t"] 1 1] == ""} {
-			set lastline [lindex [split $result "\n"] 0]
-	    	set errmsg [lindex [split $result "\n"] 2]
-		} else {
-	    	set lastline [lindex [split $result "\n"] end-2]
-	    	set errmsg [lindex [split $result "\n"] end]
-		}
-	}
-
-	set splitresult [split $lastline "\t"]
-        set total [lindex $splitresult 2]
-        set pass [lindex $splitresult 4]
-        set skip [lindex $splitresult 6]
-        set fail [lindex $splitresult 8]
-
-	# Format output
-	if {$total < 10} { set total "0${total}"}
-	if {$pass < 10} { set pass "0${pass}"}
-	if {$skip < 10} { set skip "0${skip}"}
-	if {$fail < 10} { set fail "0${fail}"}
-
-        # Check for errors.
-        if { $fail != 0 } { set err "yes" }
-
-        set out ""
-        if { ($fail != 0 || $skip != 0) && $color_out == "" } {
-            # Color failed tests.
-            append out "\x1b\[1;31mTotal:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  \x1b\[0m" $test
-        } else {
-            append out "Total:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  " $test
-        }
-
-        # Print results and constrints for auto-skipped tests.
-        puts $out
-        if { $skip != 0 } {
-            set out "    Constraint: "
-            append out [string trim $errmsg "\t {}"]
-            puts $out
-        }
-	if { $fail != 0 } {
-	    set end [expr [string first $test $result 0] - 1]
-	    puts [string range $result 0 $end]
-	}
-    }
-}
-
-# Return 1 if errors were found.
-if {$err != ""} { exit 1 }
-
-return 0

Copied: trunk/base/src/package1.0/tests/test.tcl (from rev 111324, branches/gsoc13-tests/src/package1.0/tests/test.tcl)
===================================================================
--- trunk/base/src/package1.0/tests/test.tcl	                        (rev 0)
+++ trunk/base/src/package1.0/tests/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,136 @@
+# Global vars
+set arguments ""
+set test_name ""
+set color_out ""
+set tcl ""
+set err ""
+
+# Get tclsh path.
+set autoconf ../../Mk/macports.autoconf.mk
+set fp [open $autoconf r]
+while {[gets $fp line] != -1} {
+    if {[string match "TCLSH*" $line] != 0} {
+        set tcl [lrange [split $line " "] 1 1]
+    }
+}
+
+proc print_help {arg} {
+    if { $arg == "tests" } {
+        puts "The list of available tests is:"
+	cd tests
+	set test_suite [glob *.test]
+        foreach test $test_suite {
+            puts [puts -nonewline "  "]$test
+        }
+    } else {
+        puts "Usage: tclsh test.tcl \[-debug level\] \[-t test\] \[-l\]\n"
+        puts "  -debug LVL : sets the level of printed debug info \[0-3\]"
+        puts "  -t TEST    : run a specific test"
+        puts "  -nocolor   : disable color output (for automatic testing)"
+        puts "  -l         : print the list of available tests"
+        puts "  -h, -help  : print this message\n"
+    }
+}
+
+# Process args
+foreach arg $argv {
+    if { $arg == "-h" || $arg == "-help" } {
+        print_help ""
+        exit 0
+    } elseif { $arg == "-debug" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set level [lindex $argv $index]
+        if { $level >= 0 && $level <= 3 } {
+            append arguments "-debug " $level
+        } else {
+            puts "Invalid debug level."
+            exit 1
+        }
+    } elseif { $arg == "-t" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set test_name [lindex $argv $index]
+        set no 0
+	cd tests
+	set test_suite [glob *.test]
+        foreach test $test_suite {
+            if { $test_name != $test } {
+                set no [expr $no + 1]
+            }
+        }
+        if { $no == [llength $test_suite] } {
+            print_help tests
+            exit 1
+        }
+    } elseif { $arg == "-l" } {
+        print_help tests
+        exit 0
+    } elseif { $arg == "-nocolor" } {
+        set color_out "no"
+    }
+}
+
+
+# Run tests
+if { $test_name != ""} {
+    set result [eval exec $tcl $test_name $arguments]
+    puts $result
+
+} else {
+    cd tests
+    set test_suite [glob *.test]
+
+    foreach test $test_suite {
+        set result [eval exec -ignorestderr $tcl $test $arguments]
+		set lastline [lindex [split $result "\n"] end]
+
+	if {[lrange [split $lastline "\t"] 1 1] != "Total"} {
+		if {[lrange [split $lastline "\t"] 1 1] == ""} {
+			set lastline [lindex [split $result "\n"] 0]
+	    	set errmsg [lindex [split $result "\n"] 2]
+		} else {
+	    	set lastline [lindex [split $result "\n"] end-2]
+	    	set errmsg [lindex [split $result "\n"] end]
+		}
+	}
+
+	set splitresult [split $lastline "\t"]
+        set total [lindex $splitresult 2]
+        set pass [lindex $splitresult 4]
+        set skip [lindex $splitresult 6]
+        set fail [lindex $splitresult 8]
+
+	# Format output
+	if {$total < 10} { set total "0${total}"}
+	if {$pass < 10} { set pass "0${pass}"}
+	if {$skip < 10} { set skip "0${skip}"}
+	if {$fail < 10} { set fail "0${fail}"}
+
+        # Check for errors.
+        if { $fail != 0 } { set err "yes" }
+
+        set out ""
+        if { ($fail != 0 || $skip != 0) && $color_out == "" } {
+            # Color failed tests.
+            append out "\x1b\[1;31mTotal:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  \x1b\[0m" $test
+        } else {
+            append out "Total:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  " $test
+        }
+
+        # Print results and constrints for auto-skipped tests.
+        puts $out
+        if { $skip != 0 } {
+            set out "    Constraint: "
+            append out [string trim $errmsg "\t {}"]
+            puts $out
+        }
+	if { $fail != 0 } {
+	    set end [expr [string first $test $result 0] - 1]
+	    puts [string range $result 0 $end]
+	}
+    }
+}
+
+# Return 1 if errors were found.
+if {$err != ""} { exit 1 }
+
+return 0


Property changes on: trunk/base/src/pextlib1.0/Makefile.in
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/src/pextlib1.0/Makefile:37343-46937
/branches/gsoc09-logging/base/src/pextlib1.0/Makefile:51231-60371
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/Makefile:78828-88375
/branches/universal-sanity/base/src/pextlib1.0/Makefile:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/Makefile:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/Makefile:45682-46060
/users/perry/base-select/src/pextlib1.0/Makefile:44044-44692
   + /branches/gsoc08-privileges/base/src/pextlib1.0/Makefile:37343-46937
/branches/gsoc09-logging/base/src/pextlib1.0/Makefile:51231-60371
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/Makefile:78828-88375
/branches/gsoc13-tests/src/pextlib1.0/Makefile.in:106692-111324
/branches/universal-sanity/base/src/pextlib1.0/Makefile:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/Makefile:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/Makefile:45682-46060
/users/perry/base-select/src/pextlib1.0/Makefile:44044-44692


Property changes on: trunk/base/src/pextlib1.0/sha2.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/src/pextlib1.0/sha2.c:37343-46937
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha2.c:78828-88375
/branches/universal-sanity/base/src/pextlib1.0/sha2.c:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/sha2.c:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/sha2.c:45682-46060
/users/perry/base-select/src/pextlib1.0/sha2.c:44044-44692
   + /branches/gsoc08-privileges/base/src/pextlib1.0/sha2.c:37343-46937
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha2.c:78828-88375
/branches/gsoc13-tests/src/pextlib1.0/sha2.c:106692-111324
/branches/universal-sanity/base/src/pextlib1.0/sha2.c:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/sha2.c:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/sha2.c:45682-46060
/users/perry/base-select/src/pextlib1.0/sha2.c:44044-44692


Property changes on: trunk/base/src/pextlib1.0/sha2.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/src/pextlib1.0/sha2.h:37343-46937
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha2.h:78828-88375
/branches/universal-sanity/base/src/pextlib1.0/sha2.h:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/sha2.h:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/sha2.h:45682-46060
/users/perry/base-select/src/pextlib1.0/sha2.h:44044-44692
   + /branches/gsoc08-privileges/base/src/pextlib1.0/sha2.h:37343-46937
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha2.h:78828-88375
/branches/gsoc13-tests/src/pextlib1.0/sha2.h:106692-111324
/branches/universal-sanity/base/src/pextlib1.0/sha2.h:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/sha2.h:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/sha2.h:45682-46060
/users/perry/base-select/src/pextlib1.0/sha2.h:44044-44692


Property changes on: trunk/base/src/pextlib1.0/sha256cmd.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/src/pextlib1.0/rmd160cmd.c:37343-46937
/branches/gsoc09-logging/base/src/pextlib1.0/sha256cmd.c:51231-60371
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha256cmd.c:78828-88375
/branches/universal-sanity/base/src/pextlib1.0/rmd160cmd.c:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/rmd160cmd.c:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/rmd160cmd.c:45682-46060
/users/perry/base-select/src/pextlib1.0/rmd160cmd.c:44044-44692
   + /branches/gsoc08-privileges/base/src/pextlib1.0/rmd160cmd.c:37343-46937
/branches/gsoc09-logging/base/src/pextlib1.0/sha256cmd.c:51231-60371
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha256cmd.c:78828-88375
/branches/gsoc13-tests/src/pextlib1.0/sha256cmd.c:106692-111324
/branches/universal-sanity/base/src/pextlib1.0/rmd160cmd.c:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/rmd160cmd.c:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/rmd160cmd.c:45682-46060
/users/perry/base-select/src/pextlib1.0/rmd160cmd.c:44044-44692


Property changes on: trunk/base/src/pextlib1.0/sha256cmd.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/src/pextlib1.0/rmd160cmd.h:37343-46937
/branches/gsoc09-logging/base/src/pextlib1.0/sha256cmd.h:51231-60371
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha256cmd.h:78828-88375
/branches/universal-sanity/base/src/pextlib1.0/rmd160cmd.h:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/rmd160cmd.h:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/rmd160cmd.h:45682-46060
/users/perry/base-select/src/pextlib1.0/rmd160cmd.h:44044-44692
   + /branches/gsoc08-privileges/base/src/pextlib1.0/rmd160cmd.h:37343-46937
/branches/gsoc09-logging/base/src/pextlib1.0/sha256cmd.h:51231-60371
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha256cmd.h:78828-88375
/branches/gsoc13-tests/src/pextlib1.0/sha256cmd.h:106692-111324
/branches/universal-sanity/base/src/pextlib1.0/rmd160cmd.h:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/rmd160cmd.h:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/pextlib1.0/rmd160cmd.h:45682-46060
/users/perry/base-select/src/pextlib1.0/rmd160cmd.h:44044-44692


Property changes on: trunk/base/src/port1.0
___________________________________________________________________
Modified: svn:ignore
   - port_autoconf.tcl
pkgIndex.tcl

   + port_autoconf.tcl
port_test_autoconf.tcl
pkgIndex.tcl


Modified: trunk/base/src/port1.0/Makefile
===================================================================
--- trunk/base/src/port1.0/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/port1.0/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -33,6 +33,4 @@
 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 pkgIndex.tcl ${INSTALLDIR}
 
 test::
-	${TCLSH} tests/portutil.tcl ${macports_tcl_dir}
-	${TCLSH} tests/portdestroot.tcl ${macports_tcl_dir}
-	${TCLSH} tests/portfetch.tcl ${macports_tcl_dir}
+	$(TCLSH) ./tests/test.tcl -nocolor

Copied: trunk/base/src/port1.0/port_test_autoconf.tcl.in (from rev 111324, branches/gsoc13-tests/src/port1.0/port_test_autoconf.tcl.in)
===================================================================
--- trunk/base/src/port1.0/port_test_autoconf.tcl.in	                        (rev 0)
+++ trunk/base/src/port1.0/port_test_autoconf.tcl.in	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,37 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
+# macports-autoconf.tcl.in
+# $Id: macports_autoconf.tcl.in 90070 2012-02-20 21:54:35Z jberry at macports.org $
+#
+# Copyright (c) 2006 - 2009, 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Apple Inc. nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+namespace eval macports::autoconf {
+    variable macports_tcl_dir "@macports_tcl_dir@"
+    variable prefix "@prefix@"
+}

Modified: trunk/base/src/port1.0/portchecksum.tcl
===================================================================
--- trunk/base/src/port1.0/portchecksum.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/port1.0/portchecksum.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -264,6 +264,10 @@
                 foreach {type sum} $portfile_checksums {
                     set calculated_sum [calc_$type $fullpath]
                     lappend sums [format "%-8s%s" $type $calculated_sum]
+
+		    # Used for regression testing
+                    ui_debug "[format [msgcat::mc "Calculated (%s) is %s"] $type $calculated_sum]"
+
                     if {[string equal $sum $calculated_sum]} {
                         ui_debug "[format [msgcat::mc "Correct (%s) checksum for %s"] $type $distfile]"
                     } else {

Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/port1.0/portutil.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -2235,8 +2235,9 @@
                 set PortInfo(vinfo) {}
             }
             array set vinfo $PortInfo(vinfo)
-
+puts $value
             foreach v $value {
+		puts $v
                 if {[regexp {([-+])([-A-Za-z0-9_]+)} $v whole val variant] && ![info exists variations($variant)]} {
                     # Retrieve the information associated with this variant.
                     if {![info exists vinfo($variant)]} {

Copied: trunk/base/src/port1.0/tests/Portfile (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/Portfile)
===================================================================
--- trunk/base/src/port1.0/tests/Portfile	                        (rev 0)
+++ trunk/base/src/port1.0/tests/Portfile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,55 @@
+# $Id: Portfile 85472 2011-10-14 01:52:18Z dports at macports.org $
+
+PortSystem              1.0
+
+name                    fondu
+version                 060102
+revision                1
+platforms               darwin
+categories              print
+license                 BSD
+maintainers             nomaintainer
+homepage                http://fondu.sourceforge.net/
+master_sites            http://fondu.sourceforge.net/
+
+description             A set of programs to interconvert between Mac font \
+                        formats and pfb, ttf, otf and bdf files on UNIX.
+
+long_description        Dealing with Mac fonts is hard on other operating \
+                        systems because Mac fonts are stored in the resource \
+                        fork, and other operating systems do not support \
+                        this concept. Fondu will extract the resource fork \
+                        from either a MacBinary file or a BinHex file. Ufond \
+                        will create a resource fork inside a MacBinary file.
+
+checksums               md5 e20861beacddc1ab392bef7813641bf8
+extract.suffix          .tgz
+distfiles               [suffix ${name}_src-${version}]
+
+patchfiles
+
+patch {
+    foreach patch $patchfiles {
+        set fd [open ${portpath}/files/${patch} r]
+        set var [gets $fd]
+        close $fd
+        set fd [open ${workpath}/${distname}/test_patch w+]
+        puts $fd $var
+        close $fd
+    }
+}
+
+post-patch {
+    reinplace "s|^CFLAGS = -g \$(WFLAGS)|CFLAGS = -g \$(WFLAGS) ${configure.cppflags} ${configure.cflags} ${configure.ldflags} [get_canonical_archflags]|g" ${worksrcpath}/Makefile.in
+}
+
+configure.args          --bindir=${prefix}/bin \
+                        --mandir=${prefix}/share/man
+
+post-destroot {
+    eval xinstall -m 644 [glob ${worksrcpath}/*.1] ${destroot}${prefix}/share/man/man1/
+}
+
+test {
+    file delete -force $worksrcpath/README
+}

Deleted: trunk/base/src/port1.0/tests/common.tcl
===================================================================
--- trunk/base/src/port1.0/tests/common.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/port1.0/tests/common.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,18 +0,0 @@
-proc test_equal {statement value} {
-    uplevel 1 "\
-        puts -nonewline {checking if $statement == \"$value\"... }
-        if {\[catch {
-                set actual $statement
-                if {\$actual == \[subst {$value}\]} { \n\
-                    puts yes
-                } else { \n\
-                    puts \"no (was \$actual)\" \n\
-                    exit 1 \n\
-                } \n\
-            } msg\]} { \n\
-                puts \"caught error: \$msg\" \n\
-                exit 1 \n\
-            }"
-}
-
-

Copied: trunk/base/src/port1.0/tests/library.tcl (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/library.tcl)
===================================================================
--- trunk/base/src/port1.0/tests/library.tcl	                        (rev 0)
+++ trunk/base/src/port1.0/tests/library.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,65 @@
+##
+# This is basically a copy of macports::worker_init, but without using
+# sub-interpreters
+proc macports_worker_init {} {
+    interp alias {} _cd {} cd
+    proc PortSystem {version} {
+        package require port $version
+    }
+    # Clearly separate slave interpreters and the master interpreter.
+    interp alias {} mport_exec      {} mportexec
+    interp alias {} mport_open      {} mportopen
+    interp alias {} mport_close     {} mportclose
+    interp alias {} mport_lookup    {} mportlookup
+    interp alias {} mport_info      {} mportinfo
+    # Export some utility functions defined here.
+    interp alias {} macports_create_thread          {} macports::create_thread
+    interp alias {} getportworkpath_from_buildpath  {} macports::getportworkpath_from_buildpath
+    interp alias {} getportresourcepath             {} macports::getportresourcepath
+    interp alias {} getportlogpath                  {} macports::getportlogpath
+    interp alias {} getdefaultportresourcepath      {} macports::getdefaultportresourcepath
+    interp alias {} getprotocol                     {} macports::getprotocol
+    interp alias {} getportdir                      {} macports::getportdir
+    interp alias {} findBinary                      {} macports::findBinary
+    interp alias {} binaryInPath                    {} macports::binaryInPath
+    # New Registry/Receipts stuff
+    interp alias {} registry_new                    {} registry::new_entry
+    interp alias {} registry_open                   {} registry::open_entry
+    interp alias {} registry_write                  {} registry::write_entry
+    interp alias {} registry_prop_store             {} registry::property_store
+    interp alias {} registry_prop_retr              {} registry::property_retrieve
+    interp alias {} registry_exists                 {} registry::entry_exists
+    interp alias {} registry_exists_for_name        {} registry::entry_exists_for_name
+    interp alias {} registry_activate               {} portimage::activate
+    interp alias {} registry_deactivate             {} portimage::deactivate
+    interp alias {} registry_deactivate_composite   {} portimage::deactivate_composite
+    interp alias {} registry_uninstall              {} registry_uninstall::uninstall
+    interp alias {} registry_register_deps          {} registry::register_dependencies
+    interp alias {} registry_fileinfo_for_index     {} registry::fileinfo_for_index
+    interp alias {} registry_fileinfo_for_file      {} registry::fileinfo_for_file
+    interp alias {} registry_bulk_register_files    {} registry::register_bulk_files
+    interp alias {} registry_active                 {} registry::active
+    interp alias {} registry_file_registered        {} registry::file_registered
+    interp alias {} registry_port_registered        {} registry::port_registered
+    interp alias {} registry_list_depends           {} registry::list_depends
+    # deferred options processing.
+    interp alias {} getoption {} macports::getoption
+    # ping cache
+    interp alias {} get_pingtime {} macports::get_pingtime
+    interp alias {} set_pingtime {} macports::set_pingtime
+    # archive_sites.conf handling
+    interp alias {} get_archive_sites_conf_values {} macports::get_archive_sites_conf_values
+    foreach opt $macports::portinterp_options {
+        if {![info exists $opt]} {
+            global macports::$opt
+            set ::$opt macports::$opt
+        }
+        if {[info exists $opt]} {
+            set system_options($opt) $opt
+            set ::$opt $opt
+        }
+    }
+
+    # We don't need to handle portinterp_deferred_options, they're
+    # automatically handled correctly.
+}

Copied: trunk/base/src/port1.0/tests/portactivate.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portactivate.test)
===================================================================
--- trunk/base/src/port1.0/tests/portactivate.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portactivate.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,106 @@
+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 ../port_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 portactivate 1.0
+package require registry 1.0
+
+test activate_start {
+    Activate start unit test.
+    Requires root for setting euid.
+} -constraints {
+    root
+} -setup {
+    # file writable $prefix is used to determine whether privilege escalation
+    # is needed, so set prefix to a directory unwritable for this user
+    set prefix /usr/bin
+
+    # elevateToRoot uses $euid and $egid as the IDs to set
+    set euid 0
+    set egid 0
+
+} -body {
+    # drop privileges; the code won't attempt to elevate privileges without
+    # that
+    seteuid 333
+    if {[catch {portactivate::activate_start args}] != 0} {
+        return "FAIL: couldn't elevate privileges"
+    }
+
+    # when uid == 0 and euid == 0, the code will not attempt to elevate
+    # privileges
+    seteuid 0
+    if {[catch {portactivate::activate_start args}] != 0} {
+        return "FAIL: couldn't elevate privileges"
+    }
+    return "Activate_start successful."
+} -result "Activate_start successful."
+
+
+test activate_main {
+    Activate main unit test.
+} -constraints {
+    root
+} -setup {
+    set destpath $pwd/work/destroot
+    set portbuildpath $pwd
+    set portdbpath $pwd/dbpath
+    set portpath $pwd
+
+    set mport [mportopen file://.]
+
+    # set $version var
+    set workername [ditem_key $mport workername]
+
+    # portinstall setup
+    interp alias {} _cd {} cd
+
+    # hide all output. Deactivate this for debugging!
+    set oldchannels [array get macports::channels]
+    set macports::channels(msg)    {}
+    set macports::channels(notice) {}
+
+    if {[$workername eval eval_targets install] != 0} {
+		return "FAIL: port install failed"
+    }
+
+} -body {
+    if {[$workername eval eval_targets activate] != 0} {
+		return "FAIL: cannot activate port after install"
+    }
+    if {[$workername eval eval_targets deactivate] != 0} {
+        return "FAIL: cannot deactivate port"
+    }
+    if {[$workername eval eval_targets activate] != 0} {
+		return "FAIL: cannot activate port after deactivate"
+    }
+    return "Port activate successful."
+
+} -cleanup {
+    if {[$workername eval eval_targets uninstall] != 0} {
+        return "FAIL: uninstall failed"
+    }
+    if {[$workername eval eval_targets clean] != 0} {
+        return "FAIL: clean failed"
+    }
+    array set macports::channels $oldchannels
+
+    mportclose $mport
+} -result "Port activate successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/portchecksum.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portchecksum.test)
===================================================================
--- trunk/base/src/port1.0/tests/portchecksum.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portchecksum.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,141 @@
+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 ../portchecksum.tcl
+
+
+test parse_checksum {
+    Parse checksum unit test.
+} -body {
+    set all_dist_files {file file2}
+    set checksums_str {file md5 1111 file2 sha1 3333}
+
+    set res [portchecksum::parse_checksums $checksums_str]
+    if {$res != "yes"} {return "FAIL: error in checksum parse"}
+    if {$checksums_array(file) != "md5 1111"} {
+	   return "FAIL: invalid file options"
+    }
+    if {$checksums_array(file2) != "sha1 3333"} {
+	   return "FAIL: invalid file options"
+    }
+    return "Parse checksum successful."
+} -result "Parse checksum successful."
+
+
+test calc_md5 {
+    Calculate md5 unit test. Based on a file it creates.
+} -body {
+    set fd [open $pwd/file w+]
+    puts $fd "test.file"
+    close $fd
+
+    set res [portchecksum::calc_md5 $pwd/file]
+    if {$res != "9f70ecc1095ff10df81be6b5f218328d"} {
+	   return "FAIL: unexpected md5"
+    }
+    return "Calc md5 successful."
+
+} -cleanup {
+    file delete -force $pwd/file
+} -result "Calc md5 successful."
+
+
+test calc_sha1 {
+    Calculate sha1 unit test.
+} -body {
+    set fd [open $pwd/file w+]
+    puts $fd "test.file"
+    close $fd
+
+    set res [portchecksum::calc_sha1 $pwd/file]
+    if {$res != "5560df60ff202ca8b8c3dcf51ad650b78e859261"} {
+	   return "FAIL: unexpected sha1"
+    }
+    return "Calc sha1 successful."
+
+} -cleanup {
+    file delete -force $pwd/file
+} -result "Calc sha1 successful."
+
+
+test calc_rmd160 {
+    Calculate rmd160 unit test.
+} -body {
+    set fd [open $pwd/file w+]
+    puts $fd "test.file"
+    close $fd
+
+    set res [portchecksum::calc_rmd160 $pwd/file]
+    if {$res != "5aee5d12fe536e2e288e9f1daafd84f1bc17c3e6"} {
+	   return "FAIL: unexpected rmd160"
+    }
+    return "Calc rmd160 successful."
+
+} -cleanup {
+    file delete -force $pwd/file
+} -result "Calc rmd160 successful."
+
+
+test calc_sha256 {
+    Calculate sha256 unit test.
+} -body {
+    set fd [open $pwd/file w+]
+    puts $fd "test.file"
+    close $fd
+
+    set res [portchecksum::calc_sha256 $pwd/file]
+    if {$res != "2f686816f2a80e8efcc4ef40ac4e898d27ce4205a61ee422d56f8c5e8b46612e"} {
+	   return "FAIL: unexpected sha1"
+    }
+    return "Calc sha256 successful."
+
+} -cleanup {
+    file delete -force $pwd/file
+} -result "Calc sha256 successful."
+
+
+# test checksum_start
+
+
+test checksum_main {
+    Checksum main unit test. Checks for empty files.
+} -body {
+    set all_dist_files {file file2}
+    set checksum.skip yes
+
+    if {[portchecksum::checksum_main] != 0} {
+	   return "FAIL: checksum not skipped"
+    }
+
+    set checksum.skip no
+    set distpath $pwd/dpath
+    set usealtworkpath no
+    set altprefix prefix
+
+    file mkdir $distpath
+    close [open $distpath/file w]
+    close [open $distpath/file2 w]
+    array set checksums_array {
+	   file {md5 d41d8cd98f00b204e9800998ecf8427e}
+	   file2 {sha1 da39a3ee5e6b4b0d3255bfef95601890afd80709}
+    }
+
+    if {[portchecksum::checksum_main] != 0} {
+	   return "FAIL: incorrect checksum"
+    }
+    return "Checksum main successful."
+
+} -cleanup {
+    file delete -force $distpath
+    file delete -force file
+    file delete -force file2
+} -result "Checksum main successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/portclean.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portclean.test)
===================================================================
--- trunk/base/src/port1.0/tests/portclean.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portclean.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,212 @@
+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 ../port_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 portclean 1.0
+source ../port_autoconf.tcl
+
+test clean_start {
+    Clean start unit test.
+} -constraints {
+    root
+} -body {
+    set prefix /opt/local
+    seteuid 333
+    if {[catch {clean_start args}] != 1} {
+	   return "FAIL: couldn't elevate privileges"
+    }
+    seteuid 0
+    return "Clean_start successful."
+} -result "Clean_start successful."
+
+
+# test clean_main
+
+
+test clean_dist {
+    Clean distfiles unit test.
+} -body {
+    set usealtworkpath no
+    set ports_force yes
+    set portdbpath $pwd/dbpath
+    set altprefix /tmp/altprefix
+    set dist_subdir subdir
+    set name subdir_name
+    set distpath $pwd/distpath
+    lappend distfiles $distpath/dist_file
+    lappend distfiles $distpath/dist_file2
+    set patchpath $pwd/patchpath
+    lappend patchfiles $patchpath/patch_file
+    lappend patchfiles $patchpath/patch_file2
+
+    # create files
+    file mkdir $distpath
+    close [open $distpath/dist_file w+]
+    close [open $distpath/dist_file2 w+]
+    file mkdir $altprefix$distpath
+    close [open $altprefix$distpath/dist_file2 w+]
+    file mkdir $portdbpath/distfiles/$dist_subdir
+    close [open $portdbpath/distfiles/$dist_subdir/subdir_file w+]
+    close [open $portdbpath/distfiles/$dist_subdir/subdir_$name w+]
+
+    # create patch files
+    file mkdir $patchpath
+    close [open $patchpath/patch_file2 w+]
+    file mkdir $altprefix$patchpath
+    close [open $altprefix$patchpath/patch_file2 w+]
+
+    portclean::clean_dist
+
+    if {[file exists $distpath/dist_file]} {
+	   return "FAIL: distfile not removed"
+    }
+    if {[file exists $distpath/dist_file2]} {
+	   return "FAIL: distfile not removed"
+    }
+    if {[file exists $altprefix$distpath/dist_file2]} {
+	   return "FAIL: alt distfile not removed"
+    }
+    if {[file exists $patchpath/patch_file2]} {
+	   return "FAIL: patchfile not removed"
+    }
+    if {[file exists $altprefix$patchpath/patch_file2]} {
+	   return "FAIL: alt patchfile not removed"
+    }
+    if {[file exists $portdbpath/distfiles/$dist_subdir]} {
+	   return "FAIL: distfiles dir not removed"
+    }
+
+    return "Clean distfiles successful."
+
+} -cleanup {
+    file delete -force $distpath
+    file delete -force $portdbpath
+    file delete -force $patchpath
+    file delete -force $altprefix
+
+} -result "Clean distfiles successful."
+
+
+test clean_work {
+    Clean work unit test.
+} -constraints {
+    root
+} -body {
+    set usealtworkpath no
+    set altprefix $pwd/prefix
+    set portpath portpath
+    set subbuildpath /subbuild
+    set worksymlink $pwd/symlink
+
+    # create files
+    file mkdir $subbuildpath
+    close [open $subbuildpath/test.work w+]
+    file mkdir $altprefix/subbuild
+    close [open $altprefix/subbuild/test.work w+]
+    close [open $altprefix/$portpath w+]
+    file link -symbolic $worksymlink $subbuildpath
+
+    portclean::clean_work
+
+    if {[file exists $subbuildpath]} {
+	   return "FAIL: buildpath not removed"
+    }
+    if {[file exists $altprefix/subbuild]} {
+	   return "FAIL: subbuild not removed"
+    }
+    if {[file exists $worksymlink]} {
+	   return "FAIL: symlink not removed"
+    }
+    if {[file exists $altprefix$portpath]} {
+	   return "FAIL: port dir in alt prefix not removed"
+    }
+
+    return "Clean work successful."
+
+} -cleanup {
+    file delete -force $subbuildpath
+    file delete -force $altprefix
+    file delete -force $worksymlink
+
+} -result "Clean work successful."
+
+
+test clean_logs {
+    Clean logs unit test.
+} -constraints {
+    root
+} -body {
+    set portpath $pwd/portpath
+    set logpath [getportlogpath $portpath]
+    set subport $logpath/subport
+
+    # create files
+    file mkdir $subport
+    close [open $subport/test.log w+]
+
+    portclean::clean_logs
+
+    if {[file exists $subport]} {
+	   return "FAIL: log dir not removed"
+    }
+    return "Clean logs successful."
+
+} -cleanup {
+    file delete -force $portpath
+    file delete -force $subport
+
+} -result "Clean logs successful."
+
+
+test clean_archive {
+    Clean archive unit test.
+} -body {
+    set subport subport
+    set portdbpath $pwd/dbpath
+
+    file mkdir $portdbpath/incoming
+    close [open $portdbpath/incoming/test.clean w+]
+    close [open $portdbpath/incoming/subport-1_0.0.0.0.TMP w+]
+
+    # create zip
+    set fd [open $pwd/+CONTENTS w+]
+    puts $fd "@portname subport"
+    close $fd
+    exec zip $portdbpath/incoming/subport-2_0.0.0.0.zip +CONTENTS
+
+    portclean::clean_archive
+
+    if {[file exists $portdbpath/incoming/subport-1_0.0.0.0.TMP]} {
+	   return "FAIL: .TMP file not removed"
+    }
+    if {![file exists $portdbpath/incoming/test.clean]} {
+	   return "FAIL: removed unrelated file"
+    }
+    if {[file exists $portdbpath/incoming/subport-2_0.0.0.0.zip]} {
+	   return "FAIL: zip archive not removed"
+    }
+
+    return "Clean archive successful."
+
+} -cleanup {
+    file delete -force $pwd/+CONTENTS
+    file delete -force $portdbpath
+
+} -result "Clean archive successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/portdeactivate.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portdeactivate.test)
===================================================================
--- trunk/base/src/port1.0/tests/portdeactivate.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portdeactivate.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,103 @@
+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 ../port_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 portdeactivate 1.0
+package require registry 1.0
+
+test activate_start {
+    Deactivate start unit test.
+    Requires root for setting euid.
+} -constraints {
+    root
+} -setup {
+    # file writable $prefix is used to determine whether privilege escalation
+    # is needed, so set prefix to a directory unwritable for this user
+    set prefix /usr/bin
+
+    # elevateToRoot uses $euid and $egid as the IDs to set
+    set euid 0
+    set egid 0
+
+} -body {
+    # drop privileges; the code won't attempt to elevate privileges without
+    # that
+    seteuid 333
+    if {[catch {portdeactivate::deactivate_start args}] != 0} {
+        return "FAIL: couldn't elevate privileges"
+    }
+
+    # when uid == 0 and euid == 0, the code will not attempt to elevate
+    # privileges
+    seteuid 0
+    if {[catch {portdeactivate::deactivate_start args}] != 0} {
+        return "FAIL: couldn't elevate privileges"
+    }
+    return "Deactivate_start successful."
+} -result "Deactivate_start successful."
+
+
+test deactivate_main {
+    Deactivate main unit test.
+} -constraints {
+    root
+} -setup {
+    set destpath $pwd/work/destroot
+    set portbuildpath $pwd
+    set portdbpath $pwd/dbpath
+    set portpath $pwd
+
+    set mport [mportopen file://.]
+
+    # set $version var
+    set workername [ditem_key $mport workername]
+
+    # portinstall setup
+    interp alias {} _cd {} cd
+
+    # hide all output. Deactivate this for debugging!
+    set oldchannels [array get macports::channels]
+    set macports::channels(msg)    {}
+    set macports::channels(notice) {}
+
+    if {[$workername eval eval_targets install] != 0} {
+		return "FAIL: port install failed"
+    }
+
+} -body {
+    if {[$workername eval eval_targets activate] != 0} {
+		return "FAIL: cannot activate port after install"
+    }
+    if {[$workername eval eval_targets deactivate] != 0} {
+		return "FAIL: cannot deactivate port after activate"
+    }
+	return "Port deactivate successful."
+
+} -cleanup {
+	if {[$workername eval eval_targets uninstall] != 0} {
+    	return "FAIL: uninstall failed"
+	}
+	if {[$workername eval eval_targets clean] != 0} {
+    	return "FAIL: clean failed"
+	}
+	array set macports::channels $oldchannels
+
+	mportclose $mport
+} -result "Port deactivate successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/portdepends.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portdepends.test)
===================================================================
--- trunk/base/src/port1.0/tests/portdepends.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portdepends.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,38 @@
+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 ../port_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 ../portdepends.tcl
+
+
+test validate_depends_options {
+    Validate depends unit test.
+} -body {
+    set res [catch {portdepends::validate_depends_options target set {lib:test.val:value}}]
+    if {$res != 0} {return "FAIL: value lib:test.val:value not accepted"}
+    set res [catch {portdepends::validate_depends_options target set {bin:test.val:value}}]
+    if {$res != 0} {return "FAIL: value bin:test.val:value not accepted"}
+    set res [catch {portdepends::validate_depends_options target set {path:test:value}}]
+    if {$res != 0} {return "FAIL: value path:test:value not accepted"}
+    set res [catch {portdepends::validate_depends_options target set {port:test3}}]
+    if {$res != 0} {return "FAIL: value port:test3 not accepted"}
+    set res [catch {portdepends::validate_depends_options target set {lib:test}}]
+    if {$res != 1} {return "FAIL: invalid options lib:test accepted"}
+    return "Validate depends successful."
+} -result "Validate depends successful."
+
+# test validate_depends_options_new
+
+
+cleanupTests

Deleted: trunk/base/src/port1.0/tests/portdestroot.tcl
===================================================================
--- trunk/base/src/port1.0/tests/portdestroot.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/port1.0/tests/portdestroot.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,40 +0,0 @@
-source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
-package require macports
-mportinit
-
-source [file dirname [info script]]/../portdestroot.tcl
-source [file dirname [info script]]/common.tcl
-
-namespace eval tests {
-
-proc "when destroot cmd is not gmake no -w argument is added" {} {
-    global build.type build.cmd destroot.cmd destroot.target
-
-    set build.type "gnu"
-    set build.cmd "gmake"
-    set destroot.cmd "_destroot_cmd_"
-    set destroot.target "_target_"
-
-    test_equal {[portdestroot::destroot_getargs]} "_target_"
-}
-
-proc "when destroot cmd is gmake a -w argument is added" {} {
-    global build.type build.cmd destroot.cmd destroot.target
-
-    set build.type "gnu"
-    set build.cmd "_build_cmd_"
-    set destroot.cmd "gmake"
-    set destroot.target "_target_"
-
-    test_equal {[portdestroot::destroot_getargs]} "-w _target_"
-}
-
-
-# run all tests
-foreach proc [info procs *] {
-    puts "* ${proc}"
-    $proc
-}
-
-# namespace eval tests
-}

Copied: trunk/base/src/port1.0/tests/portdistcheck.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portdistcheck.test)
===================================================================
--- trunk/base/src/port1.0/tests/portdistcheck.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portdistcheck.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,50 @@
+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 ../port_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
+
+source ../portdistcheck.tcl
+
+
+test distcheck_main {
+    Distcheck main unit test.
+} -setup {
+    set portpath $pwd
+    set filespath $pwd/files
+
+    set name cocot
+    set subport $name
+    set distname cocot-20080315
+    set porturl "http://distfiles.macports.org/cocot/"
+    set master_sites $porturl
+    set extract.suffix .tar.bz2
+
+} -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"
+    }
+
+    return "Distcheck main successful."
+} -result "Distcheck main successful."
+
+
+cleanupTests

Deleted: trunk/base/src/port1.0/tests/portfetch.tcl
===================================================================
--- trunk/base/src/port1.0/tests/portfetch.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/port1.0/tests/portfetch.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,58 +0,0 @@
-source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
-package require macports
-mportinit
-
-set scriptdir [file dirname [info script]]
-source ${scriptdir}/../portfetch.tcl
-source ${scriptdir}/common.tcl
-
-namespace eval tests {
-
-proc "mirror tags are parsed correctly" {} {
-    global distfiles master_sites name dist_subdir filespath scriptdir
-
-    set name test
-    set filespath $scriptdir
-    set dist_subdir tset
-    set portfetch::mirror_sites::sites(macports_test) {
-        http://distfiles.macports.org/:mirror
-        http://distfiles2.macports.org:80/:mirror
-        http://distfiles3.macports.org:80/
-        http://distfiles4.macports.org:80/some/subdir/
-        http://distfiles5.macports.org:80/some/subdir/:mirror
-    }
-    set distfiles test.tar.bz2
-    set master_sites macports_test
-    set fetch_urls {}
-    portfetch::checksites [list master_sites {}] ""
-    portfetch::checkdistfiles fetch_urls
-
-    global portfetch::urlmap
-    foreach {url_var distfile} $fetch_urls {
-        if {![info exists urlmap($url_var)]} {
-            set urlmap($url_var) $urlmap(master_sites)
-        }
-        foreach site $urlmap($url_var) {
-            set file_url [portfetch::assemble_url $site $distfile]
-            lappend all_file_urls $file_url
-        }
-    }
-    set all_file_urls [lsort $all_file_urls]
-
-    set expected [list http://distfiles.macports.org/tset/test.tar.bz2 \
-                       http://distfiles2.macports.org:80/tset/test.tar.bz2 \
-                       http://distfiles3.macports.org:80/test/test.tar.bz2 \
-                       http://distfiles4.macports.org:80/some/subdir/test/test.tar.bz2 \
-                       http://distfiles5.macports.org:80/some/subdir/tset/test.tar.bz2]
-
-    test_equal {$all_file_urls} {$expected}
-}
-
-# run all tests
-foreach proc [info procs *] {
-    puts "* ${proc}"
-    $proc
-}
-
-# namespace eval tests
-}

Copied: trunk/base/src/port1.0/tests/portinstall.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portinstall.test)
===================================================================
--- trunk/base/src/port1.0/tests/portinstall.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portinstall.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,182 @@
+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 ../port_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
+
+source ../portinstall.tcl
+source ../../registry2.0/portuninstall.tcl
+source ../port_autoconf.tcl
+
+# Set env vars
+set os.platform darwin
+set macosx_version 10.8
+set os_version 12
+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 revision 2
+
+
+test install_start {
+    Install start unit test.
+} -constraints {
+    root
+} -setup {
+    set portvariants {var1}
+    set prefix prefix
+    set add_users no
+
+} -body {
+    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.
+} -constraints {
+	root
+} -setup {
+	set destpath $pwd/work/destroot
+	set portbuildpath $pwd
+	set portdbpath $pwd/dbpath
+	set portpath $pwd
+	set create /dev/null
+
+	# destroot setup
+    file mkdir $pwd/$subport
+    set mport [mportopen file://.]
+
+    # set $version var
+    set workername [ditem_key $mport workername]
+
+    # run destroot
+    if {[$workername eval eval_targets destroot] != 0} {
+		return "FAIL: destroot failed"
+	}
+
+	# portinstall setup
+	interp alias {} _cd {} cd
+
+	# hide all output. Deactivate this for debugging!
+	set oldchannels [array get macports::channels]
+	set macports::channels(msg)    {}
+	set macports::channels(notice) {}
+
+	if {[$workername eval eval_targets install] != 0} {
+		return "FAIL: port install failed"
+	}
+
+} -body {
+    if {[catch {$workername eval portinstall::create_archive $create tgz}] != 0} {
+		return "FAIL: cannot create archive"
+    }
+    return "Create archive successful."
+
+} -cleanup {
+	if {[$workername eval eval_targets uninstall] != 0} {
+    	return "FAIL: uninstall failed"
+	}
+	if {[$workername eval eval_targets clean] != 0} {
+    	return "FAIL: clean failed"
+	}
+	array set macports::channels $oldchannels
+	mportclose $mport
+
+    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.
+} -constraints {
+	root
+
+} -setup {
+	set workpath $pwd/work
+    set portpath $pwd
+    set portdbpath $pwd/dbpath
+    set portbuildpath $pwd
+    set destpath $pwd/work/destroot
+	set portvariants {+var1}
+	
+	set epoch i386
+	set compiler.cpath /usr/bin/gcc
+	set compiler.library_path /usr/lib
+
+	# destroot setup
+    file mkdir $pwd/$subport
+    set mport [mportopen file://.]
+
+    if {[eval_variants variations] != 0} {
+        mportclose $mport
+        error "Error evaluating variants"
+    }
+
+    # set $version var
+    set workername [ditem_key $mport workername]
+
+    # run destroot
+    if {[$workername eval eval_targets destroot] != 0} {
+		return "FAIL: destroot failed"
+	}
+
+	# portinstall setup
+	interp alias {} _cd {} cd
+
+	# hide all output. Deactivate this for debugging!
+	set oldchannels [array get macports::channels]
+	set macports::channels(msg)    {}
+	set macports::channels(notice) {}
+
+} -body {
+    if {[$workername eval eval_targets install] != 0} {
+		return "FAIL: cannot install port"
+    }
+    return "Install main successful."
+
+} -cleanup {
+	if {[$workername eval eval_targets uninstall] != 0} {
+    	return "FAIL: uninstall failed"
+	}
+	if {[$workername eval eval_targets clean] != 0} {
+    	return "FAIL: clean failed"
+	}
+	array set macports::channels $oldchannels
+
+	mportclose $mport
+
+    file delete -force $pwd/$subport
+    file delete -force $portdbpath
+    file delete -force $pwd/work
+
+} -result "Install main successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/portload.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portload.test)
===================================================================
--- trunk/base/src/port1.0/tests/portload.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portload.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,60 @@
+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 ../port_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 ../portload.tcl
+source ../port_autoconf.tcl
+
+
+test load_main {
+    Load main unit test.
+} -constraints {
+	root
+
+} -setup {
+    set path /Library/test/files
+    file mkdir $path
+
+    # Create dummy plist
+    set fd [open $path/file.plist w+]
+    puts $fd "\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>"
+    puts $fd "\<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\>"
+    puts $fd "\<plist version=\"1.0\"\>"
+    puts $fd "\<dict\>"
+    puts $fd "\<key\>Label\</key\>"
+    puts $fd "\<string\>org.test.load\</string\>"
+    puts $fd "\<key\>ProgramArguments\</key\>"
+    puts $fd "\<array\>\<string\>/bin/ls\</string\>\</array\>"
+    puts $fd "\</dict\>"
+    puts $fd "\</plist\>"
+    close $fd
+
+} -body {
+    set launchctl_path ${portutil::autoconf::launchctl_path}
+    set startupitem.location test
+    set startupitem.plist files/file.plist
+
+    if {[portload::load_main] != ""} {
+		return "FAIL: unable to load plist"
+    }
+    return "Load successful."
+
+} -cleanup {
+    exec $launchctl_path unload -w $path 2>@stderr
+    file delete -force /Library/test
+
+} -result "Load successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/portmain.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portmain.test)
===================================================================
--- trunk/base/src/port1.0/tests/portmain.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portmain.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,52 @@
+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 ../port_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 portmain 1.0
+
+# Set testing vars
+set os_platform darwin
+set macosx_version 10.8
+set os_version 12
+set os_arch i386
+set portpath .
+set portbuildpath ./build
+
+
+test get_default_subport {
+    Get default subport unit test.
+} -body {
+    set portpath path/port/subport
+    if {[portmain::get_default_subport] != "subport"} {
+		return "FAIL: wrong subport"
+    }
+    return "Get default subport successful."
+} -result "Get default subport successful."
+
+
+test get_subbuildpath {
+    Get subbuildpath unit test.
+} -body {
+    set portpath path/port/subport
+    if {[portmain::get_subbuildpath] != "./build/subport"} {
+		return "FAIL: wrong subbuildpath"
+    }
+    return "Get subbuild path successful."
+} -result "Get subbuild path successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/portpatch.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portpatch.test)
===================================================================
--- trunk/base/src/port1.0/tests/portpatch.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portpatch.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,78 @@
+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 ../port_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 portpatch
+source ../port_autoconf.tcl
+
+
+test build_getpatchtype {
+    Get patch type unit test.
+} -body {
+    set res [portpatch::build_getpatchtype]
+    if {$res != $portutil::autoconf::patch_path} {
+		return "FAIL: wrong path"
+    }
+    return "Get patch type successful."
+} -result "Get patch type successful."
+
+
+test patch_main {
+    Patch main unit test.
+} -constraints {
+    root
+} -setup {
+    set macosx_version 12
+
+    set subport fondu
+    set filespath $pwd/files
+    set distpath $pwd/dist
+    set usealtworkpath yes
+    set altprefix prefix
+
+    set workpath $pwd/work
+    set worksrcpath $workpath/src
+    set compiler.cpath /usr/bin/gcc
+    set compiler.library_path /usr/lib
+    set macosx_deployment_target $pwd/deploy_target
+
+    file mkdir $filespath
+    set fd [open $filespath/file.diff w+]
+    puts $fd "first line should get to the workpath"
+    close $fd
+
+    set mport [mportopen file://.]
+    set workername [ditem_key $mport workername]
+    $workername eval "set patchfiles {file.diff}"
+
+} -body {
+    if {[$workername eval eval_targets patch]} {
+        return "FAIL: cannot run patch"
+    }
+    if {![file exists $pwd/work/fondu-060102/test_patch]} {
+        return "FAIL: missing patched file"
+    }
+    return "Patch successful."
+
+} -cleanup {
+    file delete -force $filespath
+    file delete -force $pwd/work
+
+} -result "Patch successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/porttest.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/porttest.test)
===================================================================
--- trunk/base/src/port1.0/tests/porttest.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/porttest.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,71 @@
+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 ../port_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 port 1.0
+package require registry 1.0
+
+
+# test test_start
+
+test test_main {
+    Test main unit test.
+} -constraints {
+    root
+} -setup {
+    set destpath $pwd/work/destroot
+    set portbuildpath $pwd
+    set portdbpath $pwd/dbpath
+    set portpath $pwd
+
+    set mport [mportopen file://.]
+
+    # set $version var
+    set workername [ditem_key $mport workername]
+
+    # portinstall setup
+    interp alias {} _cd {} cd
+
+    # hide all output. Deactivate this for debugging!
+    set oldchannels [array get macports::channels]
+    set macports::channels(msg)    {}
+    set macports::channels(notice) {}
+
+    if {[$workername eval eval_targets install] != 0} {
+	return "FAIL: port install failed"
+    }
+
+} -body {
+    if {[$workername eval eval_targets test] != 0} {
+	return "FAIL: test target failed"
+    }
+
+    return "Test main successful."
+
+} -cleanup {
+    if {[$workername eval eval_targets uninstall] != 0} {
+    	return "FAIL: uninstall failed"
+    }
+    if {[$workername eval eval_targets clean] != 0} {
+    	return "FAIL: clean failed"
+    }
+    file delete -force $pwd/work
+
+} -result "Test main successful."
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/portuninstall.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portuninstall.test)
===================================================================
--- trunk/base/src/port1.0/tests/portuninstall.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portuninstall.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,95 @@
+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 ../port_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
+
+source ../portinstall.tcl
+source ../../registry2.0/portuninstall.tcl
+source ../port_autoconf.tcl
+
+set subport fondu
+set version 3.0
+set revision 2
+
+
+# test uninstall_start
+
+
+test uninstall_main {
+    Uninstall main unit test.
+} -constraints {
+	root
+
+} -setup {
+	set workpath $pwd/work
+	set portpath $pwd
+	set portdbpath $pwd/dbpath
+	set portbuildpath $pwd
+	set destpath $pwd/work/destroot
+	set portvariants {+var1}
+
+	set epoch i386
+	set compiler.cpath /usr/bin/gcc
+	set compiler.library_path /usr/lib
+
+	# destroot setup
+	file mkdir $pwd/$subport
+	set mport [mportopen file://.]
+
+	if {[eval_variants variations] != 0} {
+    	mportclose $mport
+    	error "Error evaluating variants"
+	}
+
+	# set $version var
+	set workername [ditem_key $mport workername]
+
+	# run destroot
+	if {[$workername eval eval_targets destroot] != 0} {
+		return "FAIL: destroot failed"
+	}
+
+	# portinstall setup
+	interp alias {} _cd {} cd
+
+	# hide all output. Deactivate this for debugging!
+	set oldchannels [array get macports::channels]
+	set macports::channels(msg)    {}
+	set macports::channels(notice) {}
+	
+	if {[$workername eval eval_targets install] != 0} {
+		return "FAIL: cannot install port"
+    }
+
+} -body {
+	if {[$workername eval eval_targets uninstall] != 0} {
+		return "FAIL: uninstall failed"
+	}
+    return "Uninstall main successful."
+
+} -cleanup {
+	if {[$workername eval eval_targets clean] != 0} {
+    	return "FAIL: clean failed"
+	}
+	
+    file delete -force $pwd/$subport
+    file delete -force $portdbpath
+    file delete -force $pwd/work
+
+} -result "Uninstall main successful."
+
+
+cleanupTests

Deleted: trunk/base/src/port1.0/tests/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/tests/portutil.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/port1.0/tests/portutil.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,217 +0,0 @@
-# Test file for Pextlib's fs-traverse
-# Requires r/w access to /tmp
-# MacPorts must be installed for this to work
-
-source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
-package require macports
-mportinit
-
-# load the current copy of portutil instead of the installed one
-source [file dirname [info script]]/../portutil.tcl
-
-# end boilerplate
-
-namespace eval tests {
-
-proc test_delete {} {
-    set root "/tmp/macports-portutil-delete"
-    # use file delete -force to kill the test directory if it already exists
-    # yeah I realize this will fail on 10.3 if it already exists. oh well.
-    file delete -force $root
-    
-    try {
-        mtree $root {
-            a               directory
-            a/a             file
-            a/b             file
-            a/c             directory
-            a/c/a           file
-            a/c/b           {link ../b}
-            a/c/c           {link ../../b}
-            a/c/d           directory
-            a/c/d/a         file
-            a/c/d/b         directory
-            a/c/d/c         file
-            a/d             file
-            b               directory
-            b/a             file
-            b/b             {link q}
-            b/c             directory
-            b/c/a           file
-            b/c/b           file
-            b/d             file
-        }
-        
-        # test deleting a symlink
-        delete $root/a/c/b
-        
-        if {[file exists $root/a/c/b] || ![file exists $root/a/b]} {
-            error "delete (symlink) failed"
-        }
-        
-        # test multiple args
-        delete $root/a $root/b
-        
-        if {[file exists $root/a] || [file exists $root/b]} {
-            error "delete (multiple args) failed"
-        }
-    } finally {
-        file delete -force $root
-    }
-}
-
-proc test_depends_lib-delete {} {
-    # tests depends_lib-delete
-    # actually tests all option-deletes
-    # but the bug was originally documented with depends_lib
-    
-    # depends_lib is intended to work from within a worker thread
-    # so we shall oblige
-    set workername [interp create]
-    macports::worker_init $workername {} {} [macports::getportbuildpath {}] {} {}
-    $workername alias scriptname info script
-    set body {
-        # load the current copy of portutil instead of the installed one
-        source [file dirname [scriptname]]/../portutil.tcl
-        package require port
-        
-        depends_lib port:foo port:bar port:blah
-        depends_lib-delete port:blah port:bar
-        array get PortInfo
-    }
-    if {[catch {$workername eval $body} result]} {
-        interp delete $workername
-        error $result $::errorInfo $::errorCode
-    } else {
-        interp delete $workername
-    }
-    array set temp $result
-    if {$temp(depends_lib) ne "port:foo"} {
-        error "depends_lib-delete did not delete properly"
-    }
-}
-
-proc test_touch {} {
-    set root "/tmp/macports-portutil-touch"
-    file delete -force $root
-    
-    try {
-        touch -c $root
-        if {[file exists $root]} { error "touch failed" }
-    
-        touch $root
-        if {![file exists $root]} { error "touch failed" }
-    
-        touch -a -t 199912010001.01 $root
-        if {[file atime $root] != [clock scan 19991201T000101]} { error "touch failed" }
-        if {[file mtime $root] == [clock scan 19991201T000101]} { error "touch failed" }
-    
-        touch -m -t 200012010001.01 $root
-        if {[file atime $root] == [clock scan 20001201T000101]} { error "touch failed" }
-        if {[file mtime $root] != [clock scan 20001201T000101]} { error "touch failed" }
-    
-        touch -a -m -t 200112010001.01 $root
-        if {[file atime $root] != [clock scan 20011201T000101]} { error "touch failed" }
-        if {[file mtime $root] != [clock scan 20011201T000101]} { error "touch failed" }
-    
-        touch -r ~ $root
-        if {[file atime $root] != [file atime ~]} { error "touch failed" }
-        if {[file mtime $root] != [file mtime ~]} { error "touch failed" }
-    } finally {
-        file delete -force $root
-    }
-}
-
-proc test_ln {} {
-    set root "/tmp/macports-portutil-ln"
-    file delete -force $root
-    
-    file mkdir $root
-    try {
-        close [open $root/a w]
-        ln -s a $root/b
-        if {[catch {file type $root/b}] || [file type $root/b] ne "link"} {
-            set message "ln failed: "
-            if {[catch {file type $root/b}]} {
-                append message "symlink not created"
-            } elseif {[file type $root/b] ne "link"} {
-                append message "created [file type $root/b], expected link"
-            }
-            error $message
-        }
-    
-        close [open $root/c w]
-        if {![catch {ln -s c $root/b}]} { error "ln failed" }
-    
-        ln -s -f c $root/b
-        if {[catch {file type $root/b}] || [file type $root/b] ne "link"} { error "ln failed" }
-    
-        file delete $root/b
-    
-        ln $root/a $root/b
-        if {[catch {file type $root/b}] || [file type $root/b] ne "file"} { error "ln failed" }
-    
-        file delete $root/b
-        file mkdir $root/dir
-        ln -s dir $root/b
-        ln -s a $root/b
-        if {[catch {file type $root/dir/a}] || [file type $root/dir/a] ne "link"} { error "ln failed" }
-        file delete $root/dir/a
-    
-        ln -s -f -h a $root/b
-        if {[catch {file type $root/b}] || [file type $root/b] ne "link" || [file readlink $root/b] ne "a"} { error "ln failed" }
-    
-        cd $root/dir
-        ln -s ../c
-        if {[catch {file type $root/dir/c}] || [file type $root/dir/c] ne "link"} { error "ln failed" }
-    
-        ln -s foobar $root/d
-        if {[catch {file type $root/d}] || [file type $root/d] ne "link" || [file readlink $root/d] ne "foobar"} { error "ln failed" }
-        
-        ln -s -f -h z $root/dir
-        if {[catch {file type $root/dir/z}] || [file type $root/dir/z] ne "link"} { error "ln failed" }
-        
-        # test combined flags
-        ln -sf q $root/dir
-        if {[catch {file type $root/dir/q}] || [file type $root/dir/q] ne "link"} { error "ln failed" }
-    } finally {
-        file delete -force $root
-    }
-}
-
-# Create a filesystem hierarchy based on the given specification
-# The mtree spec consists of name/type pairings, where type can be
-# one of directory, file or link. If type is link, it must be a
-# two-element list containing the path as the second element
-proc mtree {root spec} {
-    foreach {entry typelist} $spec {
-        set type [lindex $typelist 0]
-        set link [lindex $typelist 1]
-        set file [file join $root $entry]
-        switch $type {
-            directory {
-                file mkdir $file
-            }
-            file {
-                # touch
-                close [open $file w]
-            }
-            link {
-                # file link doesn't let you link to files that don't exist
-                # so lets farm out to /bin/ln
-                exec /bin/ln -s $link $file
-            }
-            default {
-                return -code error "Unknown file map type: $typelist"
-            }
-        }
-    }
-}
-
-# run all tests
-foreach proc [info procs test_*] {
-    $proc
-}
-
-# namespace eval tests
-}

Copied: trunk/base/src/port1.0/tests/portutil.test (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/portutil.test)
===================================================================
--- trunk/base/src/port1.0/tests/portutil.test	                        (rev 0)
+++ trunk/base/src/port1.0/tests/portutil.test	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,854 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source ../../macports1.0/macports_fastload.tcl
+
+set pwd [file normalize $argv0]
+set pwd [eval file join {*}[lrange [file split $pwd] 0 end-1]]
+
+source ../port_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 registry 1.0
+package require registry2 2.0
+package require Pextlib 1.0
+package require macports_dlist 1.0
+package require macports_util 1.0
+package require msgcat
+package require porttrace 1.0
+
+proc init {} {
+    global macports::registry.path
+
+    set db_path [file join ${registry.path} registry registry.db]
+    set db_exists [file exists $db_path]
+    #registry::active
+}
+
+proc init_eval_targets {} {
+    global os_platform os_version os_arch macosx_version pwd
+    global version mport portpath portbuildpath
+
+    set os_platform darwin
+    set macosx_version 10.8
+    set os_version 11
+    set os_arch i386
+    set portpath .
+    set portbuildpath ./build
+
+    # vars for target_run
+    global portdbpath usealtworkpath
+    set usealtworkpath no
+    set portdbpath $pwd/
+    set workpath $pwd/work
+    set altprefix ""
+
+
+    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 $portname]]
+    }
+
+    source $pwd/../portutil.tcl
+    source $pwd/../portmain.tcl
+
+    #variant provides code requires aaa
+}
+
+
+# Create a filesystem hierarchy based on the given specification
+# The mtree spec consists of name/type pairings, where type can be
+# one of directory, file or link. If type is link, it must be a
+# two-element list containing the path as the second element
+proc mtree {root spec} {
+    foreach {entry typelist} $spec {
+        set type [lindex $typelist 0]
+        set link [lindex $typelist 1]
+        set file [file join $root $entry]
+        switch $type {
+            directory {
+                file mkdir $file
+            }
+            file {
+                # touch
+                close [open $file w]
+            }
+            link {
+                # file link doesn't let you link to files that don't exist
+                # so lets farm out to /bin/ln
+                exec /bin/ln -sf $link $file
+            }
+            default {
+                return -code return "Unknown file map type: $typelist"
+            }
+        }
+    }
+}
+
+
+test option {
+    Option unit test. Tcl 'set' functionality.
+} -body {
+    if {[option MP macports] != "macports"} {return "FAIL: var not set correctly"}
+    if {$MP != "macports"} {return "FAIL: var not set"}
+    return "Option successful."
+} -result "Option successful."
+
+
+test exists {
+    Exists unit test. Checks for existance of a Portfile option.
+} -body {
+    set vara a
+    if {[exists vara] != 1} {return "FAIL: option exists but not detected"}
+    if {[exists varb] != 0} {return "FAIL: option detected although missing"}
+    return "Exists successful."
+} -result "Exists successful."
+
+
+test handle_option {
+    Handle_option unit test.
+} -body {
+    if {[handle_option vara a] != "a"} {return "FAIL: unable to set var"}
+    return "Handle_option successful."
+} -result "Handle_option successful."
+
+
+test handle_option-append {
+    Handle_option append unit test.
+} -body {
+    set user_options {vara varb}
+    handle_option-append user_options varc
+    if {[lsearch $user_options varc] < 0} {return "FAIL: var not appended"}
+    if {[lsearch $user_options vard] >= 0} {return "FAIL: unappended var found"}
+    return "Handle_option-append successful."
+} -result "Handle_option-append successful."
+
+
+test handle_option-delete {
+    Handle_option delete unit test.
+} -body {
+    set user_options {vara varb}
+    handle_option-delete user_options varb
+    if {[lsearch $user_options varb] > 0} {return "FAIL: var not deleted"}
+    if {[lsearch $user_options vara] < 0} {return "FAIL: var not found"}
+    return "Handle_option-delete successful."
+} -result "Handle_option-delete successful."
+
+
+test handle_option-strsed {
+    Handle_option strsed unit test.
+} -body {
+	unset user_options
+    array set user_options { opt options }
+    if {[handle_option-strsed opt b] != ""} {return "FAIL: invalid result"}
+	return "Handle_option-strsed successful."
+} -result "Handle_option-strsed successful."
+
+
+# test handle_option-replace # deprecated
+
+
+test options {
+    Options unit test.
+} -body {
+    options date
+    if {[date macports] != "macports"} {return "FAIL: incorect options"}
+    return "Options successful."
+} -result "Options successful."
+
+
+# test options::export #
+# test options_export #
+# test handle_deprecated_option #
+# test get_deprecated_options #
+# test option_deprecate
+# test option_proc
+# test option_proc_trace #
+# test commands
+# test command_string #
+# test command_exec #
+# test default
+# test default_check #
+# test handle_option_string
+# test variant
+# test variant_isset
+# test variant_set
+# test variant_remove_ditem #
+# test variant_exists
+# test load_variant_desc_file
+# test variant_desc
+# test platform
+# test subport
+
+# test parse_environment #
+# test append_to_environment_value #
+# test append_list_to_environment_value #
+# test environment_array_to_string #
+
+
+test getdisttag {
+    Get dist tag unit test.
+} -body {
+    set tag [getdisttag distfile.tar.gz:tag1]
+    if {$tag != "tag1"} {return "FAIL: invalid tag detected"}
+    set tag [getdisttag distfile.tar.gz:tag1:tag2]
+    if {$tag != "tag2"} {return "FAIL: invalid last tag"}
+    set tag [getdisttag distfile.tar.gz]
+    if {$tag != ""} {return "FAIL: detected unexistent tag"}
+    return "Getdisttag successful."
+} -result "Getdisttag successful."
+
+
+test getdistname {
+    Get dist tag unit test.
+} -body {
+    set tag [getdistname distfile.tar.gz:tag1]
+    if {$tag != "distfile.tar.gz"} {return "FAIL: invalid name detected"}
+    set tag [getdistname distfile.gz::tag1]
+    if {$tag != "distfile.gz:"} {return "FAIL: invalid name"}
+    return "Getdistname successful."
+} -result "Getdistname successful."
+
+
+test tbool {
+    Tbool unit test. Check if variable is in calling namespace.
+} -setup {
+    set vara "yes"
+    set varb no
+} -body {
+    if {[tbool vara] == 0} { return "FAIL: var not true" }
+    if {[tbool varb] != 0} { return "FAIL: var not false" }
+    if {[tbool var] != 0} { return "FAIL: var should not be here" }
+    return "tbool successful."
+} -result "tbool successful."
+
+
+test ldelete {
+    Ldelete unit test. Remove one value from list.
+} -setup {
+    set list {a b a}
+    set empty {}
+} -body {
+    if {[ldelete $list b] != {a a}} { return "FAIL: element not deleted" }
+    if {[ldelete $list a] != {b a}} { return "FAIL: first element not removed" }
+    if {[ldelete $empty a] != {}} { return "FAIL: list was empty" }
+    return "ldelete successful."
+} -result "ldelete successful."
+
+
+test reinplace {
+    Reinplace  unit test. "Sed in place" functionality.
+} -setup {
+    global macportsuser
+    set macportsuser macports
+
+    set root "/tmp/macports-portutil-reinplace"
+    file delete -force $root
+
+    set workpath $root
+    set worksrcpath $root
+    set file $root/file
+    source ../port_autoconf.tcl
+
+    file mkdir $root
+    set fs [open $file w+]
+    puts $fs "Macports reinplace unit test?"
+    close $fs
+
+    set second $root/dir
+    file mkdir $second
+    file copy -force $root/file $second/file
+
+} -body {
+    reinplace s/Macports/MacPorts/1 $file
+    catch {set f [open $file r]}
+    set cont [read -nonewline $f]
+    if { $cont != "MacPorts reinplace unit test?" } {
+		return "FAIL: reinplace no args."
+    }
+    close $f
+
+    reinplace -E s/test?/testing/1 $file
+    catch {set f [open $file r]}
+    set cont [read -nonewline $f]
+    if { $cont != "MacPorts reinplace unit testing?" } {
+		return "FAIL: reinplace (-E) extended regex."
+    }
+    close $f
+
+    reinplace -W $second s/Macports/MP/1 file
+    catch {set f [open $second/file r]}
+    set cont [read -nonewline $f]
+    if { $cont != "MP reinplace unit test?" } {
+		return "FAIL: reinplace (-W) relative path."
+    }
+    close $f
+
+    reinplace -n s/unit/testing/1 $file
+    catch {set f [open $file r]}
+    set cont [read -nonewline $f]
+    if { $cont != "" } {
+		return "FAIL: reinplace (-n) suppress output."
+    }
+    close $f
+
+    return "Reinplace successful."
+
+} -cleanup {
+    file delete -force $root
+} -result "Reinplace successful."
+
+
+test delete {
+    Delete unit test.
+} -setup {
+    set root "/tmp/macports-portutil-delete"
+    file delete -force $root
+
+    try {
+        mtree $root {
+            a               directory
+            a/a             file
+            a/b             file
+            a/c             directory
+            a/c/a           file
+            a/c/b           {link ../b}
+            a/c/c           {link ../../b}
+            a/c/d           directory
+            a/c/d/a         file
+            a/c/d/b         directory
+            a/c/d/c         file
+            a/d             file
+            b               directory
+            b/a             file
+            b/b             {link q}
+            b/c             directory
+            b/c/a           file
+            b/c/b           file
+            b/d             file
+        }
+    }
+
+} -body {
+    delete $root/a/c/b
+    if {[file exists $root/a/c/b] || ![file exists $root/a/b]} {
+        return "FAIL: delete with single args."
+    }
+
+    delete $root/a $root/b
+    if {[file exists $root/a] || [file exists $root/b]} {
+        return "FAIL: delete with multiple args.""
+    }
+    return "Files deleted."
+
+} -cleanup {
+    file delete -force $root
+} -result "Files deleted."
+
+
+test touch {
+    Touch unit test.
+} -setup {
+    set root "/tmp/macports-portutil-touch"
+    file delete -force $root
+} -body {
+    touch -c $root
+    if {[file exists $root]} { return "FAIL: touch unsuccessful" }
+
+    touch $root
+    if {![file exists $root]} { return "FAIL: touch unsuccessful" }
+    return "Files successfully touched."
+
+} -cleanup {
+    file delete -force $root
+} -result "Files successfully touched."
+
+
+test ln {
+    ln unit test.
+} -setup {
+    set oldpwd [pwd]
+    set root "/tmp/macports-portutil-ln"
+    file delete -force $root
+    file mkdir $root
+} -body {
+    close [open $root/a w]
+    ln -s a $root/b
+    if {[catch {file type $root/b}]} { return "FAIL: symlink not created." }
+    if {[file type $root/b] ne "link"} { return "FAIL: expected link." }
+
+    close [open $root/c w]
+    if {![catch {ln -s c $root/b}]} { return "FAIL: ln not created." }
+
+    ln -s -f c $root/b
+    if {[catch {file type $root/b}] || [file type $root/b] ne "link"} {
+        return "FAIL: ln failed."
+    }
+    file delete $root/b
+
+    ln $root/a $root/b
+    if {[catch {file type $root/b}] || [file type $root/b] ne "file"} {
+         return "FAIL: ln failed."
+     }
+    file delete $root/b
+
+    file mkdir $root/dir
+    ln -s dir $root/b
+    ln -s a $root/b
+    if {[catch {file type $root/dir/a}] || [file type $root/dir/a] ne "link"} {
+		return "FAIL: directory ln failed."
+    }
+    file delete $root/dir/a
+
+    ln -s -f -h a $root/b
+    if {[catch {file type $root/b}] || [file type $root/b] ne "link" || [file readlink $root/b] ne "a"} {
+		return "FAIL: readlink error."
+    }
+
+    cd $root/dir
+    ln -s ../c
+    if {[catch {file type $root/dir/c}] || [file type $root/dir/c] ne "link"} {
+		return "FAIL: ln failed."
+    }
+
+    ln -s foobar $root/d
+    if {[catch {file type $root/d}] || [file type $root/d] ne "link" || [file readlink $root/d] ne "foobar"} {
+		return "FAIL: readlink error."
+    }
+
+    ln -s -f -h z $root/dir
+    if {[catch {file type $root/dir/z}] || [file type $root/dir/z] ne "link"} {
+		return "FAIL: ln failed."
+    }
+
+    ln -sf q $root/dir
+    if {[catch {file type $root/dir/q}] || [file type $root/dir/q] ne "link"} {
+		return "FAIL: error combined ln flags."
+    }
+    return "Files successfully linked."
+
+} -cleanup {
+    cd $oldpwd
+    file delete -force $root
+} -result "Files successfully linked."
+
+test makeuserproc {
+    Make user proc unit test.
+} -setup {
+    global MP
+    set MP macports
+} -body {
+    makeuserproc test-proc "\{ if \{ \$MP == \"macports\" \} \{return \"works\"\} \}"
+    set res [test-proc]
+    if { $res != "works" } { return "FAIL: global var not set in proc" }
+    return "Make user proc successful."
+
+} -result "Make user proc successful."
+
+
+# test backup -
+# test lipo -
+
+
+test unobscure_maintainers {
+    Unobscure maintainers unit test.
+} -body {
+    set list { port }
+    if { [unobscure_maintainers $list] != "port at macports.org" } {
+		return "FAIL: invalid maintainer name"
+    }
+    set list { google.com:port }
+    if { [unobscure_maintainers $list] != "port at google.com" } {
+		return "FAIL: invalid maintainer name"
+    }
+
+    set list { port at google.com }
+    if { [unobscure_maintainers $list] != "port at google.com" } {
+		return "FAIL: invalid maintainer name"
+    }
+    return "unobscure_maintainers successful."
+} -result "unobscure_maintainers successful."
+
+
+# test target_run
+# test recursive_collect_deps
+
+
+test eval_targets {
+    Evaluate targets unit test.
+} -setup {
+    init_eval_targets
+	set patchfiles {file.diff}
+
+	file mkdir $filespath
+    set fd [open $filespath/file.diff w+]
+    puts $fd "first line should get to the workpath"
+    close $fd
+
+    # sets up PortInfo array
+    if {[eval_variants variations] != 0} {
+		mportclose $mport
+		error "Error evaluating variants"
+    }
+
+    set epoch $PortInfo(epoch)
+    set revision $PortInfo(revision)
+
+    # messy work just to get $version
+    set workername [ditem_key $mport workername]
+
+} -body {
+    if {[$workername eval catch {eval_targets macport}] != 1} {
+		return "FAIL: invalid target detected"
+    }
+    if {[$workername eval eval_targets checksum] != 0} {
+		return "FAIL: valid target not detected"
+    }
+    return "Eval_targets successful."
+
+} -cleanup {
+    mportclose $mport
+    file delete -force $filespath
+    file delete -force work
+
+} -result "Eval_targets successful."
+
+
+test get_statefile_value {
+    Get statefile value unit test.
+    Depends on line in statefile "target: org.macports.fetch".
+} -body {
+    set fd [open $pwd/statefile r]
+
+    set res [catch {get_statefile_value target $fd result}]
+    if {$res != 0 || $result != "org.macports.fetch"} {
+		return "FAIL: invalid value"
+    }
+    return "Get statefile value successful."
+} -result "Get statefile value successful."
+
+
+test check_statefile {
+    Check statefile unit test.
+} -body {
+    set fd [open $pwd/statefile r]
+    set res [check_statefile target org.macports.patch $fd]
+    if {$res != 1} {return "FAIL: target not found"}
+
+    set res [check_statefile target org.macports.port $fd]
+    if {$res != 0} {return "FAIL: invalid target found"}
+    close $fd
+    return "Check_statefile successful."
+} -result "Check_statefile successful."
+
+
+test write_statefile {
+    Write statefile unit test.
+} -body {
+    set fd [open $pwd/test.statefile w+]
+    write_statefile variant universal $fd
+    set res [check_statefile variant universal $fd]
+    if {$res != 1} {return "FAIL: variant not set"}
+    close $fd
+    return "Write_statefile successful."
+
+} -cleanup {
+    file delete -force $pwd/test.statefile
+} -result "Write_statefile successful."
+
+
+test check_statefile_variants {
+    Check statefile unit test.
+} -setup {
+    array set variations {
+	target org.macports.fetch
+	target org.macports.checksum
+    }
+    array set oldvariations {
+	target org.macports.fetch
+	target org.macports.checksum
+    }
+    array set oldvariations_fail {
+	target org.macports.patch
+    }
+    set fd [open $pwd/statefile r]
+
+} -body {
+    set res [check_statefile_variants variations oldvariations $fd]
+    if {$res != 0} {return "FAIL: invalid variant"}
+    set res [check_statefile_variants variations oldvariations_fail $fd]
+    if {$res != 1} {return "FAIL: invalid variant"}
+    close $fd
+    return "Check statefile successful."
+
+} -result "Check statefile successful."
+
+
+test choose_variants {
+    Choose variants unit test.
+} -setup {
+    init_eval_targets
+    array set variations { fondu + }
+    array set variations_neg { fondu - }
+    array set variations_not { fondu a }
+
+} -body {
+    set res [choose_variants $mport variations]
+    if {[lindex $res 1] != "" && [lindex $res 0] != "ditem_1"} {
+		return "FAIL: invalid variations"
+    }
+    set res [choose_variants $mport variations_neg]
+    if {[lindex $res 0] != "" && [lindex $res 1] != "ditem_1"} {
+		return "FAIL: invalid variations"
+    }
+    set res [choose_variants $mport variations_not]
+    if {[lindex $res 0] != "" && [lindex $res 1] != ""} {
+		return "FAIL: invalid variations"
+    }
+    return "Choose variant successful."
+} -result "Choose variant successful."
+
+
+test variant_run {
+    Variant run unit test. Executes proc with same name as variant.
+} -setup {
+	proc variant-var {} { set var test }
+    set ditem [variant_new var]
+    set name [ditem_key $ditem name]
+
+} -body {
+    if {[catch {variant_run $ditem}] != 0} {
+		return "FAIL: unable to run variant name proc"
+    }
+    return "Variant run successful."
+} -cleanup {
+    mportclose $mport
+    file delete -force work
+} -result "Variant run successful."
+
+
+test canonicalize_variants {
+    Canonicalize_variants unit test.
+} -body {
+    set arr {c + b - d +}
+    if {[canonicalize_variants $arr +] != "+c+d"} {
+		return "FAIL: incorrect string"
+    }
+    if {[canonicalize_variants $arr -] != "-b"} {
+		return "FAIL: incorrect string"
+    }
+    return "Canonicalize variants successful."
+} -result "Canonicalize variants successful."
+
+
+# test eval_variants
+# test check_variants
+
+
+test universal_setup {
+    Universal setup unit test.
+} -body {
+    set use_configure 0
+    set ditem [variant_new new-variant]
+
+    if {[catch {universal_setup}] != 0} {
+		return "FAIL: universal variant not set"
+    }
+    return "Universal_setup successful."
+} -result "Universal_setup successful."
+
+
+# Covered by eval_targets.
+# test target_new #
+# test target_provides #
+# test target_requires #
+# test target_uses #
+# test target_deplist #
+# test target_prerun #
+# test target_postrun #
+# test target_runtype #
+# test target_state #
+# test target_init #
+
+
+test variant_new {
+    Variant new unit test.
+} -body {
+    set ditem [variant_new new-variant]
+    if {[ditem_key $ditem name] != "new-variant"} {
+		return "FAIL: error building new variant"
+    }
+    return "Variant new successful."
+} -result "Variant new successful."
+
+
+test handle_default_variants {
+    Handle default variants unit test.
+} -body {
+    array set variations {
+		target.run org.macports.checksum
+    }
+
+    set res [handle_default_variants target set {+org -org2}]
+
+    if {[lindex $PortInfo(vinfo) 0] != "org" || [lindex $PortInfo(vinfo) 1] != "is_default +"} {
+		return "FAIL: default variant not set"
+    }
+    if {[lindex $PortInfo(vinfo) 2] != "org2" || [lindex $PortInfo(vinfo) 3] != "is_default -"} {
+		return "FAIL: nondefault variant not set"
+    }
+
+    return "Handle default variant successful."
+} -result "Handle default variant successful."
+
+
+# test handle_add_users #
+# test adduser #
+# test addgroup #
+
+
+test dirSize {
+    Directory size unit test.
+    This test is dependent on the statefile in the tests dir.
+    Expected file size is 155.
+} -body {
+    global pwd
+    file mkdir $pwd/test.dir
+    file copy -force $pwd/statefile $pwd/test.dir
+    if {[dirSize $pwd/test.dir] != 155} {
+		return "FAIL: wrong dir size"
+    }
+    return "Directory size calculated successfully."
+
+} -cleanup {
+    file delete -force $pwd/test.dir
+} -result "Directory size calculated successfully."
+
+
+test set_ui_prefix {
+    Set_ui unit test. Assumes default: "---> ".
+} -body {
+    set env(UI_PREFIX) MacPorts
+    set_ui_prefix
+    if {$UI_PREFIX != "MacPorts"} {return "FAIL: incorrect prefix"}
+    unset env(UI_PREFIX)
+    set_ui_prefix
+    if {$UI_PREFIX != "---> "} {return "FAIL; default prefix not set"}
+    return "Set_ui_prefix successful."
+} -result "Set_ui_prefix successful."
+
+
+# test PortGroup
+
+
+test get_portimage_name {
+    Get portimage name unit test.
+} -body {
+	set os.platform darwin
+    set version 1.0
+    set os.major 10
+	set revision 2
+    set configure.build_arch no
+    set portarchivetype tgz
+    set subport testport
+	set portvariants {var1}
+	set supported_archs {}
+
+    set res [get_portimage_name]
+    if {$res != "testport-1.0_2var1.darwin_10.no.tgz"} {
+		return "FAIL: invalid portimage_name"
+    }
+    return "Get portimage_name successful."
+} -result "Get portimage_name successful."
+
+
+test get_portimage_path {
+    Get portimage path unit test. Calls get_portimage_name.
+} -body {
+	set os.platform darwin
+    set portdbpath dbpath
+    set subport subport
+	set revision 2
+	set portvariants {var1}
+	set supported_archs {}
+
+    set res [get_portimage_path]
+    if {$res != "dbpath/software/subport/subport-1.0_2var1.darwin_10.no.tgz"} {
+		return "FAIL: invalid portimage_path"
+    }
+    return "Get portimage_path successful."
+} -result "Get portimage_path successful."
+
+
+test supportedArchiveTypes {
+    Supported archive types unit test.
+    Only tests xar, zip, cpio.
+} -body {
+    set archives [supportedArchiveTypes]
+
+    foreach archive $archives {
+		if {$archive == "xar" && ![file exists ${portutil::autoconf::xar_path}]} {
+	    	return "FAIL: xar detected but inexistent"
+		}
+		if {$archive == "zip" && ![file exists ${portutil::autoconf::zip_path}]} {
+	    	return "FAIL: zip detected but inexistent"
+		}
+		if {$archive == "cpio" && ![file exists ${portutil::autoconf::cpio_path}]} {
+	    	return "FAIL: cpio detected but inexistent"
+		}
+    }
+    return "Supported archives successful."
+} -result "Supported archives successful."
+
+
+# test find_portarchie_path
+# test archiveTypeIsSupported
+# test extract_archive_metadata
+
+# test merge_lipo
+# test merge_cpp
+# test merge_file
+# test merge
+# test quotemeta
+# test chown
+# test chownAsRoot
+# test fileAttrsAsRoot
+# test elevateToRoot
+# test dropPrivileges
+# test validate_macportsuser
+
+# test _libtest
+# test _bintest
+# test _pathtest
+# test _get_dep_port
+# test get_canonical_archs
+# test get_canonical_archflags
+# test check_supported_archs
+
+
+# test _check_xcode_version
+# test _archive_available
+
+
+cleanupTests

Copied: trunk/base/src/port1.0/tests/statefile (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/statefile)
===================================================================
--- trunk/base/src/port1.0/tests/statefile	                        (rev 0)
+++ trunk/base/src/port1.0/tests/statefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,6 @@
+version: 3
+target: org.macports.fetch
+target: org.macports.checksum
+target: org.macports.extract
+target: org.macports.patch
+target: org.macports.configure

Copied: trunk/base/src/port1.0/tests/test.tcl (from rev 111324, branches/gsoc13-tests/src/port1.0/tests/test.tcl)
===================================================================
--- trunk/base/src/port1.0/tests/test.tcl	                        (rev 0)
+++ trunk/base/src/port1.0/tests/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,131 @@
+# Global vars
+set arguments ""
+set test_name ""
+set color_out ""
+set tcl ""
+set err ""
+
+# Get tclsh path.
+set autoconf ../../Mk/macports.autoconf.mk
+set fp [open $autoconf r]
+while {[gets $fp line] != -1} {
+    if {[string match "TCLSH*" $line] != 0} {
+        set tcl [lrange [split $line " "] 1 1]
+    }
+}
+
+proc print_help {arg} {
+    if { $arg == "tests" } {
+        puts "The list of available tests is:"
+	cd tests
+	set test_suite [glob *.test]
+        foreach test $test_suite {
+            puts [puts -nonewline "  "]$test
+        }
+    } else {
+        puts "Usage: tclsh test.tcl \[-debug level\] \[-t test\] \[-l\]\n"
+        puts "  -debug LVL : sets the level of printed debug info \[0-3\]"
+        puts "  -t TEST    : run a specific test"
+        puts "  -nocolor   : disable color output (for automatic testing)"
+        puts "  -l         : print the list of available tests"
+        puts "  -h, -help  : print this message\n"
+    }
+}
+
+# Process args
+foreach arg $argv {
+    if { $arg == "-h" || $arg == "-help" } {
+        print_help ""
+        exit 0
+    } elseif { $arg == "-debug" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set level [lindex $argv $index]
+        if { $level >= 0 && $level <= 3 } {
+            append arguments "-debug " $level
+        } else {
+            puts "Invalid debug level."
+            exit 1
+        }
+    } elseif { $arg == "-t" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set test_name [lindex $argv $index]
+        set no 0
+	cd tests
+	set test_suite [glob *.test]
+        foreach test $test_suite {
+            if { $test_name != $test } {
+                set no [expr $no + 1]
+            }
+        }
+        if { $no == [llength $test_suite] } {
+            print_help tests
+            exit 1
+        }
+    } elseif { $arg == "-l" } {
+        print_help tests
+        exit 0
+    } elseif { $arg == "-nocolor" } {
+        set color_out "no"
+    }
+}
+
+
+# Run tests
+if { $test_name != ""} {
+    set result [eval exec -ignorestderr $tcl $test_name $arguments]
+    puts $result
+
+} else {
+    cd tests
+    set test_suite [glob *.test]
+
+    foreach test $test_suite {
+        set result [eval exec -ignorestderr $tcl $test $arguments]
+	set lastline [lindex [split $result "\n"] end]
+
+	if {[lrange [split $lastline "\t"] 1 1] != "Total"} {
+	    set lastline [lindex [split $result "\n"] end-2]
+	    set errmsg [lindex [split $result "\n"] end]
+	}
+
+	set splitresult [split $lastline "\t"]
+        set total [lindex $splitresult 2]
+        set pass [lindex $splitresult 4]
+        set skip [lindex $splitresult 6]
+        set fail [lindex $splitresult 8]
+
+	# Format output
+	if {$total < 10} { set total "0${total}"}
+	if {$pass < 10} { set pass "0${pass}"}
+	if {$skip < 10} { set skip "0${skip}"}
+	if {$fail < 10} { set fail "0${fail}"}
+
+        # Check for errors.
+        if { $fail != 0 } { set err "yes" }
+
+        set out ""
+        if { ($fail != 0 || $skip != 0) && $color_out == "" } {
+            # Color failed tests.
+            append out "\x1b\[1;31mTotal:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  \x1b\[0m" $test
+        } else {
+            append out "Total:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  " $test
+        }
+
+        # Print results and constrints for auto-skipped tests.
+        puts $out
+        if { $skip != 0 } {
+            set out "    Constraint: "
+            append out [string trim $errmsg "\t {}"]
+            puts $out
+        }
+	if { $fail != 0 } {
+	    set end [expr [string first $test $result 0] - 1]
+	    puts [string range $result 0 $end]
+	}
+    }
+}
+
+# Return 1 if errors were found.
+if {$err != ""} { exit 1 }
+
+return 0


Property changes on: trunk/base/src/registry2.0/receipt_sqlite.tcl
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/src/registry1.0/receipt_sqlite.tcl:37343-46937
/branches/gsoc09-logging/base/src/registry1.0/receipt_sqlite.tcl:51231-60371
/branches/gsoc11-rev-upgrade/base/src/registry2.0/receipt_sqlite.tcl:78828-88375
/branches/universal-sanity/base/src/registry1.0/receipt_sqlite.tcl:51872-52323
/branches/variant-descs-14482/base/src/registry1.0/receipt_sqlite.tcl:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/registry1.0/receipt_sqlite.tcl:45682-46060
/users/perry/base-select/src/registry1.0/receipt_sqlite.tcl:44044-44692
   + /branches/gsoc08-privileges/base/src/registry1.0/receipt_sqlite.tcl:37343-46937
/branches/gsoc09-logging/base/src/registry1.0/receipt_sqlite.tcl:51231-60371
/branches/gsoc11-rev-upgrade/base/src/registry2.0/receipt_sqlite.tcl:78828-88375
/branches/gsoc13-tests/src/registry2.0/receipt_sqlite.tcl:106692-111324
/branches/universal-sanity/base/src/registry1.0/receipt_sqlite.tcl:51872-52323
/branches/variant-descs-14482/base/src/registry1.0/receipt_sqlite.tcl:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/users/perry/base-bugs_and_notes/src/registry1.0/receipt_sqlite.tcl:45682-46060
/users/perry/base-select/src/registry1.0/receipt_sqlite.tcl:44044-44692

Modified: trunk/base/src/registry2.0/tests/entry.tcl
===================================================================
--- trunk/base/src/registry2.0/tests/entry.tcl	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/src/registry2.0/tests/entry.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -7,11 +7,12 @@
     load $pextlibname
 
     # totally lame that file delete won't do it
-	eval exec rm -f [glob -nocomplain test.db*]
+    eval exec rm -f [glob -nocomplain test.db*]
 
     # can't create registry in some brain-dead place or in protected place
     test_throws {registry::open /some/brain/dead/place} registry::cannot-init
-    test_throws {registry::open /etc/macports_test_prot~} registry::cannot-init
+    # This would actually work when testing with sudo :(
+    #test_throws {registry::open /etc/macports_test_prot~} registry::cannot-init
 
     # can't use registry before it's opened
     test_throws {registry::write {}} registry::misuse

Deleted: trunk/base/tests/Makefile
===================================================================
--- trunk/base/tests/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,86 +0,0 @@
-include ../Mk/macports.autoconf.mk
-
-TESTS?=checksums-1 svn-and-patchsites envvariables site-tags trace universal universal-2 xcodeversion dependencies-c dependencies-d dependencies-e case-insensitive-deactivate variants statefile-version1 statefile-version1-outdated statefile-version2 statefile-version2-outdated statefile-version2-invalid statefile-unknown-version
-
-PWD=$(shell pwd)
-
-.PHONY: all clean install test PortIndex
-
-all::
-
-/tmp/macports-tests/opt/local/etc/macports/sources.conf: sources.conf
-	@echo setting up test installation
-	rm -rf /tmp/macports-tests/
-	mkdir -p /tmp/macports-tests/ports
-	mkdir -p /tmp/macports-tests/opt/local/etc/macports/
-	mkdir -p /tmp/macports-tests/opt/local/share/
-	mkdir -p /tmp/macports-tests/opt/local/var/macports/receipts/
-	mkdir -p /tmp/macports-tests/opt/local/var/macports/registry/
-	mkdir -p /tmp/macports-tests/opt/local/var/macports/build/
-	ln -s $(datadir)/macports /tmp/macports-tests/opt/local/share/
-	ln -s $(PWD)/test /tmp/macports-tests/ports/
-	cp sources.conf /tmp/macports-tests/opt/local/etc/macports/
-
-/tmp/macports-tests/ports/PortIndex: /tmp/macports-tests/opt/local/etc/macports/sources.conf PortIndex
-	cp PortIndex PortIndex.quick /tmp/macports-tests/ports/
-
-PortIndex:
-	$(bindir)/portindex
-
-clean::
-	rm -rf /tmp/macports-tests/
-	rm -f PortIndex PortIndex.quick
-	for testname in $(TESTS); do \
-		rm -f test/$$testname/{output,output.sed,difference,work}; \
-	done
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running these tests"
-	@exit 1
-
-# Run all tests
-# Use TESTS to choose which tests to run
-# For example: make test TESTS="checkums-1 universal"
-test:: clean /tmp/macports-tests/ports/PortIndex /tmp/macports-tests/opt/local/etc/macports/sources.conf
-	@num=0; \
-	success=0; \
-	for testname in $(TESTS); do\
-		subdir=test/$$testname; \
-		echo ===\> test ${DIRPRFX}$$subdir; \
-		if [ -e $$subdir/Makefile ]; then \
-			( cd $$subdir && \
-				$(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ PORTSRC=$(PWD)/test-macports.conf test) && \
-			success=$$(( success + 1 )); \
-		else \
-			( cd $$subdir && \
-				PORTSRC=$(PWD)/test-macports.conf $(bindir)/port clean > /dev/null && \
-				PORTSRC=$(PWD)/test-macports.conf $(bindir)/port test > output 2>&1 \
-					|| ([ -e error_expected ] || (cat output; exit 1)) && \
-			sed -e "s|${PWD}|PWD|g" < output > output.sed && \
-			diff -u master output.sed 2>&1 | tee difference && \
-			if [ -s difference ]; then \
-				exit 1; \
-			else \
-				rm -f difference output.sed; \
-			fi) && \
-			success=$$(( success + 1 )); \
-			if [ -n "`PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -q echo installed`" ]; then \
-			    PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -f clean --all installed > /dev/null && \
-			    PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -f uninstall installed > /dev/null; \
-			fi; \
-		fi; \
-		num=$$(( num + 1 )); \
-	done; \
-	echo ===\> $$success of $$num tests passed.
-	@rm -rf /tmp/macports-tests/
-	@rm -f PortIndex PortIndex.quick
-
-# Run specific test
-# Prepend the directory name with "test-" and use it as target
-# For example: make test-checksums-1
-test-%:
-	$(MAKE) TESTS="$(@:test-%=%)" test
-
-install::
-
-distclean:: clean

Copied: trunk/base/tests/Makefile (from rev 111324, branches/gsoc13-tests/tests/Makefile)
===================================================================
--- trunk/base/tests/Makefile	                        (rev 0)
+++ trunk/base/tests/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,12 @@
+include ../Mk/macports.autoconf.mk
+
+all:: ../Mk/macports.autoconf.mk
+
+install::
+
+# Run all regression tests
+# tclsh test.tcl -h for more options.
+test::
+	$(TCLSH) test.tcl -nocolor
+
+clean::

Copied: trunk/base/tests/test/case-insensitive-deactivate/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/case-insensitive-deactivate/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/case-insensitive-deactivate/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/case-insensitive-deactivate/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,10 @@
+This test checks for case-insensitive port names. From Portfile.in it
+generates a Portfile which is installed with a lowercase name (casesensitive)
+and uninstalled with a CamelCase name (CaseSensitivE). The install/uninstall
+is verified by the existance/absence of the '/tmp/macports-tests/opt/local/var/test/case'
+file.
+
+There are 2 test cases. One to install a port and the other to uninstall.
+
+See ticket #11759,
+https://trac.macports.org/ticket/11759

Deleted: trunk/base/tests/test/case-insensitive-deactivate/Makefile
===================================================================
--- trunk/base/tests/test/case-insensitive-deactivate/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/case-insensitive-deactivate/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,31 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-# see test-macports.conf for the value of prefix
-TESTFILE=/tmp/macports-tests/opt/local/var/test/case
-TESTPORT1=casesensitive
-TESTPORT2=CaseSensitivE
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@echo port install $(TESTPORT1)
-	@sed 's/@name@/$(TESTPORT1)/' Portfile.in > Portfile
-	@PORTSRC=$(PORTSRC) $(bindir)/port install > output 2>&1 || (cat output; exit 1)
-	@if [ ! -f $(TESTFILE) ]; then \
-		echo "FAILED: File should exist after install: $(TESTFILE)" && exit 1; \
-	fi
-	@echo port uninstall $(TESTPORT2)
-	@sed 's/@name@/$(TESTPORT2)/' Portfile.in > Portfile
-	@PORTSRC=$(PORTSRC) $(bindir)/port uninstall > output 2>&1 || (cat output; exit 1)
-	@if [ -f $(TESTFILE) ]; then \
-		rm $(TESTFILE); \
-		echo "FAILED: File should NOT exist after uninstall: $(TESTFILE)" && exit 1; \
-	else \
-		echo "SUCCESS!"; \
-	fi
-	rm Portfile
-	rm output

Copied: trunk/base/tests/test/case-insensitive-deactivate/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/case-insensitive-deactivate/test.tcl)
===================================================================
--- trunk/base/tests/test/case-insensitive-deactivate/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/case-insensitive-deactivate/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,65 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" "Portfile"
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+set testfile "/tmp/macports-tests/opt/local/var/test/case"
+set testport1 "casesensitive"
+set testport2 "CaseSensitivE"
+
+load_variables $path
+set_dir
+port_index
+
+proc test_exists {} {
+    global path
+    global testfile
+    global testport1
+
+    exec sed "s/@name@/$testport1/" $path/Portfile.in > Portfile
+    port_install
+
+    if {[file exists $testfile]} {
+        return "Port installed."
+    } else {
+        return "File missing."
+    }
+}
+
+proc test_not_exists {} {
+    global path
+    global testfile
+    global testport2
+
+    exec sed "s/@name@/$testport2/" $path/Portfile.in > Portfile
+    port_uninstall
+
+    if {[file exists $testfile]} {
+        return "File still exists."
+    } else {
+        return "Port uninstalled."
+    }
+}
+
+
+# Test cases.
+test file_installed {
+    Regression test for file installed correctly.
+} -body {
+    test_exists
+} -result "Port installed."
+
+test file_uninstalled {
+    Regression test for file uninstalled correctly.
+} -body {
+    test_not_exists
+} -result "Port uninstalled."
+
+
+cleanup
+cleanupTests
\ No newline at end of file

Copied: trunk/base/tests/test/checksums-1/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/checksums-1/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/checksums-1/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/checksums-1/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,7 @@
+This test evaluates the checksum values of an empty file against the expected
+ones. These are taken from the output of the 'port -d test' command, by
+searching a line that beging with the string "debug: calculated".
+
+There are 3 test cases, one for each checksum used. The port command must
+return the calculated checksums in debug mode, with the form: "DEBUG:
+Calculated (_checksum-name_) " for the test to work.

Modified: trunk/base/tests/test/checksums-1/Portfile
===================================================================
--- trunk/base/tests/test/checksums-1/Portfile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/checksums-1/Portfile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -32,4 +32,4 @@
 
 test {
 	# test is actually running checksum target
-}
\ No newline at end of file
+}

Deleted: trunk/base/tests/test/checksums-1/master
===================================================================
--- trunk/base/tests/test/checksums-1/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/checksums-1/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,6 +0,0 @@
---->  Fetching distfiles for checksum
---->  Verifying checksums for checksum
---->  Extracting checksum
---->  Configuring checksum
---->  Building checksum
---->  Testing checksum

Copied: trunk/base/tests/test/checksums-1/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/checksums-1/test.tcl)
===================================================================
--- trunk/base/tests/test/checksums-1/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/checksums-1/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,47 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+initial_setup
+
+proc get_checksum {type} {
+    global path
+    global output_file
+
+    append string "debug: calculated (" $type ")*"
+    set line [get_line $path/$output_file $string]
+    set result [lrange [split $line " "] 4 4]
+
+    return $result
+}
+
+
+# Test cases
+test md5_checksum {
+    Regression test for MD5 Checksum.
+} -body {
+    get_checksum md5
+} -result "d41d8cd98f00b204e9800998ecf8427e"
+
+
+test sha1_checksum {
+    Regression test for SHA1 Checksum.
+} -body {
+    get_checksum sha1
+} -result "da39a3ee5e6b4b0d3255bfef95601890afd80709"
+
+
+test rmd160_checksum {
+    Regression test for RMD160 Checksum.
+} -body {
+    get_checksum rmd160
+} -result "9c1185a5c5e9fc54612808977ee8f548b2258d31"
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/dependencies-a/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-a/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/dependencies-a/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/dependencies-a/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test makes sure a dependency added in a variant block
+(this is selected as default variant) is considered.
+
+There is 1 test case.

Copied: trunk/base/tests/test/dependencies-a/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-a/test.tcl)
===================================================================
--- trunk/base/tests/test/dependencies-a/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/dependencies-a/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,28 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+proc dep-a {} {
+    global path
+    global output_file
+
+    initial_setup
+
+    set err "error*"
+    set line [get_line $output_file $err]
+    return $line
+}
+
+test dependencies-a {
+    Regression test for dependencies-a.
+} -body {
+    dep-a
+} -result -1
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/dependencies-b/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-b/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/dependencies-b/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/dependencies-b/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test does nothing. (or: ensures a port without dependencies really
+doesn't have any)
+
+There is 1 test case.

Copied: trunk/base/tests/test/dependencies-b/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-b/test.tcl)
===================================================================
--- trunk/base/tests/test/dependencies-b/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/dependencies-b/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,29 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+proc dep-b {} {
+    global path
+    global output_file
+
+    initial_setup
+
+    set err "error*"
+    set line [get_line $output_file $err]
+    return $line
+}
+
+test dependencies-b {
+    Regression test for dependencies-b.
+} -body {
+    dep-b
+} -result -1
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/dependencies-c/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-c/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/dependencies-c/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/dependencies-c/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test does the same as dependencies-a, but due to the transitive
+nature of dependencies, also tests what dependencies-a has already tested.
+
+There is 1 test case.

Deleted: trunk/base/tests/test/dependencies-c/master
===================================================================
--- trunk/base/tests/test/dependencies-c/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/dependencies-c/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,26 +0,0 @@
---->  Computing dependencies for dependencies-c
---->  Dependencies to be installed: dependencies-a dependencies-b
---->  Fetching distfiles for dependencies-b
---->  Verifying checksums for dependencies-b
---->  Extracting dependencies-b
---->  Configuring dependencies-b
---->  Building dependencies-b
---->  Staging dependencies-b into destroot
---->  Installing dependencies-b @1_0
---->  Activating dependencies-b @1_0
---->  Cleaning dependencies-b
---->  Fetching distfiles for dependencies-a
---->  Verifying checksums for dependencies-a
---->  Extracting dependencies-a
---->  Configuring dependencies-a
---->  Building dependencies-a
---->  Staging dependencies-a into destroot
---->  Installing dependencies-a @1_0+i_want_b
---->  Activating dependencies-a @1_0+i_want_b
---->  Cleaning dependencies-a
---->  Fetching distfiles for dependencies-c
---->  Verifying checksums for dependencies-c
---->  Extracting dependencies-c
---->  Configuring dependencies-c
---->  Building dependencies-c
---->  Testing dependencies-c

Copied: trunk/base/tests/test/dependencies-c/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-c/test.tcl)
===================================================================
--- trunk/base/tests/test/dependencies-c/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/dependencies-c/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,29 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+proc dep-c {} {
+    global path
+    global output_file
+
+    initial_setup
+
+    set err "error*"
+    set line [get_line $output_file $err]
+    return $line
+}
+
+test dependencies-c {
+    Regression test for dependencies-c.
+} -body {
+    dep-c
+} -result -1
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/dependencies-d/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-d/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/dependencies-d/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/dependencies-d/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test checks for an invalid dependency specification. The "depends" option
+tested in this test apparently was never implemented.
+
+There is 1 test case.

Deleted: trunk/base/tests/test/dependencies-d/master
===================================================================
--- trunk/base/tests/test/dependencies-d/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/dependencies-d/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,28 +0,0 @@
-Warning: depends option is not handled yet
-Warning: depends option is not handled yet
---->  Computing dependencies for dependencies-d
---->  Dependencies to be installed: dependencies-a dependencies-b
---->  Fetching distfiles for dependencies-b
---->  Verifying checksums for dependencies-b
---->  Extracting dependencies-b
---->  Configuring dependencies-b
---->  Building dependencies-b
---->  Staging dependencies-b into destroot
---->  Installing dependencies-b @1_0
---->  Activating dependencies-b @1_0
---->  Cleaning dependencies-b
---->  Fetching distfiles for dependencies-a
---->  Verifying checksums for dependencies-a
---->  Extracting dependencies-a
---->  Configuring dependencies-a
---->  Building dependencies-a
---->  Staging dependencies-a into destroot
---->  Installing dependencies-a @1_0+i_want_b
---->  Activating dependencies-a @1_0+i_want_b
---->  Cleaning dependencies-a
---->  Fetching distfiles for dependencies-d
---->  Verifying checksums for dependencies-d
---->  Extracting dependencies-d
---->  Configuring dependencies-d
---->  Building dependencies-d
---->  Testing dependencies-d

Copied: trunk/base/tests/test/dependencies-d/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-d/test.tcl)
===================================================================
--- trunk/base/tests/test/dependencies-d/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/dependencies-d/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,29 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+proc dep-d {} {
+    global path
+    global output_file
+
+    initial_setup
+
+    set err "error*"
+    set line [get_line $output_file $err]
+    return $line
+}
+
+test dependencies-d {
+    Regression test for dependencies-d.
+} -body {
+    dep-d
+} -result -1
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/dependencies-e/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-e/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/dependencies-e/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/dependencies-e/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test checks whether unknown dependencies correctly fail. There should be
+an error saying that the requested dependencies do not exist.
+
+There is 1 test case.

Deleted: trunk/base/tests/test/dependencies-e/error_expected
===================================================================
Deleted: trunk/base/tests/test/dependencies-e/master
===================================================================
--- trunk/base/tests/test/dependencies-e/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/dependencies-e/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,5 +0,0 @@
---->  Computing dependencies for dependencies-e
-Error: Dependency 'docbook-xml-4.1.2' not found.
-To report a bug, follow the instructions in the guide:
-    http://guide.macports.org/#project.tickets
-Error: Processing of port dependencies-e failed

Copied: trunk/base/tests/test/dependencies-e/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/dependencies-e/test.tcl)
===================================================================
--- trunk/base/tests/test/dependencies-e/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/dependencies-e/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,29 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+proc dep-e {} {
+    global path
+    global output_file
+
+    initial_setup
+
+    set err "error: dependency 'docbook-xml-4.1.2' not found*"
+    set line [get_line $output_file $err]
+    return $line
+}
+
+test dependencies-e {
+    Regression test for dependencies-e.
+} -body {
+    dep-e
+} -result "error: dependency 'docbook-xml-4.1.2' not found."
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/envvariables/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/envvariables/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/envvariables/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/envvariables/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,3 @@
+This test ensures that variables set in the environment are available in the
+Portfile. The test runs an 'exec sh' command that exports two variables (ENVA
+and ENVB) and checks weather they get in the output file or not.

Deleted: trunk/base/tests/test/envvariables/Makefile
===================================================================
--- trunk/base/tests/test/envvariables/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/envvariables/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,18 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@PORTSRC=$(PORTSRC) $(bindir)/port clean > /dev/null
-	@sh -c "export ENVA=A ; export ENVB=B; \
-		export PORTSRC=$(PORTSRC); $(bindir)/port test" > output 2>&1 || (cat output; exit 1)
-	@diff -u master output 2>&1 | tee difference
-	@if [ -s difference ]; then \
-		exit 1; \
-	else \
-		rm -f difference; \
-	fi

Deleted: trunk/base/tests/test/envvariables/master
===================================================================
--- trunk/base/tests/test/envvariables/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/envvariables/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,8 +0,0 @@
---->  Fetching distfiles for envvariables
---->  Verifying checksums for envvariables
---->  Extracting envvariables
---->  Configuring envvariables
---->  Building envvariables
---->  Testing envvariables
-A
-B

Copied: trunk/base/tests/test/envvariables/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/envvariables/test.tcl)
===================================================================
--- trunk/base/tests/test/envvariables/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/envvariables/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,42 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+
+# Initial setup
+load_variables $path
+set_dir
+port_index
+port_clean $path
+
+proc envvar_test {} {
+    global output_file
+    global path
+    global portsrc
+    global bindir
+
+    # Build helping string
+    append string "export ENVA=A; export ENVB=B; "
+    append string "export PORTSRC=" $portsrc "; "
+    append string $bindir "port test"
+
+    exec sh -c $string > output
+    set line [get_line $path/$output_file "a"]
+    set line2 [get_line $path/$output_file "b"]
+    return $line$line2
+}
+
+test envvariables {
+    Regression test for Environment Variables.
+} -body {
+    envvar_test
+} -result "ab"
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/library.tcl (from rev 111324, branches/gsoc13-tests/tests/test/library.tcl)
===================================================================
--- trunk/base/tests/test/library.tcl	                        (rev 0)
+++ trunk/base/tests/test/library.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,225 @@
+set autoconf [file dirname $argv0]/../../../Mk/macports.autoconf.mk
+eval ::tcltest::configure $::argv
+
+set output_file "output"
+set work_dir "work"
+
+# Set of procs used for testing.
+
+# Sets $bindir variable from macports.autoconf.mk
+# autogenerated file.
+proc load_variables {pwd} {
+    global autoconf
+    global bindir
+    global datadir
+    global portsrc
+    global cpwd
+
+    if { [file exists $autoconf] == 0 } {
+        puts "ERROR: $autoconf does not exist."
+        exit 1
+    }
+
+    set cpwd [eval file join {*}[lrange [file split $pwd] 0 end-2]]
+
+    set line [get_line $autoconf "prefix*"]
+    set prefix [lrange [split $line " "] 1 1]
+
+    set line [get_line $autoconf "bindir*"]
+    set bin [lrange [split $line "/"] 1 1]
+
+    set bindir $prefix/$bin/
+    set datadir $prefix/share
+    set portsrc $cpwd/test-macports.conf
+
+}
+
+proc cleanup {} {
+    global cpwd
+
+    file delete -force /tmp/macports-tests/
+    file delete -force $cpwd/PortIndex $cpwd/PortIndex.quick
+}
+
+# Sets initial directories
+proc set_dir {} {
+    global datadir
+    global cpwd
+
+    cleanup
+
+    file mkdir /tmp/macports-tests/ports
+    file mkdir /tmp/macports-tests/opt/local/etc/macports/
+    file mkdir /tmp/macports-tests/opt/local/share/
+    file mkdir /tmp/macports-tests/opt/local/var/macports/receipts/
+    file mkdir /tmp/macports-tests/opt/local/var/macports/registry/
+    file mkdir /tmp/macports-tests/opt/local/var/macports/build/
+
+    file link -symbolic /tmp/macports-tests/opt/local/share/macports $datadir/macports
+    file link -symbolic /tmp/macports-tests/ports/test $cpwd/test
+}
+
+# Run portindex
+proc port_index {} {
+    global bindir
+    global datadir
+    global cpwd
+
+    # Move up 2 level to run portindex.
+    set path [pwd]
+    cd ../..
+
+    set cmd "portindex"
+
+    set result [eval exec $bindir$cmd 2>@1]
+
+    file copy $cpwd/sources.conf /tmp/macports-tests/opt/local/etc/macports/
+    file copy $cpwd/PortIndex $cpwd/PortIndex.quick /tmp/macports-tests/ports/
+
+    cd $path
+}
+
+# Executes port clean.
+proc port_clean {pwd} {
+    global bindir
+    global datadir
+    global portsrc
+
+    set back [pwd]
+    cd $pwd
+
+    set env "env PORTSRC=${portsrc}"
+    set cmd "port"
+    set args "clean"
+
+    set result [catch {eval exec $env $bindir$cmd $args 2>@1} ]
+    cd $back
+}
+
+# Runs the portfile.
+proc port_run {pwd} {
+    global bindir
+    global datadir
+    global portsrc
+
+    set back [pwd]
+    cd $pwd
+
+    set env "env PORTSRC=${portsrc}"
+    set cmd "port"
+    set args "-d test"
+    set output "output"
+
+    set result [catch {eval exec $env $bindir$cmd $args >&output} ]
+    cd $back
+    return $result
+}
+
+# Runs port trace.
+proc port_trace {pwd} {
+    global bindir
+    global datadir
+    global portsrc
+
+    set back [pwd]
+    cd $pwd
+
+    set env "env PORTSRC=${portsrc}"
+    set cmd "port"
+    set args "-t test"
+    set output "output"
+
+    set result [catch {eval exec $env $bindir$cmd $args >&output 2>@1} ]
+    cd $back
+    return $result
+}
+
+# Installs new portfile.
+proc port_install {} {
+    global bindir
+    global portsrc
+
+    set env "env PORTSRC=${portsrc}"
+    set cmd "port"
+    set args "install"
+
+    set result [catch {eval exec $env $bindir$cmd $args > output 2>@1} ]
+}
+
+# Run configure command.
+proc port_config {pwd} {
+    global path
+    global bindir
+    global portsrc
+
+    set env "env PORTSRC=${portsrc}"
+    set cmd "port"
+    set args "configure"
+
+    set result [catch {eval exec $env $bindir$cmd $args 2>@1} ]
+}
+
+# Run desroot command.
+proc port_desroot {pwd} {
+    global path
+    global bindir
+    global portsrc
+    global work_dir
+    global output_file
+
+    set env "env PORTSRC=${portsrc}"
+    set cmd "port"
+    set args "destroot"
+
+    file copy -force $path/statefile $work_dir/.macports.statefile-unknown-version.state
+    if { [exec id -u] == 0 } {
+        exec chown macports $work_dir/.macports.statefile-unknown-version.state
+    }
+    set result [catch {eval exec $env $bindir$cmd $args >$output_file 2>@1} ]
+}
+
+# Uninstalls portfile.
+proc port_uninstall {} {
+    global bindir
+    global portsrc
+
+    set env "env PORTSRC=${portsrc}"
+    set cmd "port"
+    set args "uninstall"
+
+    set result [catch {eval exec $env $bindir$cmd $args > output 2>@1} ]
+}
+
+# Returns the line containint a given string
+# from a given file, or -1 if nothing is found.
+proc get_line {filename lookup} {
+    set fp [open $filename r]
+
+    while {[gets $fp line] != -1} {
+        set line [string tolower $line]
+
+        if {[string match $lookup $line] != 0} {
+            close $fp
+            return $line
+        }
+    }
+    return -1
+}
+
+# This proc contains all the steps necesary
+# to install a port and save the output to a file.
+# Needed for the majority of regression tests.
+proc initial_setup {} {
+    global output_file
+    global work_dir
+    global path
+
+    makeFile "" $output_file
+    makeDirectory $work_dir
+
+    load_variables $path
+    set_dir
+    port_index
+    port_clean $path
+    port_run $path
+}

Copied: trunk/base/tests/test/site-tags/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/site-tags/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/site-tags/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/site-tags/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test checks if MacPorts can fetch files from different URLs for the
+specified tags.
+
+There is 1 test case that looks for errors in the output file.

Deleted: trunk/base/tests/test/site-tags/master
===================================================================
--- trunk/base/tests/test/site-tags/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/site-tags/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,8 +0,0 @@
---->  Fetching distfiles for site-tags
---->  Attempting to fetch app-bm.tar.gz from http://www.douglas.stebila.ca/files/code/vim/app/
---->  Attempting to fetch doc.tar.gz from http://www.douglas.stebila.ca/files/code/vim/doc/
---->  Verifying checksums for site-tags
---->  Extracting site-tags
---->  Configuring site-tags
---->  Building site-tags
---->  Testing site-tags

Copied: trunk/base/tests/test/site-tags/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/site-tags/test.tcl)
===================================================================
--- trunk/base/tests/test/site-tags/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/site-tags/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,33 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+proc sitetag {} {
+    global output_file
+    global path
+
+    initial_setup
+
+    set err "error*"
+    set line [get_line $output_file $err]
+    if {$line == -1} {
+        return "No errors found."
+    } else {
+        return "Errors found in the output file."
+    }
+}
+
+test site-tags {
+    Regression test for site-tags.
+} -body {
+    sitetag
+} -result "No errors found."
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/statefile-unknown-version/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/statefile-unknown-version/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/statefile-unknown-version/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/statefile-unknown-version/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,5 @@
+This test checks that version 3 is not accepted. MacPorts keeps track 
+of the build process (and which steps have been completed) in a statefile.
+
+There are 2 test cases, one for the warnings and another that checks for the
+staging into destroot.

Deleted: trunk/base/tests/test/statefile-unknown-version/Makefile
===================================================================
--- trunk/base/tests/test/statefile-unknown-version/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-unknown-version/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,15 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@PORTSRC=$(PORTSRC) $(bindir)/port configure >/dev/null 2>&1
-	@cp statefile work/.macports.statefile-unknown-version.state
-	@PORTSRC=$(PORTSRC) $(bindir)/port destroot >output 2>&1 || (cat output; exit 1)
-	@diff -u master output || (echo "statfile version 3 was accepted, although it shouldn't (this is a hacky test, which might also fail if you change the number of pahses)"; exit 1)
-	@PORTSRC=$(PORTSRC) $(bindir)/port clean >/dev/null 2>&1
-	@rm output

Deleted: trunk/base/tests/test/statefile-unknown-version/master
===================================================================
--- trunk/base/tests/test/statefile-unknown-version/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-unknown-version/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,18 +0,0 @@
-Warning: Unsupported statefile version '3'
-Warning: Please run 'port selfupdate' to update to the latest version of MacPorts
-Warning: Unsupported statefile version '3'
-Warning: Please run 'port selfupdate' to update to the latest version of MacPorts
-Warning: Unsupported statefile version '3'
-Warning: Please run 'port selfupdate' to update to the latest version of MacPorts
-Warning: Unsupported statefile version '3'
-Warning: Please run 'port selfupdate' to update to the latest version of MacPorts
-Warning: Unsupported statefile version '3'
-Warning: Please run 'port selfupdate' to update to the latest version of MacPorts
-Warning: Unsupported statefile version '3'
-Warning: Please run 'port selfupdate' to update to the latest version of MacPorts
-Warning: Unsupported statefile version '3'
-Warning: Please run 'port selfupdate' to update to the latest version of MacPorts
---->  Building statefile-unknown-version
-Warning: Unsupported statefile version '3'
-Warning: Please run 'port selfupdate' to update to the latest version of MacPorts
---->  Staging statefile-unknown-version into destroot

Copied: trunk/base/tests/test/statefile-unknown-version/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/statefile-unknown-version/test.tcl)
===================================================================
--- trunk/base/tests/test/statefile-unknown-version/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/statefile-unknown-version/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,46 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+set path [file dirname [file normalize $argv0]]
+
+# Initial setup
+load_variables $path
+set_dir
+port_index
+port_config $path
+port_desroot $path
+port_clean $path
+
+proc state_unknown {warn} {
+    global path
+    global output_file
+
+    if {[string compare $warn "no"]} {
+        set msg "warning*"
+    } else {
+        set msg "*staging*destroot*"
+    }
+
+    set line [get_line $path/$output_file $msg]
+    return $line
+}
+
+test warning_check {
+    Regression test for statefile-unknown warnings.
+} -body {
+    state_unknown yes
+} -result "warning: unsupported statefile version '3'"
+
+test output_check {
+    Regression test for statefile-unknown output.
+} -body {
+    state_unknown no
+} -result "--->  staging statefile-unknown-version into destroot"
+
+removeFile $work_dir
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/statefile-version1/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version1/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/statefile-version1/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/statefile-version1/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,5 @@
+This test checks that a non-outdated statefile version doesn't trigger a
+rebuild.
+
+There are 2 test cases, one that makes sure the statefile doesn't get
+discarded and another that looks for staging into destroot.

Deleted: trunk/base/tests/test/statefile-version1/Makefile
===================================================================
--- trunk/base/tests/test/statefile-version1/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version1/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,15 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@PORTSRC=$(PORTSRC) $(bindir)/port configure >/dev/null 2>&1
-	@cp statefile work/.macports.statefile-version1.state
-	@PORTSRC=$(PORTSRC) $(bindir)/port destroot >output 2>&1 || (cat output; exit 1)
-	@diff -u master output || (echo "statefile version 1 wasn't outdated but still triggered a rebuild"; exit 1)
-	@PORTSRC=$(PORTSRC) $(bindir)/port clean >/dev/null 2>&1
-	@rm output

Deleted: trunk/base/tests/test/statefile-version1/master
===================================================================
--- trunk/base/tests/test/statefile-version1/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version1/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,2 +0,0 @@
---->  Building statefile-version1
---->  Staging statefile-version1 into destroot

Copied: trunk/base/tests/test/statefile-version1/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version1/test.tcl)
===================================================================
--- trunk/base/tests/test/statefile-version1/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/statefile-version1/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,46 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+
+# Initial setup
+load_variables $path
+set_dir
+port_index
+port_config $path
+port_desroot $path
+port_clean $path
+
+proc statefile_v1 {warn} {
+    global path
+    global output_file
+
+    if {[string compare $warn "no"]} {
+        set msg "*discarding previous state*"
+    } else {
+        set msg "*staging*destroot*"
+    }
+    set line [get_line $path/$output_file $msg]
+    return $line
+}
+
+test warning_check {
+    Regression test for statefile-version1.
+} -body {
+    statefile_v1 yes
+} -result "-1"
+
+test output_check {
+    Regression test for statefile-version1.
+} -body {
+    statefile_v1 no
+} -result "--->  staging statefile-version1 into destroot"
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/statefile-version1-outdated/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version1-outdated/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/statefile-version1-outdated/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/statefile-version1-outdated/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test checks that an outdated statefile will cause a fresh build.
+
+There are 2 test cases, one that ensures the statefile gets discarded and another
+that ensures staging into destroot.

Deleted: trunk/base/tests/test/statefile-version1-outdated/Makefile
===================================================================
--- trunk/base/tests/test/statefile-version1-outdated/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version1-outdated/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,16 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@PORTSRC=$(PORTSRC) $(bindir)/port configure >/dev/null 2>&1
-	@cp statefile work/.macports.statefile-version1-outdated.state
-	@touch -t 197001010000.09 work/.macports.statefile-version1-outdated.state
-	@PORTSRC=$(PORTSRC) $(bindir)/port destroot >output 2>&1 || (cat output; exit 1)
-	@diff -u master output || (echo "statfile version 1 was outdated but didn't cause a fresh build"; exit 1)
-	@PORTSRC=$(PORTSRC) $(bindir)/port clean >/dev/null 2>&1
-	@rm output

Deleted: trunk/base/tests/test/statefile-version1-outdated/master
===================================================================
--- trunk/base/tests/test/statefile-version1-outdated/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version1-outdated/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,7 +0,0 @@
-Portfile changed since last build; discarding previous state.
---->  Fetching distfiles for statefile-version1-outdated
---->  Verifying checksums for statefile-version1-outdated
---->  Extracting statefile-version1-outdated
---->  Configuring statefile-version1-outdated
---->  Building statefile-version1-outdated
---->  Staging statefile-version1-outdated into destroot

Copied: trunk/base/tests/test/statefile-version1-outdated/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version1-outdated/test.tcl)
===================================================================
--- trunk/base/tests/test/statefile-version1-outdated/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/statefile-version1-outdated/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,48 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+set path [file dirname [file normalize $argv0]]
+
+# Initial setup
+load_variables $path
+set_dir
+port_index
+port_config $path
+file copy -force $path/statefile $work_dir/.macports.statefile-version1-outdated.state
+exec touch -t 197001010000.09 $work_dir/.macports.statefile-version1-outdated.state
+port_desroot $path
+port_clean $path
+
+proc state_v1 {warn} {
+    global path
+    global output_file
+
+    if {[string compare $warn "no"]} {
+        set msg "*discarding previous state*"
+    } else {
+        set msg "*staging*destroot*"
+    }
+
+    set line [get_line $path/$output_file $msg]
+    return $line
+}
+
+test warning_check {
+    Regression test for statefile-v1-outdated discard prev version.
+} -body {
+    state_v1 yes
+} -result "portfile changed since last build; discarding previous state."
+
+test output_check {
+    Regression test for statefile-v1-outdated output.
+} -body {
+    state_v1 no
+} -result "--->  staging statefile-version1-outdated into destroot"
+
+removeDirectory $work_dir
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/statefile-version2/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version2/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/statefile-version2/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/statefile-version2/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,5 @@
+This test checks that a non-outdated statefile version doesn't trigger a
+rebuild.
+
+There are 2 test cases, one that makes sure the statefile doesn't get
+discarded and another that looks for staging into destroot.

Deleted: trunk/base/tests/test/statefile-version2/Makefile
===================================================================
--- trunk/base/tests/test/statefile-version2/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version2/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,16 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@PORTSRC=$(PORTSRC) $(bindir)/port configure >/dev/null 2>&1
-	@cp statefile work/.macports.statefile-version2.state
-	@sed -i'' -E "s/@CHECKSUM@/`openssl dgst -sha256 Portfile | awk '{print $$2}'`/" work/.macports.statefile-version2.state
-	@PORTSRC=$(PORTSRC) $(bindir)/port destroot >output 2>&1 || (cat output; exit 1)
-	@diff -u master output || (echo "statefile version 2 wasn't outdated, but still triggered a rebuild"; exit 1)
-	@PORTSRC=$(PORTSRC) $(bindir)/port clean >/dev/null 2>&1
-	@rm output

Deleted: trunk/base/tests/test/statefile-version2/master
===================================================================
--- trunk/base/tests/test/statefile-version2/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version2/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,2 +0,0 @@
---->  Building statefile-version2
---->  Staging statefile-version2 into destroot

Copied: trunk/base/tests/test/statefile-version2/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version2/test.tcl)
===================================================================
--- trunk/base/tests/test/statefile-version2/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/statefile-version2/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,49 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+
+# Initial setup
+load_variables $path
+set_dir
+port_index
+port_config $path
+file copy -force $path/statefile $work_dir/.macports.statefile-version2.state
+exec sed -i'' -E "s/@CHECKSUM@/`openssl dgst -sha256 Portfile | \
+    awk '{print \$\$2}'`/" $work_dir/.macports.statefile-version2.state
+port_desroot $path
+port_clean $path
+
+proc statefile_v2 {arg} {
+    global path
+    global output_file
+
+    if {[string compare $arg "no"]} {
+        set msg "*discarding previous state*"
+    } else {
+        set msg "*staging*destroot*"
+    }
+    set line [get_line $path/$output_file $msg]
+    return $line
+}
+
+test statefile-v2-discard {
+    Regression test for statefile-version2 no discard.
+} -body {
+    statefile_v2 yes
+} -result "-1"
+
+test statefile-v2 {
+    Regression test for statefile-version2.
+} -body {
+    statefile_v2 no
+} -result "--->  staging statefile-version2 into destroot"
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/statefile-version2-invalid/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version2-invalid/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/statefile-version2-invalid/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/statefile-version2-invalid/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,5 @@
+This test checks that statefile version 2 without checksum field will cause a
+warning message. MacPorts should never deal with a broken statefile.
+
+There are 2 test cases, one that ensures a warning message gets thrown and
+another that ensures staging into destroot.

Deleted: trunk/base/tests/test/statefile-version2-invalid/Makefile
===================================================================
--- trunk/base/tests/test/statefile-version2-invalid/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version2-invalid/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,15 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@PORTSRC=$(PORTSRC) $(bindir)/port configure >/dev/null 2>&1
-	@cp statefile work/.macports.statefile-version2-invalid.state
-	@PORTSRC=$(PORTSRC) $(bindir)/port destroot >output 2>&1 || (cat output; exit 1)
-	@diff -u master output || (echo "statefile version 2 without checksum field didn't cause a warning"; exit 1)
-	@PORTSRC=$(PORTSRC) $(bindir)/port clean >/dev/null 2>&1
-	@rm output

Deleted: trunk/base/tests/test/statefile-version2-invalid/master
===================================================================
--- trunk/base/tests/test/statefile-version2-invalid/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version2-invalid/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,8 +0,0 @@
-Warning: Statefile has version 2 but didn't contain a checksum
-Portfile changed since last build; discarding previous state.
---->  Fetching distfiles for statefile-version2-invalid
---->  Verifying checksums for statefile-version2-invalid
---->  Extracting statefile-version2-invalid
---->  Configuring statefile-version2-invalid
---->  Building statefile-version2-invalid
---->  Staging statefile-version2-invalid into destroot

Copied: trunk/base/tests/test/statefile-version2-invalid/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version2-invalid/test.tcl)
===================================================================
--- trunk/base/tests/test/statefile-version2-invalid/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/statefile-version2-invalid/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,47 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+set path [file dirname [file normalize $argv0]]
+
+# Initial setup
+load_variables $path
+set_dir
+port_index
+port_config $path
+file copy -force $path/statefile $work_dir/.macports.statefile-version2-invalid.state
+port_desroot $path
+port_clean $path
+
+proc state_v2_invalid {warn} {
+    global path
+    global output_file
+
+    if {[string compare $warn "no"]} {
+        set msg "*warning*checksum*"
+    } else {
+        set msg "*staging*destroot*"
+    }
+
+    set line [get_line $path/$output_file $msg]
+    return $line
+}
+
+test warning_check {
+    Regression test for statefile-v2-invalid discard prev version.
+} -body {
+    state_v2_invalid yes
+} -result "warning: statefile has version 2 but didn't contain a checksum"
+
+test output_check {
+    Regression test for statefile-v2-invalid output.
+} -body {
+    state_v2_invalid no
+} -result "--->  staging statefile-version2-invalid into destroot"
+
+removeDirectory $work_dir
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/statefile-version2-outdated/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version2-outdated/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/statefile-version2-outdated/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/statefile-version2-outdated/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test checks that an outdated statefile will cause a fresh build.
+
+There are 2 test cases, one that ensures the statefile gets discarded and another
+that ensures staging into destroot.

Deleted: trunk/base/tests/test/statefile-version2-outdated/Makefile
===================================================================
--- trunk/base/tests/test/statefile-version2-outdated/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version2-outdated/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,15 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@PORTSRC=$(PORTSRC) $(bindir)/port configure >/dev/null 2>&1
-	@cp statefile work/.macports.statefile-version2-outdated.state
-	@PORTSRC=$(PORTSRC) $(bindir)/port destroot >output 2>&1 || (cat output; exit 1)
-	@diff -u master output || (echo "statefile version 2 was outdated but didn't cause a fresh build"; exit 1)
-	@PORTSRC=$(PORTSRC) $(bindir)/port clean >/dev/null 2>&1
-	@rm output

Deleted: trunk/base/tests/test/statefile-version2-outdated/master
===================================================================
--- trunk/base/tests/test/statefile-version2-outdated/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/statefile-version2-outdated/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,7 +0,0 @@
-Portfile changed since last build; discarding previous state.
---->  Fetching distfiles for statefile-version2-outdated
---->  Verifying checksums for statefile-version2-outdated
---->  Extracting statefile-version2-outdated
---->  Configuring statefile-version2-outdated
---->  Building statefile-version2-outdated
---->  Staging statefile-version2-outdated into destroot

Copied: trunk/base/tests/test/statefile-version2-outdated/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/statefile-version2-outdated/test.tcl)
===================================================================
--- trunk/base/tests/test/statefile-version2-outdated/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/statefile-version2-outdated/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,47 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+set path [file dirname [file normalize $argv0]]
+
+# Initial setup
+load_variables $path
+set_dir
+port_index
+port_config $path
+file copy -force $path/statefile $work_dir/.macports.statefile-version2-outdated.state
+port_desroot $path
+port_clean $path
+
+proc state_v2_out {warn} {
+    global path
+    global output_file
+
+    if {[string compare $warn "no"]} {
+        set msg "*discarding previous state*"
+    } else {
+        set msg "*staging*destroot*"
+    }
+
+    set line [get_line $path/$output_file $msg]
+    return $line
+}
+
+test warning_check {
+    Regression test for statefile-v2-outdated discard prev version.
+} -body {
+    state_v2_out yes
+} -result "portfile changed since last build; discarding previous state."
+
+test output_check {
+    Regression test for statefile-v2-outdated output.
+} -body {
+    state_v2_out no
+} -result "--->  staging statefile-version2-outdated into destroot"
+
+removeDirectory $work_dir
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/svn-and-patchsites/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/svn-and-patchsites/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/svn-and-patchsites/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/svn-and-patchsites/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test checks fetching using svn and downloading of patchfiles from
+the URL given by patch_sites.
+
+There is 1 test case which looks for errors in the output file.

Deleted: trunk/base/tests/test/svn-and-patchsites/master
===================================================================
--- trunk/base/tests/test/svn-and-patchsites/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/svn-and-patchsites/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,7 +0,0 @@
---->  Fetching distfiles for svn-and-patchsites
---->  Attempting to fetch patch-1.5.14.dgc.xlabel_ext.9 from http://home.uchicago.edu/~dgc/sw/mutt/
---->  Verifying checksums for svn-and-patchsites
---->  Extracting svn-and-patchsites
---->  Configuring svn-and-patchsites
---->  Building svn-and-patchsites
---->  Testing svn-and-patchsites

Copied: trunk/base/tests/test/svn-and-patchsites/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/svn-and-patchsites/test.tcl)
===================================================================
--- trunk/base/tests/test/svn-and-patchsites/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/svn-and-patchsites/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,30 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+set path [file dirname [file normalize $argv0]]
+
+initial_setup
+
+proc svn-patch {} {
+    global output_file
+    global path
+
+    set svn "error*"
+    set line [get_line $path/$output_file $svn]
+    if {$line == -1} {
+        return "No error found."
+    } else {
+        return "Errors found in output file."
+    }
+}
+
+test svn-patchsites {
+    Regression test for svn-and-patchsites.
+} -body {
+    svn-patch
+} -result "No error found."
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/trace/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/trace/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/trace/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/trace/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test checks the 'port -t' command which creates a virtual sandbox by a 
+mechanism known from Linux as library LD_PRELOADing.
+
+There is 1 test case, which looks for errors in the output file.

Copied: trunk/base/tests/test/trace/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/trace/test.tcl)
===================================================================
--- trunk/base/tests/test/trace/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/trace/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,59 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+load_variables $path
+
+proc test_trace {} {
+    global path
+    global autoconf
+    global output_file
+
+    set line [get_line $autoconf "runusr*"]
+    set user [lrange [split $line " "] 1 1]
+
+    set_dir
+    port_index
+    port_clean $path
+
+
+    makeDirectory ../tracetesttmp
+    file attributes ../tracetesttmp -owner $user
+    exec sudo -u $user touch  ../tracetesttmp/delete-trace
+    exec sudo -u $user touch ../tracetesttmp/rename-trace
+    exec sudo -u $user mkdir ../tracetesttmp/rmdir-trace
+    file delete -force /tmp/hello-trace
+    file attributes /usr/include/unistd.h -owner $user
+    file link -symbolic /tmp/link-trace2 /usr/include/unistd.h
+    exec chown -h $user /tmp/link-trace2
+
+    port_trace $path
+    
+    #file delete -force /tmp/link-trace2
+    file delete -force /tmp/hello-trace
+
+    set err "error*"
+    set line [get_line $path/$output_file $err]
+    if { $line == -1 } {
+        return "No errors found."
+    } else {
+        return $line
+    }
+}
+
+test trace {
+    Regression test for trace.
+} -constraints {
+    root
+} -body {
+    test_trace
+} -result "No errors found."
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/universal/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/universal/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/universal/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/universal/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,7 @@
+This test checks the handling of the universal variant in MacPorts base.
+Every port should have an universal variant unless 'universal_variant no' is
+specified.
+
+There are 2 test cases. One for universal variant set and another for no
+universal variant. For each test a specific Portfile is generated from the
+Port.in file.

Deleted: trunk/base/tests/test/universal/Makefile
===================================================================
--- trunk/base/tests/test/universal/Makefile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/universal/Makefile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,17 +0,0 @@
-include ../../../Mk/macports.autoconf.mk
-
-.PHONY: test
-
-$(bindir)/port:
-	@echo "Please install MacPorts before running this test"
-	@exit 1
-
-test:
-	@PORTSRC=$(PORTSRC) $(bindir)/port clean > /dev/null
-	@sh -c "export PORTSRC=$(PORTSRC); $(bindir)/port info --variants" > output 2>&1 || (cat output; exit 1)
-	@diff -u master output 2>&1 | tee difference
-	@if [ -s difference ]; then \
-		exit 1; \
-	else \
-		rm -f difference; \
-	fi

Deleted: trunk/base/tests/test/universal/Portfile
===================================================================
--- trunk/base/tests/test/universal/Portfile	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/universal/Portfile	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,23 +0,0 @@
-# $Id$
-
-PortSystem 1.0
-name		universal
-version		1
-categories	test
-maintainers	pguyot at kallisys.net
-description	Test port for universal variant
-homepage	http://www.macports.org/
-platforms	darwin
-
-long_description ${description}
-
-distfiles
-configure	{}
-build		{}
-destroot	{
-	system "touch ${destroot}${prefix}/lib/${name}"
-}
-
-test		{}
-
-default_variants +universal

Copied: trunk/base/tests/test/universal/Portfile.in (from rev 111324, branches/gsoc13-tests/tests/test/universal/Portfile.in)
===================================================================
--- trunk/base/tests/test/universal/Portfile.in	                        (rev 0)
+++ trunk/base/tests/test/universal/Portfile.in	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,18 @@
+# $Id$
+PortSystem 1.0
+name            universal
+version         1
+categories      test
+maintainers     pguyot at kallisys.net
+description     Test port for universal variant
+homepage        http://www.macports.org/
+platforms       darwin
+long_description ${description}
+distfiles
+configure       {}
+build           {}
+destroot        {
+        system "touch ${destroot}${prefix}/lib/${name}"
+}
+test            {}
+ at option@

Deleted: trunk/base/tests/test/universal/master
===================================================================
--- trunk/base/tests/test/universal/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/universal/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1 +0,0 @@
-variants: universal

Copied: trunk/base/tests/test/universal/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/universal/test.tcl)
===================================================================
--- trunk/base/tests/test/universal/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/universal/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,57 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+
+makeFile "" "Portfile"
+makeFile "" $output_file
+makeDirectory $work_dir
+set path [file dirname [file normalize $argv0]]
+
+# Initial setup
+load_variables $path
+set_dir
+port_index
+
+proc univ_test {opt} {
+    global output_file
+    global path
+    global portsrc
+    global bindir
+
+    # Modify Porfile.in for variants.
+    if {[string compare $opt "yes"]} {
+        # No universal variant
+        exec sed "s/@option@/universal_variant\ no/" $path/Portfile.in > Portfile
+    } else {
+        # Add universal variant
+        exec sed "s/@option@/default_variants\ +universal/" $path/Portfile.in > Portfile
+    }
+    port_clean $path
+
+    # Build helping string
+    append string "export PORTSRC=" $portsrc "; "
+    append string $bindir "port info --variants"
+
+    exec sh -c $string > output 2>@1
+    set var "variants:*"
+    set line [get_line $path/$output_file $var]
+    return $line
+}
+
+
+test universal {
+    Regression test for universal variant.
+} -body {
+    univ_test "yes"
+} -result "variants: universal"
+
+test nouniversal {
+    Regression test for no universal variant.
+} -body {
+    univ_test "no"
+} -result "variants: "
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/variants/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/variants/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/variants/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/variants/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,3 @@
+This test checks the variants feature in general.
+
+There is 1 test case.

Deleted: trunk/base/tests/test/variants/master
===================================================================
--- trunk/base/tests/test/variants/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/variants/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,8 +0,0 @@
-Utopia variant -- 2
-Utopia variant -- 2
---->  Fetching distfiles for variants
---->  Verifying checksums for variants
---->  Extracting variants
---->  Configuring variants
---->  Building variants
---->  Testing variants

Copied: trunk/base/tests/test/variants/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/variants/test.tcl)
===================================================================
--- trunk/base/tests/test/variants/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/variants/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,27 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+set path [file dirname [file normalize $argv0]]
+
+initial_setup
+
+proc var_check {} {
+    global output_file
+    global path
+
+    set var "utopia variant*"
+    set line [get_line $path/$output_file $var]
+    return $line
+}
+
+
+test variants {
+    Regression test for variants.
+} -body {
+    var_check
+} -result "utopia variant -- 2"
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test/xcodeversion/DESCRIPTION (from rev 111324, branches/gsoc13-tests/tests/test/xcodeversion/DESCRIPTION)
===================================================================
--- trunk/base/tests/test/xcodeversion/DESCRIPTION	                        (rev 0)
+++ trunk/base/tests/test/xcodeversion/DESCRIPTION	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,4 @@
+This test checks the Xcode version. MacPorts needs at least Xcode 2.1.
+
+There are 2 test cases, one for the Xcode version and another to check the
+xcodebuild path.

Deleted: trunk/base/tests/test/xcodeversion/master
===================================================================
--- trunk/base/tests/test/xcodeversion/master	2013-09-18 23:14:53 UTC (rev 111324)
+++ trunk/base/tests/test/xcodeversion/master	2013-09-19 00:14:10 UTC (rev 111325)
@@ -1,8 +0,0 @@
---->  Fetching distfiles for xcodeversion
---->  Verifying checksums for xcodeversion
---->  Extracting xcodeversion
---->  Configuring xcodeversion
---->  Building xcodeversion
---->  Testing xcodeversion
-xcodeversion >= 2.1
-xcodebuildcmd = /usr/bin/xcodebuild

Copied: trunk/base/tests/test/xcodeversion/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test/xcodeversion/test.tcl)
===================================================================
--- trunk/base/tests/test/xcodeversion/test.tcl	                        (rev 0)
+++ trunk/base/tests/test/xcodeversion/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,41 @@
+package require tcltest 2
+namespace import tcltest::*
+
+source [file dirname $argv0]/../library.tcl
+set path [file dirname [file normalize $argv0]]
+
+initial_setup
+
+proc xcode_ver {} {
+    global output_file
+    global path
+
+    set xcode "xcodeversion*"
+    set line [get_line $path/$output_file $xcode]
+    return $line
+}
+
+proc xcode_binpath {} {
+    global output_file
+    global path
+
+    set xcode "xcodebuildcmd*"
+    set line [get_line $path/$output_file $xcode]
+    return $line
+}
+
+test envvariables {
+    Regression test for XCode version.
+} -body {
+    xcode_ver
+} -result "xcodeversion >= 2.1"
+
+test xcode_path {
+    Regression test for XCode path.
+} -body {
+    xcode_binpath
+} -result "xcodebuildcmd = /usr/bin/xcodebuild"
+
+
+cleanup
+cleanupTests

Copied: trunk/base/tests/test.tcl (from rev 111324, branches/gsoc13-tests/tests/test.tcl)
===================================================================
--- trunk/base/tests/test.tcl	                        (rev 0)
+++ trunk/base/tests/test.tcl	2013-09-19 00:14:10 UTC (rev 111325)
@@ -0,0 +1,143 @@
+set test_suite {
+    case-insensitive-deactivate
+    checksums-1
+    dependencies-a
+    dependencies-b
+    dependencies-c
+    dependencies-d
+    dependencies-e
+    envvariables
+    site-tags
+    statefile-unknown-version
+    statefile-version1
+    statefile-version1-outdated
+    statefile-version2
+    statefile-version2-invalid
+    statefile-version2-outdated
+    svn-and-patchsites
+    trace
+    universal
+    variants
+    xcodeversion
+}
+set arguments ""
+set test_name ""
+set color_out ""
+set tcl ""
+set err ""
+
+# Get tclsh path.
+set autoconf ../Mk/macports.autoconf.mk
+set fp [open $autoconf r]
+while {[gets $fp line] != -1} {
+    if {[string match "TCLSH*" $line] != 0} {
+        set tcl [lrange [split $line " "] 1 1]
+    }
+}
+
+proc print_help {arg} {
+    if { $arg == "tests" } {
+        puts "The list of abailable tests is:"
+        foreach test $::test_suite {
+            puts [puts -nonewline "  "]$test
+        }
+    } else {
+        puts "Usage: tclsh test.tcl \[-debug level\] \[-t test\] \[-l\]\n"
+        puts "  -debug LVL : sets the level of printed debug info \[0-3\]"
+        puts "  -t TEST    : run a specific test"
+        puts "  -nocolor   : disable color output (for automatic testing)"
+        puts "  -l         : print the list of available tests"
+        puts "  -h, -help  : print this message\n"
+    }
+}
+
+# Process args
+foreach arg $argv {
+    if { $arg == "-h" || $arg == "-help" } {
+        print_help ""
+        exit 0
+    } elseif { $arg == "-debug" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set level [lindex $argv $index]
+        if { $level >= 0 && $level <= 3 } {
+            append arguments "-debug " $level
+        } else {
+            puts "Invalid debug level."
+            exit 1
+        }
+    } elseif { $arg == "-t" } {
+        set index [expr [lsearch $argv $arg] + 1]
+        set test_name [lindex $argv $index]
+        set no 0
+        foreach test $test_suite {
+            if { $test_name != $test } {
+                set no [expr $no + 1]
+            }
+        }
+        if { $no == [llength $test_suite] } {
+            print_help tests
+            exit 1
+        }
+    } elseif { $arg == "-l" } {
+        print_help tests
+        exit 0
+    } elseif { $arg == "-nocolor" } {
+        set color_out "no"
+    }
+}
+
+
+# Run tests
+if { $test_name != ""} {
+    cd test/$test_name
+
+    set result [eval exec $tcl test.tcl $arguments]
+    puts $result
+
+} else {
+    foreach test $test_suite {
+        cd test/$test
+    
+        set result [eval exec $tcl test.tcl $arguments]
+        set lastline [lindex [split $result "\n"] end]
+
+        if {[lrange [split $lastline "\t"] 1 1] != "Total"} {
+            set lastline [lindex [split $result "\n"] end-2]
+            set errmsg [lindex [split $result "\n"] end]
+        }
+
+        set splitresult [split $lastline "\t"]
+        set total [lindex $splitresult 2]
+        set pass [lindex $splitresult 4]
+        set skip [lindex $splitresult 6]
+        set fail [lindex $splitresult 8]
+
+        # Check for errors.
+        if { $fail != 0 } { set err "yes" }
+
+        set out ""
+        if { ($fail != 0 || $skip != 0) && $color_out == "" } {
+            # Color failed tests.
+            append out "\x1b\[1;31mTotal:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  \x1b\[0m" $test
+        } else {
+            append out "Total:" $total " Passed:" $pass " Failed:" $fail " Skipped:" $skip "  " $test
+        }
+
+        # Print results and constrints for auto-skipped tests.
+        puts $out
+        if { $skip != 0 } {
+            set out "    Constraint: "
+            append out [string trim $errmsg "\t {}"]
+            puts $out
+        }
+    
+        cd ../..
+    }
+}
+
+# Return 1 if errors were found.
+if {$err != ""} {
+    exit 1
+}
+
+return 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130918/809cc7fd/attachment-0001.html>


More information about the macports-changes mailing list