Index: devdoc/parts/d_installation.inc ================================================================== --- devdoc/parts/d_installation.inc +++ devdoc/parts/d_installation.inc @@ -0,0 +1,95 @@ +A last thing to consider when adding a new package to the collection +is installation. + +[para] How to [emph use] the tool, the [file installer.tcl] script is +doumented in +[term {Tcllib - The Installer's Guide}]. + +[para] Here we document how to extend the installer so that it may +install the new package(s). + +[para] In most cases only a single file has to be modified, +[file support/installation/modules.tcl] holding one command per module +and application to install. + +[para] The commands are: + +[list_begin definitions] + +[call [cmd Module] [arg name] \ + [arg code-action] \ + [arg doc-action] \ + [arg example-action]] + +Install the packages of module [arg name], found in +[file modules/[arg name]]. + +[para] The [arg code-action] is responsible for installing the +packages and their index. The system currently provides + +[list_begin definitions] + +[def [cmd _tcl]] Copy all [file .tcl] files found in +[file modules/[arg name]] into the installation. + +[def [cmd _tcr]] As [cmd _tcl], copy the [file .tcl] files found in +the subdirectories of [file modules/[arg name]] as well. + +[def [cmd _tci]] As [cmd _tcl], and copy the [file tclIndex.tcl] file +as well. + +[def [cmd _msg]] As [cmd _tcl], and copy the subdirectory [file msgs] +as well. + +[def [cmd _doc]] As [cmd _tcl], and copy the subdirectory +[file mpformats] as well. + +[def [cmd _tex]] As [cmd _tcl], and copy [file .tex] files as well. + +[list_end] + +[para] The [arg doc-action] is responsible for installing the package +documentation. The system currently provides + +[list_begin definitions] +[def [cmd _null]] No documentation available, do nothing. + +[def [cmd _man]] Process the [file .man] files found in +[file modules/[arg name]] and install the results (nroff and/or HTML) +in the proper location, as given to the installer. + +[para] This is actually a fallback, normally the installer uses the +pre-made formatted documentation found under [file idoc]. + +[list_end] + +[para] The [arg example-action] is responsible for installing the +examples. The system currently provides + +[list_begin definitions] +[def [cmd _null]] No examples available, do nothing. + +[def [cmd _exa]] Copy the the directory [file examples/[arg name]] +recursively to the install location for examples. + +[list_end] + +[call [cmd Application] [arg name]] + +Install the application with [arg name], found in [file apps]. + + +[call [cmd Exclude] [arg name]] + +This command signals to the installer which of the listed modules to +[emph not] install. I.e. they name the deprecated modules of Tcllib. + +[list_end] + +[para] If, and only if the above actions are not suitable for the new +module then a second file has to be modified, +[file support/installation/actions.tcl]. + +[para] This file contains the implementations of the available +actions, and is the place where any custom action needed to handle the +special circumstances of module has to be added. Index: devdoc/parts/d_testwrite.inc ================================================================== --- devdoc/parts/d_testwrite.inc +++ devdoc/parts/d_testwrite.inc @@ -0,0 +1,115 @@ + +While previous sections talked about running the testsuites for a +module and the packages therein this has no meaning if the module in +question has no testsuites at all. + +[para] This section gives a very basic overview on possible +methodologies for writing tests and testsuites. + +[para] First there are "drudgery" tests. Written to check absolutely +basic assumptions which should never fail. + +[para] For example for a command FOO taking two arguments, three tests +calling it with zero, one, and three arguments. The basic checks that +the command fails if it has not enough arguments, or too many. + +[para] After that come the tests checking things based on our +knowledge of the command, about its properties and assumptions. Some +examples based on the graph operations added during Google's Summer of +Code 2009 are: + +[list_begin itemized] + +[item] The BellmanFord command in struct::graph::ops takes a + [arg startnode] as argument, and this node should be a node of + the graph. Equals one test case checking the behavior when the + specified node is not a node a graph. + +[para] This often gives rise to code in the implementation which + explicitly checks the assumption and throws a nice error. + Instead of letting the algorithm fails later in some weird + non-deterministic way. + +[para] It not always possible to do such checks. The graph argument + for example is just a command in itself, and while we expect + it to exhibit a certain interface, i.e. a set of sub-commands + aka methods, we cannot check that it has them, except by + actually trying to use them. That is done by the algorithm + anyway, so an explicit check is just overhead we can get by + without. + +[item] IIRC one of the distinguishing characteristic of either + BellmanFord and/or Johnson is that they are able to handle + negative weights. Whereas Dijkstra requires positive weights. + +[para] This induces (at least) three testcases ... Graph with all + positive weights, all negative, and a mix of positive and + negative weights. + + Thinking further does the algorithm handle the weight + [const 0] as well ? Another test case, or several, if we mix + zero with positive and negative weights. + +[item] The two algorithms we are currently thinking about are about + distances between nodes, and distance can be 'Inf'inity, + i.e. nodes may not be connected. This means that good test + cases are + + [list_begin enumerated] + [enum] Strongly connected graph + [enum] Connected graph + [enum] Disconnected graph. + [list_end] + + [para] At the extremes of strongly connected and disconnected + we have the fully connected graphs and graphs without edges, + only nodes, i.e. completely disconnected. + +[item] IIRC both of the algorithms take weighted arcs, and fill in a + default if arcs are left unweighted in the input graph. + + [para] This also induces three test cases: + + [list_begin enumerated] + [enum] Graph will all arcs with explicit weights. + [enum] Graph without weights at all. + [enum] Graph with mixture of weighted and unweighted graphs. + [list_end] +[list_end] + +[para] What was described above via examples is called +[term black-box] testing. Test cases are designed and written based on +the developer's knowledge of the properties of the algorithm and its +inputs, without referencing a particular implementation. + +[para] Going further, a complement to [term black-box] testing is +[term white-box]. For this we know the implementation of the +algorithm, we look at it and design our tests cases so that they force +the code through all possible paths in the implementation. Wherever a +decision is made we have a test case forcing a specific direction of +the decision, for all possible combinations and directions. It is easy +to get a combinatorial explosion in the number of needed test-cases. + +[para] In practice I often hope that the black-box tests I have made +are enough to cover all the paths, obviating the need for white-box +tests. + +[para] The above should be enough to make it clear that writing tests +for an algorithm takes at least as much time as coding the algorithm, +and often more time. Much more time. + +See for example also [uri http://sqlite.org/testing.html], a writeup +on how the Sqlite database engine is tested. + +[para] An interesting connection is to documentation. In one +direction, the properties checked with black-box testing are exactly +the properties which should be documented in the algorithm's man +page. And conversely, the documentation of the properties of an +algorithm makes a good reference to base the black-box tests on. + +[para] In practice test cases and documentation often get written +together, cross-influencing each other. And the actual writing of test +cases is a mix of black and white box, possibly influencing the +implementation while writing the tests. Like writing a test for a +condition like [term {startnode not in input graph}] serving as +reminder to put a check for this condition into the code. Index: devdoc/tcllib_devguide.man ================================================================== --- devdoc/tcllib_devguide.man +++ devdoc/tcllib_devguide.man @@ -45,18 +45,18 @@ [section {Testsuite Tooling}] [include parts/d_testing.inc] [comment {===================================================================}] [section {Documentation Tooling}] -[include parts/d_documentation.inc]x +[include parts/d_documentation.inc] [comment {===================================================================}] [section {Notes On Writing A Testsuite}] -[include parts/d_testwrite.inc]x +[include parts/d_testwrite.inc] [comment {===================================================================}] [section {Installation Tooling}] -[include parts/d_installation.inc]x +[include parts/d_installation.inc] [comment {===================================================================}] [manpage_end] Index: embedded/www/tcllib/files/devdoc/tcllib_devguide.html ================================================================== --- embedded/www/tcllib/files/devdoc/tcllib_devguide.html +++ embedded/www/tcllib/files/devdoc/tcllib_devguide.html @@ -104,10 +104,11 @@
tcllib_devguide - Tcllib - The Developer's Guide
Welcome to Tcllib, the Tcl Standard Library. Note that Tcllib is not a package itself. It is a collection of (semi-independent) Tcl packages that provide utility functions useful to a large collection @@ -455,16 +465,175 @@
Invoke it as either
./sak.tcl doc validate (modules/)FOO
or
./sak.tcl doc validate
to either check the packages of a specific module or check all of -them. -x
+them.x
+While previous sections talked about running the testsuites for a +module and the packages therein this has no meaning if the module in +question has no testsuites at all.
+This section gives a very basic overview on possible +methodologies for writing tests and testsuites.
+First there are "drudgery" tests. Written to check absolutely +basic assumptions which should never fail.
+For example for a command FOO taking two arguments, three tests +calling it with zero, one, and three arguments. The basic checks that +the command fails if it has not enough arguments, or too many.
+After that come the tests checking things based on our +knowledge of the command, about its properties and assumptions. Some +examples based on the graph operations added during Google's Summer of +Code 2009 are:
+The BellmanFord command in struct::graph::ops takes a + startnode as argument, and this node should be a node of + the graph. Equals one test case checking the behavior when the + specified node is not a node a graph.
+This often gives rise to code in the implementation which + explicitly checks the assumption and throws a nice error. + Instead of letting the algorithm fails later in some weird + non-deterministic way.
+It not always possible to do such checks. The graph argument + for example is just a command in itself, and while we expect + it to exhibit a certain interface, i.e. a set of sub-commands + aka methods, we cannot check that it has them, except by + actually trying to use them. That is done by the algorithm + anyway, so an explicit check is just overhead we can get by + without.
IIRC one of the distinguishing characteristic of either + BellmanFord and/or Johnson is that they are able to handle + negative weights. Whereas Dijkstra requires positive weights.
+This induces (at least) three testcases ... Graph with all + positive weights, all negative, and a mix of positive and + negative weights. + Thinking further does the algorithm handle the weight + 0 as well ? Another test case, or several, if we mix + zero with positive and negative weights.
The two algorithms we are currently thinking about are about + distances between nodes, and distance can be 'Inf'inity, + i.e. nodes may not be connected. This means that good test + cases are
+Strongly connected graph
Connected graph
Disconnected graph.
At the extremes of strongly connected and disconnected + we have the fully connected graphs and graphs without edges, + only nodes, i.e. completely disconnected.
IIRC both of the algorithms take weighted arcs, and fill in a + default if arcs are left unweighted in the input graph.
+This also induces three test cases:
+Graph will all arcs with explicit weights.
Graph without weights at all.
Graph with mixture of weighted and unweighted graphs.
What was described above via examples is called +black-box testing. Test cases are designed and written based on +the developer's knowledge of the properties of the algorithm and its +inputs, without referencing a particular implementation.
+Going further, a complement to black-box testing is +white-box. For this we know the implementation of the +algorithm, we look at it and design our tests cases so that they force +the code through all possible paths in the implementation. Wherever a +decision is made we have a test case forcing a specific direction of +the decision, for all possible combinations and directions. It is easy +to get a combinatorial explosion in the number of needed test-cases.
+In practice I often hope that the black-box tests I have made +are enough to cover all the paths, obviating the need for white-box +tests.
+The above should be enough to make it clear that writing tests +for an algorithm takes at least as much time as coding the algorithm, +and often more time. Much more time. +See for example also http://sqlite.org/testing.html, a writeup +on how the Sqlite database engine is tested.
+An interesting connection is to documentation. In one +direction, the properties checked with black-box testing are exactly +the properties which should be documented in the algorithm's man +page. And conversely, the documentation of the properties of an +algorithm makes a good reference to base the black-box tests on.
+In practice test cases and documentation often get written +together, cross-influencing each other. And the actual writing of test +cases is a mix of black and white box, possibly influencing the +implementation while writing the tests. Like writing a test for a +condition like startnode not in input graph serving as +reminder to put a check for this condition into the code.
x
+A last thing to consider when adding a new package to the collection +is installation.
+How to use the tool, the "installer.tcl" script is +doumented in +Tcllib - The Installer's Guide.
+Here we document how to extend the installer so that it may +install the new package(s).
+In most cases only a single file has to be modified, +"support/installation/modules.tcl" holding one command per module +and application to install.
+The commands are:
+Install the packages of module name, found in +"modules/name".
+The code-action is responsible for installing the +packages and their index. The system currently provides
+Copy all ".tcl" files found in +"modules/name" into the installation.
As _tcl, copy the ".tcl" files found in +the subdirectories of "modules/name" as well.
As _tcl, and copy the "tclIndex.tcl" file +as well.
As _tcl, and copy the subdirectory "msgs" +as well.
As _tcl, and copy the subdirectory +"mpformats" as well.
As _tcl, and copy ".tex" files as well.
The doc-action is responsible for installing the package +documentation. The system currently provides
+No documentation available, do nothing.
Process the ".man" files found in +"modules/name" and install the results (nroff and/or HTML) +in the proper location, as given to the installer.
+This is actually a fallback, normally the installer uses the +pre-made formatted documentation found under "idoc".
The example-action is responsible for installing the +examples. The system currently provides
+No examples available, do nothing.
Copy the the directory "examples/name" +recursively to the install location for examples.
Install the application with name, found in "apps".
This command signals to the installer which of the listed modules to +not install. I.e. they name the deprecated modules of Tcllib.
If, and only if the above actions are not suitable for the new +module then a second file has to be modified, +"support/installation/actions.tcl".
+This file contains the implementations of the available +actions, and is the place where any custom action needed to handle the +special circumstances of module has to be added.
tcllib_devguide - Tcllib - The Developer's Guide
Welcome to Tcllib, the Tcl Standard Library. Note that Tcllib is not a package itself. It is a collection of (semi-independent) Tcl packages that provide utility functions useful to a large collection @@ -462,16 +472,175 @@
Invoke it as either
./sak.tcl doc validate (modules/)FOO
or
./sak.tcl doc validate
to either check the packages of a specific module or check all of -them. -x
+them.x
+While previous sections talked about running the testsuites for a +module and the packages therein this has no meaning if the module in +question has no testsuites at all.
+This section gives a very basic overview on possible +methodologies for writing tests and testsuites.
+First there are "drudgery" tests. Written to check absolutely +basic assumptions which should never fail.
+For example for a command FOO taking two arguments, three tests +calling it with zero, one, and three arguments. The basic checks that +the command fails if it has not enough arguments, or too many.
+After that come the tests checking things based on our +knowledge of the command, about its properties and assumptions. Some +examples based on the graph operations added during Google's Summer of +Code 2009 are:
+The BellmanFord command in struct::graph::ops takes a + startnode as argument, and this node should be a node of + the graph. Equals one test case checking the behavior when the + specified node is not a node a graph.
+This often gives rise to code in the implementation which + explicitly checks the assumption and throws a nice error. + Instead of letting the algorithm fails later in some weird + non-deterministic way.
+It not always possible to do such checks. The graph argument + for example is just a command in itself, and while we expect + it to exhibit a certain interface, i.e. a set of sub-commands + aka methods, we cannot check that it has them, except by + actually trying to use them. That is done by the algorithm + anyway, so an explicit check is just overhead we can get by + without.
IIRC one of the distinguishing characteristic of either + BellmanFord and/or Johnson is that they are able to handle + negative weights. Whereas Dijkstra requires positive weights.
+This induces (at least) three testcases ... Graph with all + positive weights, all negative, and a mix of positive and + negative weights. + Thinking further does the algorithm handle the weight + 0 as well ? Another test case, or several, if we mix + zero with positive and negative weights.
The two algorithms we are currently thinking about are about + distances between nodes, and distance can be 'Inf'inity, + i.e. nodes may not be connected. This means that good test + cases are
+Strongly connected graph
Connected graph
Disconnected graph.
At the extremes of strongly connected and disconnected + we have the fully connected graphs and graphs without edges, + only nodes, i.e. completely disconnected.
IIRC both of the algorithms take weighted arcs, and fill in a + default if arcs are left unweighted in the input graph.
+This also induces three test cases:
+Graph will all arcs with explicit weights.
Graph without weights at all.
Graph with mixture of weighted and unweighted graphs.
What was described above via examples is called +black-box testing. Test cases are designed and written based on +the developer's knowledge of the properties of the algorithm and its +inputs, without referencing a particular implementation.
+Going further, a complement to black-box testing is +white-box. For this we know the implementation of the +algorithm, we look at it and design our tests cases so that they force +the code through all possible paths in the implementation. Wherever a +decision is made we have a test case forcing a specific direction of +the decision, for all possible combinations and directions. It is easy +to get a combinatorial explosion in the number of needed test-cases.
+In practice I often hope that the black-box tests I have made +are enough to cover all the paths, obviating the need for white-box +tests.
+The above should be enough to make it clear that writing tests +for an algorithm takes at least as much time as coding the algorithm, +and often more time. Much more time. +See for example also http://sqlite.org/testing.html, a writeup +on how the Sqlite database engine is tested.
+An interesting connection is to documentation. In one +direction, the properties checked with black-box testing are exactly +the properties which should be documented in the algorithm's man +page. And conversely, the documentation of the properties of an +algorithm makes a good reference to base the black-box tests on.
+In practice test cases and documentation often get written +together, cross-influencing each other. And the actual writing of test +cases is a mix of black and white box, possibly influencing the +implementation while writing the tests. Like writing a test for a +condition like startnode not in input graph serving as +reminder to put a check for this condition into the code.
x
+A last thing to consider when adding a new package to the collection +is installation.
+How to use the tool, the "installer.tcl" script is +doumented in +Tcllib - The Installer's Guide.
+Here we document how to extend the installer so that it may +install the new package(s).
+In most cases only a single file has to be modified, +"support/installation/modules.tcl" holding one command per module +and application to install.
+The commands are:
+Install the packages of module name, found in +"modules/name".
+The code-action is responsible for installing the +packages and their index. The system currently provides
+Copy all ".tcl" files found in +"modules/name" into the installation.
As _tcl, copy the ".tcl" files found in +the subdirectories of "modules/name" as well.
As _tcl, and copy the "tclIndex.tcl" file +as well.
As _tcl, and copy the subdirectory "msgs" +as well.
As _tcl, and copy the subdirectory +"mpformats" as well.
As _tcl, and copy ".tex" files as well.
The doc-action is responsible for installing the package +documentation. The system currently provides
+No documentation available, do nothing.
Process the ".man" files found in +"modules/name" and install the results (nroff and/or HTML) +in the proper location, as given to the installer.
+This is actually a fallback, normally the installer uses the +pre-made formatted documentation found under "idoc".
The example-action is responsible for installing the +examples. The system currently provides
+No examples available, do nothing.
Copy the the directory "examples/name" +recursively to the install location for examples.
Install the application with name, found in "apps".
This command signals to the installer which of the listed modules to +not install. I.e. they name the deprecated modules of Tcllib.
If, and only if the above actions are not suitable for the new +module then a second file has to be modified, +"support/installation/actions.tcl".
+This file contains the implementations of the available +actions, and is the place where any custom action needed to handle the +special circumstances of module has to be added.