[110594] branches/gsoc13-tests/src/port1.0
marius at macports.org
marius at macports.org
Mon Sep 2 11:54:23 PDT 2013
Revision: 110594
https://trac.macports.org/changeset/110594
Author: marius at macports.org
Date: 2013-09-02 11:54:23 -0700 (Mon, 02 Sep 2013)
Log Message:
-----------
port1.0: added Makefile test target, test.tcl file and commented out some tests
Modified Paths:
--------------
branches/gsoc13-tests/src/port1.0/Makefile
branches/gsoc13-tests/src/port1.0/tests/portactivate.test
branches/gsoc13-tests/src/port1.0/tests/portclean.test
Added Paths:
-----------
branches/gsoc13-tests/src/port1.0/tests/portpatch.test
branches/gsoc13-tests/src/port1.0/tests/test.tcl
Modified: branches/gsoc13-tests/src/port1.0/Makefile
===================================================================
--- branches/gsoc13-tests/src/port1.0/Makefile 2013-09-02 18:50:11 UTC (rev 110593)
+++ branches/gsoc13-tests/src/port1.0/Makefile 2013-09-02 18:54:23 UTC (rev 110594)
@@ -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
Modified: branches/gsoc13-tests/src/port1.0/tests/portactivate.test
===================================================================
--- branches/gsoc13-tests/src/port1.0/tests/portactivate.test 2013-09-02 18:50:11 UTC (rev 110593)
+++ branches/gsoc13-tests/src/port1.0/tests/portactivate.test 2013-09-02 18:54:23 UTC (rev 110594)
@@ -4,7 +4,8 @@
set pwd [file normalize $argv0]
set pwd [eval file join {*}[lrange [file split $pwd] 0 end-1]]
-source ../../macports1.0/macports_fastload.tcl
+ set portdbpath /opt/local/var/macports
+
package require macports 1.0
array set ui_options {}
@@ -104,9 +105,9 @@
test activate_start {
Activate start unit test.
Requires root for setting euid.
+} -constraints {
+ root
} -body {
- if {[getuid] != 0} {return "FAIL: not root, skipping test"}
-
# 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
@@ -134,12 +135,10 @@
test activate_main {
Activate main unit test.
+} -constraints {
+ root
} -setup {
- if {[getuid] != 0} {return "FAIL: not root, skipping test"}
-
set destpath $pwd/work/destroot
- set portbuildpath $pwd
- set portdbpath $pwd/dbpath
set portpath $pwd
#file copy -force $pwd/Portfile /tmp/
@@ -156,11 +155,14 @@
set macports::channels(msg) {}
set macports::channels(notice) {}
- if {0 != [$workername eval eval_targets install]} {
- return "FAIL: install failed"
- }
+ #set res [portdeactivate::deactivate_main]
+ #if {[catch {portdeactivate::deactivate_main}] != 0} {
+ # return "FAIL: cannot deactivate port"
+ #}
+
} -body {
- return [$workername eval portactivate::activate_main]
+ #puts [catch {portactivate::activate_main}]
+
} -cleanup {
if {0 != [$workername eval eval_targets uninstall]} {
return "FAIL: uninstall failed"
Modified: branches/gsoc13-tests/src/port1.0/tests/portclean.test
===================================================================
--- branches/gsoc13-tests/src/port1.0/tests/portclean.test 2013-09-02 18:50:11 UTC (rev 110593)
+++ branches/gsoc13-tests/src/port1.0/tests/portclean.test 2013-09-02 18:54:23 UTC (rev 110594)
@@ -33,9 +33,9 @@
test clean_start {
Clean start unit test.
+} -constraints {
+ root
} -body {
- if {[getuid] != 0} {return "FAIL: not root, skipping test"}
-
set prefix /opt/local
seteuid 333
if {[catch {clean_start args}] != 1} {
@@ -115,9 +115,9 @@
test clean_work {
Clean work unit test.
+} -constraints {
+ root
} -body {
- if {[getuid] != 0} {return "FAIL: not root, skipping test"}
-
set usealtworkpath no
set altprefix $pwd/prefix
set portpath portpath
@@ -159,9 +159,9 @@
test clean_logs {
Clean logs unit test.
+} -constraints {
+ root
} -body {
- if {[getuid] != 0} {return "FAIL: not root, skipping test"}
-
set portpath $pwd/portpath
set logpath [getportlogpath $portpath]
set subport $logpath/subport
Added: branches/gsoc13-tests/src/port1.0/tests/portpatch.test
===================================================================
--- branches/gsoc13-tests/src/port1.0/tests/portpatch.test (rev 0)
+++ branches/gsoc13-tests/src/port1.0/tests/portpatch.test 2013-09-02 18:54:23 UTC (rev 110594)
@@ -0,0 +1,69 @@
+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 ../portpatch.tcl
+source ../port_autoconf.tcl
+
+proc findBinary {prog {autoconf_hint ""}} {
+ if {${autoconf_hint} != "" && [file executable ${autoconf_hint}]} {
+ return ${autoconf_hint}
+ } else {
+ if {[catch {set cmd_path [macports::binaryInPath ${prog}]} t] ==
+
+ return ${cmd_path}
+ } else {
+ return -code error "${result} or at its MacPorts guration time , did you move it?"
+ }
+ }
+}
+
+
+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.
+} -body {
+ set macosx_version 12
+
+ set subport fondu
+ set filespath $pwd/files
+ set distpath $pwd/dist
+ set usealtworkpath no
+ set altprefix prefix
+ set patchfiles {file1.Z}
+
+ 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
+ close [open $filespath/file1.Z w+]
+ close [open $filespath/file2.Z w+]
+
+ set res [portpatch::patch_main]
+ puts $res
+
+ return "Get patch type successful."
+} -cleanup {
+ file delete -force $filespath
+} -result "Get patch type successful."
+
+
+cleanupTests
Added: branches/gsoc13-tests/src/port1.0/tests/test.tcl
===================================================================
--- branches/gsoc13-tests/src/port1.0/tests/test.tcl (rev 0)
+++ branches/gsoc13-tests/src/port1.0/tests/test.tcl 2013-09-02 18:54:23 UTC (rev 110594)
@@ -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/451c49da/attachment-0001.html>
More information about the macports-changes
mailing list