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

marius at macports.org marius at macports.org
Thu Aug 15 15:38:52 PDT 2013


Revision: 109464
          https://trac.macports.org/changeset/109464
Author:   marius at macports.org
Date:     2013-08-15 15:38:52 -0700 (Thu, 15 Aug 2013)
Log Message:
-----------
macports1.0: added dlist, index and util test

Added Paths:
-----------
    branches/gsoc13-tests/src/macports1.0/tests/macports_dlist.test
    branches/gsoc13-tests/src/macports1.0/tests/macports_index.test
    branches/gsoc13-tests/src/macports1.0/tests/macports_util.test

Added: branches/gsoc13-tests/src/macports1.0/tests/macports_dlist.test
===================================================================
--- branches/gsoc13-tests/src/macports1.0/tests/macports_dlist.test	                        (rev 0)
+++ branches/gsoc13-tests/src/macports1.0/tests/macports_dlist.test	2013-08-15 22:38:52 UTC (rev 109464)
@@ -0,0 +1,203 @@
+package require tcltest 2
+namespace import tcltest::*
+
+package require macports 1.0
+mportinit
+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://.]
+} -body {
+    #puts [ditem_key $mport provides]
+    #dlist_delete $mport provides
+    #puts [ditem_key $mport provides]
+} -cleanup {
+    mportclose $mport
+} -result ""
+
+
+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

Added: branches/gsoc13-tests/src/macports1.0/tests/macports_index.test
===================================================================
--- branches/gsoc13-tests/src/macports1.0/tests/macports_index.test	                        (rev 0)
+++ branches/gsoc13-tests/src/macports1.0/tests/macports_index.test	2013-08-15 22:38:52 UTC (rev 109464)
@@ -0,0 +1,31 @@
+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
+
+
+# test init
+
+
+test get_path {
+    Get path unit test.
+} -body {
+    set macports::portdbpath $pwd/portdbpath
+    set url "http://www.macports.org"
+
+    if {[macports::index::get_path $url] != "${macports::portdbpath}/sources/http.www.macports.org"} {
+	return "FAIL: wrong path"
+    }
+    return "Get path successful."
+} -result "Get path successful."
+
+
+# test sync
+# test search
+# test fetch_port
+
+
+cleanupTests

Added: branches/gsoc13-tests/src/macports1.0/tests/macports_util.test
===================================================================
--- branches/gsoc13-tests/src/macports1.0/tests/macports_util.test	                        (rev 0)
+++ branches/gsoc13-tests/src/macports1.0/tests/macports_util.test	2013-08-15 22:38:52 UTC (rev 109464)
@@ -0,0 +1,150 @@
+package require tcltest 2
+namespace import tcltest::*
+
+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.
+} -body {
+    proc test_proc {arg} {
+	catch {
+	    throw $arg
+	}
+    }
+    if {[test_proc ""] != 1} {
+	return "FAIL: wrong value returned"
+    }
+    #puts [catch {test_proc {7 "msg" "info"}}]
+    return "throw successful."
+} -result "throw successful."
+
+
+test try {
+    Try unit test.
+} -body {
+    #puts [catch {try {return 7} catch * {return 6}}]
+    #puts [catch {try {error "msg" "info" 3} catch * {return 6}}]
+    if {[catch {try}] != 1} {
+	return "FAIL: no args err not detected"
+    }
+    return "try successful."
+} -result "try successful."
+
+
+cleanupTests
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130815/a4463de9/attachment.html>


More information about the macports-changes mailing list