[MacPorts] Tests modified

MacPorts noreply at macports.org
Mon Sep 2 10:00:00 PDT 2013


Page "Tests" was changed by marius at macports.org
Diff URL: <https://trac.macports.org/wiki/Tests?action=diff&version=9>
Revision 9
Comment: more improvements
Changes:
-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: Tests
=========================================================================
--- Tests (version: 8)
+++ Tests (version: 9)
@@ -1,6 +1,6 @@
 === Intro ===
 
-The MacPorts testing framework uses tcltest ![0] for its unit tests as well as regression tests.
+The MacPorts testing framework uses [[http://wiki.tcl.tk/1502 | tcltest]] for its unit tests as well as regression tests.
 Maintainer: marius [at] macports.org
 
 === Running tests ===
@@ -8,9 +8,9 @@
 The easiest way to run all the tests, is to use the target in the Makefile.
 * make test
 
-Each 'tests/' directory has a 'test.tcl' file, used by the make target to run all tests and format the output, making it easy to read.
+Each 'tests/' directory has a [[https://trac.macports.org/browser/branches/gsoc13-tests/src/macports1.0/tests/test.tcl | test.tcl]] file, used by the make target to run all tests and format the output, making it easy to read.
 The file can be used also to:
-* run all tests:                    ' tclsh test.tcl '
+* run all tests:                ' tclsh test.tcl '
 * get debug info:               ' tclsh test.tcl -debug \[0-3\] '
 * list individual test files:   ' tclsh test.tcl -l '
 * run specific test files:      ' tclsh test.tcl -t macports.test '
@@ -25,7 +25,7 @@
 === Must know ===
 
 * regression tests have their own directory, found in ' trunk/base/tests/ '
-* each module of MacPorts (port1.0, macports1.0, package1.0) has its own ‘tests/’ directory where the test files are located and also additional files needed (Portfile, test.tcl)
+* each module of MacPorts (port1.0, macports1.0, package1.0) has its own ‘tests/’ directory where the test files are located and also additional files needed ([[https://trac.macports.org/browser/branches/gsoc13-tests/src/macports1.0/tests/Portfile | Portfile]], [[https://trac.macports.org/browser/branches/gsoc13-tests/src/macports1.0/tests/test.tcl | test.tcl]])
 * each file in a module has a corresponding test file (.test extension) in the ‘tests/’ directory
 * each proc in a file has a corresponding test case (test proc_name) in the
 * each test case must be independent from each other, so they can be run individually if needed
@@ -54,13 +54,33 @@
 mportinit ui_options
 
 # source/require tested/needed files
-source ../../port1.0/portutil.tcl
+# source ../../port1.0/portutil.tcl
+package require portutil 1.0
 
-# additional procs needed for testing
-proc registry_exists {name version {revision 0} {variants ""}} {
-        global macports::registry.format
-        return [${macports::registry.format}::entry_exists $name $version $revision $variants]
-}
+# use custom macports.conf and sources.conf
+# you need to provide the sources.conf (see additional files) file
+makeDirectory $pwd/tmpdir
+makeDirectory $pwd/tmpdir/share
+makeDirectory $pwd/tmpdir/var/macports/registry
+set fd [open $pwd/tmpdir/macports.conf w+]
+puts $fd "portdbpath $pwd/tmpdir/var/macports"
+puts $fd "prefix $pwd/tmpdir"
+puts $fd "variants_conf $pwd/tmpdir/variants.conf"
+puts $fd "sources_conf $pwd/sources.conf"
+puts $fd "applications_dir $pwd/tmpdir/Applications"
+puts $fd "frameworks_dir $pwd/tmpdir/Library/Frameworks"
+close $fd
+set env(PORTSRC) $pwd/tmpdir/macports.conf
+file link -symbolic $pwd/tmpdir/share/macports $macports::autoconf::prefix/share/macports
+close [open $pwd/tmpdir/variants.conf w+]
+
+# if you need to use procs from macports namespace, that are just aliases, you can
+# always source library.tcl (see additional files) which provides a copy macports::worker_init
+# without sub-interpreters; it also sets some important environment variables like
+# os.platform, os.major, os.arch, workpath, destpath, portpath
+# some other option would be to get the $workername from a $mport and use it directly
+
+# additional procs needed for testing go before the actual test cases
 
 
 # test case example
@@ -105,6 +125,6 @@
 
 === Resources ===
 
-![0] - [[http://wiki.tcl.tk/1502 | Tcltest official wiki page]]\\
-![1] - [[http://web.archive.org/web/20080617153002/www.tclscripting.com/articles/apr06/article1.html | Getting started with tcltest]]\\
-![2] - [[http://www.tcl.tk/man/tcl8.5/TclCmd/tcltest.htm | Official tcltest documentation]]\\
+* [[http://wiki.tcl.tk/1502 | Tcltest official wiki page]]\\
+* [[http://web.archive.org/web/20080617153002/www.tclscripting.com/articles/apr06/article1.html | Getting started with tcltest]]\\
+* [[http://www.tcl.tk/man/tcl8.5/TclCmd/tcltest.htm | Official tcltest documentation]]\\
-------8<------8<------8<------8<------8<------8<------8<------8<--------

--
Page URL: <https://trac.macports.org/wiki/Tests>
MacPorts <http://www.macports.org/>
Ports system for OS X

This is an automated message. Someone added your email address to be
notified of changes on 'Tests' page.
If it was not you, please report to .


More information about the macports-changes mailing list