[107291] branches/gsoc13-tests/tests/test
marius at macports.org
marius at macports.org
Tue Jun 25 04:06:01 PDT 2013
Revision: 107291
https://trac.macports.org/changeset/107291
Author: marius at macports.org
Date: 2013-06-25 04:06:01 -0700 (Tue, 25 Jun 2013)
Log Message:
-----------
Added initial setup for checksum test and library file.
Modified Paths:
--------------
branches/gsoc13-tests/tests/test/checksums-1/checksum.tcl
branches/gsoc13-tests/tests/test/checksums-1/test_checksum.tcl
Added Paths:
-----------
branches/gsoc13-tests/tests/test/library.tcl
Modified: branches/gsoc13-tests/tests/test/checksums-1/checksum.tcl
===================================================================
--- branches/gsoc13-tests/tests/test/checksums-1/checksum.tcl 2013-06-25 10:24:43 UTC (rev 107290)
+++ branches/gsoc13-tests/tests/test/checksums-1/checksum.tcl 2013-06-25 11:06:01 UTC (rev 107291)
@@ -1,64 +1,7 @@
set autoconf "../../../Mk/macports.autoconf.mk"
-# Sets $bindir variable from macports.autoconf.mk
-# autogenerated file.
-proc load_variables {} {
- global autoconf
- global bindir
+source ../library.tcl
- if { [file exists $autoconf] == 0 } {
- puts "$autoconf does not exist."
- exit 1
- }
-
- 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/
-}
-
-# Executes port clean.
-proc clean {} {
- global bindir
-
- set args "clean"
- set cmd "port"
-
- set result [eval exec $bindir$cmd $args]]
-}
-
-# Runs the portfile.
-proc run {} {
- global bindir
-
- set args "-d test"
- set output "output"
- set cmd "port"
-
- set result [catch {eval exec $bindir$cmd $args >&output} ]
- return $result
-}
-
-# 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 first $lookup $line 0] != -1} {
- close $fp
- return $line
- }
- }
- return -1
-}
-
-
proc get_md5 {filename} {
set md5 "debug: calculated (md5)"
Modified: branches/gsoc13-tests/tests/test/checksums-1/test_checksum.tcl
===================================================================
--- branches/gsoc13-tests/tests/test/checksums-1/test_checksum.tcl 2013-06-25 10:24:43 UTC (rev 107290)
+++ branches/gsoc13-tests/tests/test/checksums-1/test_checksum.tcl 2013-06-25 11:06:01 UTC (rev 107291)
@@ -1,21 +1,21 @@
package require tcltest 2
namespace import tcltest::*
-source checksum.tcl
+source ./checksum.tcl
set file "output"
set dir "work"
+# Initial setup
+load_variables
+port_clean
+port_run
+
+
test md5_checksum {
Regression test for MD5 Checksum.
} -constraints {
root
-} -setup {
- if { [file exists $file] == 0 } {
- load_variables
- clean
- run
- }
} -body {
get_md5 $file
} -result "d41d8cd98f00b204e9800998ecf8427e"
@@ -25,12 +25,6 @@
Regression test for SHA1 Checksum.
} -constraints {
root
-} -setup {
- if { [file exists $file] == 0 } {
- load_variables
- clean
- run
- }
} -body {
get_sha $file
} -result "da39a3ee5e6b4b0d3255bfef95601890afd80709"
@@ -40,12 +34,6 @@
Regression test for RMD160 Checksum.
} -constraints {
root
-} -setup {
- if { [file exists $file] == 0 } {
- load_variables
- clean
- run
- }
} -body {
get_rmd $file
} -result "9c1185a5c5e9fc54612808977ee8f548b2258d31"
@@ -54,4 +42,5 @@
# remove output file and print results
removeFile $file
removeDirectory $dir
+
cleanupTests
Added: branches/gsoc13-tests/tests/test/library.tcl
===================================================================
--- branches/gsoc13-tests/tests/test/library.tcl (rev 0)
+++ branches/gsoc13-tests/tests/test/library.tcl 2013-06-25 11:06:01 UTC (rev 107291)
@@ -0,0 +1,59 @@
+# Set of procs used for testing.
+
+# Sets $bindir variable from macports.autoconf.mk
+# autogenerated file.
+proc load_variables {} {
+ global autoconf
+ global bindir
+
+ if { [file exists $autoconf] == 0 } {
+ puts "$autoconf does not exist."
+ exit 1
+ }
+
+ 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/
+}
+
+# Executes port clean.
+proc port_clean {} {
+ global bindir
+
+ set args "clean"
+ set cmd "port"
+
+ set result [eval exec $bindir$cmd $args]]
+}
+
+# Runs the portfile.
+proc port_run {} {
+ global bindir
+
+ set args "-d test"
+ set output "output"
+ set cmd "port"
+
+ set result [catch {eval exec $bindir$cmd $args >&output} ]
+ return $result
+}
+
+# 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 first $lookup $line 0] != -1} {
+ close $fp
+ return $line
+ }
+ }
+ return -1
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130625/a9f65b91/attachment.html>
More information about the macports-changes
mailing list