Page "Tests" was changed by marius@macports.org Diff URL: <https://trac.macports.org/wiki/Tests?action=diff&version=6> Revision 6 Changes: -------8<------8<------8<------8<------8<------8<------8<------8<-------- Index: Tests ========================================================================= --- Tests (version: 5) +++ Tests (version: 6) @@ -1,16 +1,37 @@ === Intro === The MacPorts testing framework uses tcltest ![0] for its unit tests as well as regression tests. -Maintainer: marius@macports.org +Maintainer: marius [at] macports.org + +=== Running tests === + +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. +The file can be used also to: +* 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 ' +* print help message: ' tclsh test.tcl -h ' + +Specific test cases can be run using the '-match' argument for the file that contains the test, from its parent directory. +* tclsh macports.test -match mportclose + +Regression tests can be found in ' trunk/base/tests/ ' and can be run just as unit tests. === 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 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 * each test must clan all auxiliary files or directories it creates and revert all port it installs +* use a single test proceduce for each tested proc; sub-test cases should be included in the same body +* when adding new regression tests, make sure to specify its name in the test_suite list of ' trunk/base/tests/test.tcl ' === Sample file === @@ -48,6 +69,9 @@ # or the partial cases it tests test mportclose { Mport close unit test. +# this branch is optional and you can use other constraints too +} -constraints { + root # the setup branch is optional } -setup { set mport [mportopen file://.] @@ -68,9 +92,3 @@ cleanupTests }}} - -=== Resources === - -![0] - [[http://wiki.tcl.tk/1502 | Tcltest official wiki page]]\\ -![1] - [[http://web.archive.org/web/20080617153002/www.tclscripting.com/articles/apr0... | Getting started with tcltest]]\\ -![2] - [[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 .