From b33a1c7526696585e43f4f6d23b1d0d88d176b99 Mon Sep 17 00:00:00 2001 From: Freddy Vulto Date: Wed, 15 Apr 2009 22:19:26 +0200 Subject: [PATCH] Added asciidoc files. --- doc/main.txt | 10 +++ doc/main.xml | 151 +++++++++++++++++++++++++++++++++++++++++++++ doc/makeHtml.sh | 4 ++ doc/styleguide.txt | 36 +++++++++++ doc/testing.txt | 115 ++++++++++++++++++++++++++++++++++ 5 files changed, 316 insertions(+) create mode 100644 doc/main.txt create mode 100644 doc/main.xml create mode 100755 doc/makeHtml.sh create mode 100644 doc/styleguide.txt create mode 100644 doc/testing.txt diff --git a/doc/main.txt b/doc/main.txt new file mode 100644 index 00000000..d9acde5c --- /dev/null +++ b/doc/main.txt @@ -0,0 +1,10 @@ +Bash-completion +=============== +Freddy Vulto (FVu) +v1.0, Mar 2009 + +// include::intro.txt[] +// include::bash_completion.txt[] + +include::styleguide.txt[] +include::testing.txt[] diff --git a/doc/main.xml b/doc/main.xml new file mode 100644 index 00000000..ddf324a0 --- /dev/null +++ b/doc/main.xml @@ -0,0 +1,151 @@ + + + + + + Bash-completion + Mar 2009 + + Freddy + Vulto + (FVu) + + FV( + +1.0Mar 2009FV( + + + +Preface + + +Coding Style Guide +This document attempts to explain the basic styles and patterns that are used in the bash completion. New code should try to conform to these standards so that it is as easy to maintain as existing code. Of course every rule has an exception, but it's important to know the rules nonetheless! + +This is particularly directed at people new to the bash completion codebase, who are in the process of getting their code reviewed. Before getting a review, please read over this document and make sure your code conforms to the recommendations here. + + + +Automated testing + +Introduction +The bash-completion package contains an automated test suite. Running the tests should help verifying that bash-completion works as expected. The tests are also very helpful in uncovering software regressions at an early stage. + +The bash-completion test suite is written on top of the DejaGnu testing framework. DejaGnu is written in Expect, which in turn uses Tcl — Tool command language. + + + +Installing DejaGnu +Installing DejaGnu should be easy using your local package manager. + +
+Debian/Ubuntu +On Debian/Ubuntu you can use apt-get: + +sudo apt-get install dejagnu +This should also install the necessary expect and tcl packages. + +
+
+ +Structure +
+Main areas (DejaGnu tools) +The tests are grouped into different areas, called tool in DejaGnu: + + + + +install + + + + Functional tests for installation and caching of the main bash-completion package. + + + + + +completion + + + + Functional tests per completion. + + + + + +unit + + + + Unit tests for bash-completion helper functions. + + + + +
+
+Running the tests +The tests are run by calling runtest in the test directory: + +runtest --outdir=log --tool completion +runtest --outdir=log --tool install +runtest --outdir=log --tool unit +The commands above are already wrapped up in shell scripts within the test directory: + +./runCompletion +./runInstall +./runUnit +
+
+ +Maintenance +
+Adding a completion test +You can add script/generate to add a test. + +
+
+ +Rationale +
+Naming conventions +
+Test suite or testsuite +The primary Wikipedia page is called +test suite and not testsuite, so that's what this +document sticks to. + +
+
+script/generate +The name and location of this code generation script come from Ruby on Rails' script/generate. + +
+
+
+ +Reference +Within test scripts the following library functions can be used: + + + +The test environment +The tests run in a specially prepared bash environment. The following files are used: + bashrch + inputrc +* fixtures + +
+bashrc +Contents of bashrc: + +
+
+
+ +Index + +
diff --git a/doc/makeHtml.sh b/doc/makeHtml.sh new file mode 100755 index 00000000..8e52eff3 --- /dev/null +++ b/doc/makeHtml.sh @@ -0,0 +1,4 @@ +#!/bin/bash -eu + +[ -d html~ ] || mkdir html~ +a2x -D html~ -d book -f xhtml main.txt diff --git a/doc/styleguide.txt b/doc/styleguide.txt new file mode 100644 index 00000000..7dd7c204 --- /dev/null +++ b/doc/styleguide.txt @@ -0,0 +1,36 @@ +Coding Style Guide +================== + +This document attempts to explain the basic styles and patterns that are used in the bash completion. New code should try to conform to these standards so that it is as easy to maintain as existing code. Of course every rule has an exception, but it's important to know the rules nonetheless! + +This is particularly directed at people new to the bash completion codebase, who are in the process of getting their code reviewed. Before getting a review, please read over this document and make sure your code conforms to the recommendations here. + +///////////////////////////////////////// +case/esac vs if +--------------- + +simple matching vs extended globbing +------------------------------------ +in case statements: -@(a|b)) vs -a|-b) + +[[ ]] vs [ ] +------------ + +indentation +----------- + +line wrapping +------------- + +quoting +------- + +awk vs cut for simple cases +--------------------------- + +$(...) vs `...` +--------------- + +variable and function naming +---------------------------- +///////////////////////////////////////// diff --git a/doc/testing.txt b/doc/testing.txt new file mode 100644 index 00000000..65579fd9 --- /dev/null +++ b/doc/testing.txt @@ -0,0 +1,115 @@ +Automated testing +================= + +Introduction +------------ +The bash-completion package contains an automated test suite. Running the tests should help verifying that bash-completion works as expected. The tests are also very helpful in uncovering software regressions at an early stage. + +The bash-completion test suite is written on top of the http://www.gnu.org/software/dejagnu/[DejaGnu] testing framework. DejaGnu is written in http://expect.nist.gov[Expect], which in turn uses http://tcl.sourceforge.net[Tcl] -- Tool command language. + + + + +Installing DejaGnu +------------------ + +Installing DejaGnu should be easy using your local package manager. + + +Debian/Ubuntu +~~~~~~~~~~~~~ + +On Debian/Ubuntu you can use `apt-get`: +------------- +sudo apt-get install dejagnu +------------- +This should also install the necessary `expect` and `tcl` packages. + + + + +Structure +--------- + + +Main areas (DejaGnu tools) +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The tests are grouped into different areas, called _tool_ in DejaGnu: + +*install*:: + Functional tests for installation and caching of the main bash-completion package. +*completion*:: + Functional tests per completion. +*unit*:: + Unit tests for bash-completion helper functions. + + +Running the tests +~~~~~~~~~~~~~~~~~ + +The tests are run by calling `runtest` in the test directory: +----------------------- +runtest --outdir=log --tool completion +runtest --outdir=log --tool install +runtest --outdir=log --tool unit +----------------------- +The commands above are already wrapped up in shell scripts within the `test` directory: +----------------------- +./runCompletion +./runInstall +./runUnit +----------------------- + + + + +Maintenance +----------- + + +Adding a completion test +~~~~~~~~~~~~~~~~~~~~~~~~ + +You can add script/generate to add a test. + + + + +Rationale +--------- + + +Naming conventions +~~~~~~~~~~~~~~~~~~ + +Test suite or testsuite +^^^^^^^^^^^^^^^^^^^^^^^ +The primary Wikipedia page is called +http://en.wikipedia.org/wiki/Test_suite[test suite] and not testsuite, so that's what this +document sticks to. + +script/generate +^^^^^^^^^^^^^^^ +The name and location of this code generation script come from Ruby on Rails' http://en.wikibooks.org/wiki/Ruby_on_Rails/Tools/Generators[script/generate]. + + + + +== Reference + +Within test scripts the following library functions can be used: + +== The test environment + +The tests run in a specially prepared bash environment. The following files are used: +* bashrch +* inputrc +* fixtures + +=== bashrc + +Contents of bashrc: + +Index +=====