[110590] branches/gsoc13-tests/src/package1.0

marius at macports.org marius at macports.org
Mon Sep 2 11:16:56 PDT 2013


Revision: 110590
          https://trac.macports.org/changeset/110590
Author:   marius at macports.org
Date:     2013-09-02 11:16:56 -0700 (Mon, 02 Sep 2013)
Log Message:
-----------
package1.0: added test.tcl, Makefile test target, commented out not working tests that may be removed

Modified Paths:
--------------
    branches/gsoc13-tests/src/package1.0/Makefile
    branches/gsoc13-tests/src/package1.0/tests/portarchivefetch.test
    branches/gsoc13-tests/src/package1.0/tests/portdpkg.test
    branches/gsoc13-tests/src/package1.0/tests/portrpm.test
    branches/gsoc13-tests/src/package1.0/tests/portsrpm.test

Added Paths:
-----------
    branches/gsoc13-tests/src/package1.0/tests/test.tcl

Modified: branches/gsoc13-tests/src/package1.0/Makefile
===================================================================
--- branches/gsoc13-tests/src/package1.0/Makefile	2013-09-02 17:24:31 UTC (rev 110589)
+++ branches/gsoc13-tests/src/package1.0/Makefile	2013-09-02 18:16:56 UTC (rev 110590)
@@ -17,6 +17,7 @@
 distclean:: clean
 
 test::
+	$(TCLSH) ./tests/test.tcl -nocolor
 
 install:: all
 	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} ${INSTALLDIR}

Modified: branches/gsoc13-tests/src/package1.0/tests/portarchivefetch.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portarchivefetch.test	2013-09-02 17:24:31 UTC (rev 110589)
+++ branches/gsoc13-tests/src/package1.0/tests/portarchivefetch.test	2013-09-02 18:16:56 UTC (rev 110590)
@@ -4,13 +4,21 @@
 set pwd [file normalize $argv0]
 set pwd [eval file join {*}[lrange [file split $pwd] 0 end-1]]
 
+
 package require macports 1.0
 mportinit
-package require portarchivefetch 1.0
 source ./library.tcl
 macports_worker_init
 
-source ../portarchivefetch.tcl
+#source ../../port1.0/port_autoconf.tcl
+#set portutil::autoconf::openssl_path "/usr/bin/openssl"
+package require portarchivefetch 1.0
+#source ../portarchivefetch.tcl
+namespace eval portutil {
+    namespace eval autoconf {
+	variable openssl_path "/usr/bin/openssl"
+    }
+}
 
 test filter_sites {
     Filter sites unit test.
@@ -21,16 +29,10 @@
     env_init
 
     set portvariants {var1}
-    set master_sites "http://fondu.sourceforge.net/"
+    set porturl http://www.fondu.sourceforge.net/fondu-060102_1var1.darwin_9.noarch.tgz
 
-    #array set portfetch::mirror_sites::sites {
-#	"http://aaa.bbb.ccc/ddd/eee/file.zip" aaa
-    #}
-    #set portfetch::mirror_sites::archive_type tgz
-    #set portfetch::mirror_sites::archive_prefix file
-
 } -body {
-    if {[catch {portarchivefetch::filter_sites}] != 0} {
+    if {[portarchivefetch::filter_sites] != "http://www.fondu.sourceforge.net/:tgz"} {
 	return "FAIL: couldn't fetch file"
     }
 
@@ -40,12 +42,18 @@
 
 test checkarchivefiles {
     Check archive files unit test.
-} -body {
+} -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"
     }
@@ -61,7 +69,41 @@
 
 # test get_full_archive_sites_path
 # test checkfiles
-# test fetchfiles
+
+
+test fetchfiles {
+    Fetch files unit test. Fails to verify signature.
+} -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/
+	archive_sites www.google.com
+    }
+    set portarchivefetch::archivefetch_urls {fondu fondu-060102_1.darwin_12.x86_64.tbz2}
+
+} -body {
+    set macportsuser macports
+    if {[portarchivefetch::fetchfiles] != 0} {
+	return "FAIL: cannot fetch port"
+    }
+    #if {![file exists ${archivefetch.fulldestpath}/fondu_src-060102.tgz.TMP]} {
+	#return "FAIL: missing fetched archive"
+    #}
+    #if {![file exists ${archivefetch.fulldestpath}/fondu_src-060102.tgz.rmd160]} {
+	#return "FAIL: missing fetched archive rmd"
+    #}
+    return "Fetch files successful."
+
+} -cleanup {
+    file delete -force $portdbpath
+
+} -result "Fetch files successful."
+
+
 # test archivefetch_start
 # test archivefetch_main
 

Modified: branches/gsoc13-tests/src/package1.0/tests/portdpkg.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portdpkg.test	2013-09-02 17:24:31 UTC (rev 110589)
+++ branches/gsoc13-tests/src/package1.0/tests/portdpkg.test	2013-09-02 18:16:56 UTC (rev 110590)
@@ -16,6 +16,8 @@
 
 test main {
     Port dpkg main unit test.
+} -constraints {
+    [catch {exec which dpkg-deb}] == 0
 } -setup {
     set os.platform darwin
     set os.major 10
@@ -36,10 +38,6 @@
 
 
 } -body {
-    if {[catch {exec which dpkg-deb}] != 0} {
-	return "FAIL: dpkg package missing. Try 'port install dpkg'."
-    }
-
     if {[catch {portdpkg::main}] != 0} {
 	return "FAIL: cannot create dmg"
     }

Modified: branches/gsoc13-tests/src/package1.0/tests/portrpm.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portrpm.test	2013-09-02 17:24:31 UTC (rev 110589)
+++ branches/gsoc13-tests/src/package1.0/tests/portrpm.test	2013-09-02 18:16:56 UTC (rev 110590)
@@ -25,8 +25,8 @@
     set mport [mportopen file://.]
     set workername [ditem_key $mport workername]
 
-    set res [$workername eval eval_targets rpm]
-    puts $res
+    #set res [$workername eval eval_targets rpm]
+    #puts $res
 
     #if {![file exists /opt/local/src/macports/RPMS/x86_64/fondu-060102-1.x86_64.rpm]} {}
 

Modified: branches/gsoc13-tests/src/package1.0/tests/portsrpm.test
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/portsrpm.test	2013-09-02 17:24:31 UTC (rev 110589)
+++ branches/gsoc13-tests/src/package1.0/tests/portsrpm.test	2013-09-02 18:16:56 UTC (rev 110590)
@@ -27,10 +27,12 @@
     file mkdir $portdbpath
 
 } -body {
-    set res [portsrpm::srpm_main]
-    puts $res
+    #set res [portsrpm::srpm_main]
 
     return "Srpm pkg successful."
+} -cleanup {
+    file delete -force $workpath
+    file delete -force $portdbpath
 } -result "Srpm pkg successful."
 
 

Added: branches/gsoc13-tests/src/package1.0/tests/test.tcl
===================================================================
--- branches/gsoc13-tests/src/package1.0/tests/test.tcl	                        (rev 0)
+++ branches/gsoc13-tests/src/package1.0/tests/test.tcl	2013-09-02 18:16:56 UTC (rev 110590)
@@ -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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130902/10c87ac4/attachment-0001.html>


More information about the macports-changes mailing list