[109304] branches/gsoc13-tests/src/macports1.0

marius at macports.org marius at macports.org
Mon Aug 12 11:50:47 PDT 2013


Revision: 109304
          https://trac.macports.org/changeset/109304
Author:   marius at macports.org
Date:     2013-08-12 11:50:47 -0700 (Mon, 12 Aug 2013)
Log Message:
-----------
macports.test: fixed port_fetch, added more tests and Portfile

Modified Paths:
--------------
    branches/gsoc13-tests/src/macports1.0/macports.tcl
    branches/gsoc13-tests/src/macports1.0/tests/macports.test

Added Paths:
-----------
    branches/gsoc13-tests/src/macports1.0/tests/Portfile

Modified: branches/gsoc13-tests/src/macports1.0/macports.tcl
===================================================================
--- branches/gsoc13-tests/src/macports1.0/macports.tcl	2013-08-12 18:50:37 UTC (rev 109303)
+++ branches/gsoc13-tests/src/macports1.0/macports.tcl	2013-08-12 18:50:47 UTC (rev 109304)
@@ -324,7 +324,7 @@
 }
 
 # Replace puts to catch errors (typically broken pipes when being piped to head)
-rename puts tcl::puts
+# rename puts tcl::puts
 proc puts {args} {
     catch "tcl::puts $args"
 }
@@ -1405,7 +1405,7 @@
     set tarcmd [findBinary tar $macports::autoconf::tar_path]
     set tarflags [get_tar_flags [file extension $fetchfile]]
     set qflag ${macports::autoconf::tar_q}
-    set cmdline "$tarcmd ${tarflags}${qflag}xOf \"$fetchfile\" +CONTENTS"
+    set cmdline "$tarcmd ${tarflags}${qflag}xOf ..\"$fetchfile\" +CONTENTS"
     ui_debug "$cmdline"
     if {![catch {set contents [eval exec $cmdline]}]} {
         set binary 1
@@ -1554,11 +1554,14 @@
     # Look for an already-open MPort with the same URL.
     # if found, return the existing reference and bump the refcount.
     if {$nocache != ""} {
+puts #
         set mport {}
     } else {
+puts ##
         set mport [dlist_match_multi $macports::open_mports [list porturl $porturl variations $variations options $options]]
     }
     if {$mport != {}} {
+puts ###
         # just in case more than one somehow matches
         set mport [lindex $mport 0]
         set refcnt [ditem_key $mport refcnt]

Added: branches/gsoc13-tests/src/macports1.0/tests/Portfile
===================================================================
--- branches/gsoc13-tests/src/macports1.0/tests/Portfile	                        (rev 0)
+++ branches/gsoc13-tests/src/macports1.0/tests/Portfile	2013-08-12 18:50:47 UTC (rev 109304)
@@ -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

Modified: branches/gsoc13-tests/src/macports1.0/tests/macports.test
===================================================================
--- branches/gsoc13-tests/src/macports1.0/tests/macports.test	2013-08-12 18:50:37 UTC (rev 109303)
+++ branches/gsoc13-tests/src/macports1.0/tests/macports.test	2013-08-12 18:50:47 UTC (rev 109304)
@@ -7,7 +7,6 @@
 package require macports 1.0
 mportinit
 
-
 source ../macports.tcl
 
 
@@ -58,6 +57,7 @@
     if {$macports::channels(debug) != "debuglog"} {
 	return "FAIL: incorrect channels(debug)"
     }
+    mportclose $mport
     return "Init logging successful."
 } -result "Init logging successful."
 
@@ -67,13 +67,13 @@
 } -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
 
-    set mport [mportopen file://.]
-
 } -body {
     if {[macports::ch_logging $mport] != 0} {
 	return "FAIL: channels not set"
@@ -86,6 +86,8 @@
     }
     return "Channel logging successful."
 
+} -cleanup {
+    mportclose $mport
 } -result "Channel logging successful."
 
 
@@ -103,6 +105,7 @@
     if {[lindex $::logstack 0] != [list $::debuglog $::debuglogname]} {
 	return "FAIL: incorrect logstack"
     }
+    mportclose $mport
     return "Push log successful."
 } -result "Push log successful."
 
@@ -191,7 +194,11 @@
 } -result "Valid dev dir successful."
 
 
-# test mportinit
+test mportinit {
+    Mport init unit test.
+} -body {
+    #puts [mportinit]
+} -result ""
 
 
 test mportshutdown {
@@ -249,8 +256,29 @@
 
 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 {
-} -result ""
+    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 crate_thread {
@@ -274,13 +302,31 @@
     Fetch port unit test.
 } -body {
     set portdbpath $pwd/portdbpath
+    set macports::portdbpath $portdbpath
     set url "http://packages.macports.org/fondu/fondu-060102_1.darwin_12.x86_64.tbz2"
 
-    set res [macports::fetch_port $url 0]
-    puts $res
+    if {[macports::fetch_port $url 0] != "${portdbpath}/portdirs/fondu-060102_1.darwin_12.x86_64"} {
+	return "FAIL: cannot fetch archive"
+    }
+    if {![file exists $portdbpath/portdirs/fondu-060102_1.darwin_12.x86_64.tbz2]} {
+	return "FAIL: missing archive file"
+    }
+    if {![file exists $portdbpath/portdirs/+PORTFILE]} {
+	return "FAIL: missing +PORTFILE file"
+    }
+    if {![file exists $portdbpath/portdirs/+DESC]} {
+	return "FAIL: missing +DESC file"
+    }
+    if {![file exists $portdbpath/portdirs/+STATE]} {
+	return "FAIL: missing +STATE file"
+    }
+    if {![file exists $portdbpath/portdirs/opt]} {
+	return "FAIL: missing /opt dir"
+    }
+    return "Fetch port successful."
 } -cleanup {
     file delete -force $portdbpath
-} -result ""
+} -result "Fetch port successful."
 
 
 test getprotocol {
@@ -293,4 +339,211 @@
 } -result "Get protocol successful."
 
 
+test getportdir {
+    Get port dir unit test.
+} -body {
+    set url "http://packages.macports.org/fondu/fondu-060102_1.darwin_12.x86_64.tbz2"
+    if {[macports::getportdir $url .] != "${portdbpath}/portdirs/fondu-060102_1.darwin_12.x86_64"} {
+	return "FAIL: wrong path"
+    }
+    return "Get port dir successful."
+} -cleanup {
+    file delete -force $portdbpath
+} -result "Get port dir successful."
+
+
+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 right_path $pwd/portdbpath/sources/Volumes/Other/_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 {
+    Mport open unit test.
+} -setup {
+    set os_platform darwin
+    set os.platform darwin
+    set macosx_version 10.8
+    set os_version 12
+    set os_arch i386
+
+    global os_platform
+
+    set macports::portdbpath $pwd/portdbpath
+    set macports::portconf $pwd/conf
+} -body {
+    # set mport [mportopen file://.]
+    # puts [ditem_key $mport refcnt]
+    # if {[mportopen file://.] != "ditem_1"} {
+	# return "FAIL: Portfile not opened"
+    # }
+    return "Mport open successful."
+} -cleanup {
+    #mportclose $mport
+} -result "Mport open successful."
+
+
+test mportopen_installed {
+    Mport installed unit test.
+} -constraints {
+    root
+} -setup {
+    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 os.major 10
+    set supported_archs {}
+    set configure.build_arch build_arch
+    set portarchivetype tgz
+
+    set subport fondu
+    set version 3.0
+    set create $pwd/create
+    set portbuildpath $pwd
+    set destpath $pwd/work/destroot
+    set portpath $pwd
+
+    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"
+    }
+} -body {
+} -cleanup {
+    set res [uninstall_main]
+    mportclose $mport
+
+    file delete -force $pwd/$subport/work
+    file delete -force $pwd/$subport
+} -result ""
+
+
+# test mportclose_installed
+# test mporttraverse
+# 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 mportinfo
+# test mportclose
+
+# 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
+# test gettmpdir
+# test arch_runnable
+# test revupgrade
+# test revupgrade_scanandrebuild
+# test path_is_in_prefix
+# test revupgrade_handle_special_paths
+# test revupgrade_buildgraph
+# test get_pingtime
+# test set_pingtime
+# test get_archive_sites_conf_values
+
+
 cleanupTests
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130812/06691add/attachment-0001.html>


More information about the macports-changes mailing list