[MacPorts] Tests modified

MacPorts noreply at macports.org
Sun Sep 8 09:57:34 PDT 2013


Page "Tests" was changed by marius at macports.org
Diff URL: <https://trac.macports.org/wiki/Tests?action=diff&version=10>
Revision 10
Comment: added more things; some link will work only after merge
Changes:
-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: Tests
=========================================================================
--- Tests (version: 9)
+++ Tests (version: 10)
@@ -1,30 +1,65 @@
 === Intro ===
 
-The MacPorts testing framework uses [[http://wiki.tcl.tk/1502 | tcltest]] 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. The framework has been developed during GSoC 13 by Marius Coțofană.
+
+To keep things simple, each module of MacPorts ([[https://trac.macports.org/browser/trunk/base/src/macports1.0 | macports1.0]], [[https://trac.macports.org/browser/trunk/base/src/package1.0 | package1.0]], [[https://trac.macports.org/browser/trunk/base/src/port1.0 | port1.0]], [[https://trac.macports.org/browser/trunk/base/src/registry2.0 | registry2.0]]) has it's own 'tests/' directory. Each Tcl script in a module (e.g. [[https://trac.macports.org/browser/trunk/base/src/macports1.0/macports.tcl | macports.tcl]]) has its own test script located in the 'test' directory, with the same name and the '.test' extension (e.g. [[https://trac.macports.org/browser/trunk/base/src/macports1.0/tests/macports.test | macports.test]]). Every proc in a script (e.g. [[https://trac.macports.org/browser/trunk/base/src/macports1.0/macports.tcl#L334 | proc macports::findBinary]]) should have it's own test proc (e.g. [[https://trac.macports.org/browser/trunk/base/src/macports1.0/tests/macports.test#L334 | test findBinary]]) in the corresponding test file. Test procs should maintain the order in the original script and should be independent one of another.
+
 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
+{{{
+make test
+}}}
 
-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.
+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 script just runs the tests individually, printing the test file name, the total number of tests, number of passed, skipped, failed as well as constraints or errors of failed tests. This is one possible output when running macports.test:
+{{{
+Total:31 Passed:31 Failed:00 Skipped:00  macports.test
+}}}
+
+Many tests need root privileges to run correctly, but will be auto skipped in the other case. Constarints are printed just bellow the final result, together with the number of test cases that require it, as so:
+{{{
+Total:31 Passed:24 Failed:00 Skipped:07  macports.test
+    Constraint: 7	root
+}}}
+
+The stack trace of an error that occurs during a test is printed below the constraints (if any).
+
 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 '
+* 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
+{{{
+tclsh macports.test -match mportclose
+}}}
 
-Regression tests can be found in ' trunk/base/tests/ ' and can be  run just as unit tests.
+Regression tests can be found in [[https://trac.macports.org/browser/trunk/base/tests/test | trunk/base/tests/test]] and can be  run just as unit tests, using 'make test' from the parent directory.
 
 
 === Must know ===
 
-* regression tests have their own directory, found in ' trunk/base/tests/ '
+* the tests can be run only on an installed version of Macports ( so make sure you have run 'sudo make install' )
+* regression tests have their own directory, found in [[https://trac.macports.org/browser/trunk/base/tests/test | trunk/base/tests/test]]
 * 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
@@ -38,12 +73,16 @@
 
 {{{
 # include required tcltest package and set namespace
-package require tcltest 2
+'''package require tcltest 2'''
 namespace import tcltest::*
 
 # get absolute path to current ‘tests/’ directory
 set pwd [file normalize $argv0]
 set pwd [eval file join {*}[lrange [file split $pwd] 0 end-1]]
+
+# the macports_fastload.tcl file needs to be sourced so we
+# can directly require packages later on
+source ../../macports1.0/macports_fastload.tcl
 
 # debug options
 # ports_debug and ports_verbose are commented out as default
-------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