Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69180 - in branches/quickbook-filenames/tools/quickbook: src test test/command-line test/doc-info
From: dnljms_at_[hidden]
Date: 2011-02-22 15:45:34


Author: danieljames
Date: 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
New Revision: 69180
URL: http://svn.boost.org/trac/boost/changeset/69180

Log:
Flag for testing errors.

quickbook-fail-test couldn't distinguish between correctly handled
errors and bugs, so add quickbook-error-test which will only succeed for
quickbook errors.
Added:
   branches/quickbook-filenames/tools/quickbook/test/command-line/
   branches/quickbook-filenames/tools/quickbook/test/command-line/Jamfile.v2 (contents, props changed)
   branches/quickbook-filenames/tools/quickbook/test/command-line/error-fail.quickbook (contents, props changed)
   branches/quickbook-filenames/tools/quickbook/test/command-line/error1.quickbook (contents, props changed)
   branches/quickbook-filenames/tools/quickbook/test/command-line/error2.quickbook (contents, props changed)
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp | 35 +++++++++++++++++++++++++++++--
   branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 | 43 ++++++++++++++++++++-------------------
   branches/quickbook-filenames/tools/quickbook/test/doc-info/Jamfile.v2 | 6 ++--
   branches/quickbook-filenames/tools/quickbook/test/quickbook-testing.jam | 28 +++++++++++++++++++++++++
   4 files changed, 84 insertions(+), 28 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
@@ -193,6 +193,8 @@
         quickbook::detail::initialise_markups();
 
         options_description desc("Allowed options");
+ options_description hidden("Hidden options");
+ options_description all("All options");
 
 #if QUICKBOOK_WIDE_PATHS
 #define PO_VALUE po::wvalue
@@ -214,6 +216,14 @@
             ("define,D", PO_VALUE< std::vector<input_string> >(), "define macro")
         ;
 
+ hidden.add_options()
+ ("expect-errors",
+ "Succeed if the input file contains a correctly handled "
+ "error, fail otherwise.")
+ ;
+
+ all.add(desc).add(hidden);
+
         positional_options_description p;
         p.add("input-file", -1);
 
@@ -231,15 +241,24 @@
             return 1;
         }
 
- store(wcommand_line_parser(wide_argc, wide_argv).options(desc).positional(p).run(), vm);
+ store(
+ wcommand_line_parser(wide_argc, wide_argv)
+ .options(all)
+ .positional(p)
+ .run(), vm);
 
         LocalFree(wide_argv);
 #else
- store(command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
+ store(command_line_parser(argc, argv)
+ .options(all)
+ .positional(p)
+ .run(), vm);
 #endif
 
         notify(vm);
 
+ bool expect_errors = vm.count("expect-errors");
+
         if (vm.count("help"))
         {
             std::ostringstream description_text;
@@ -333,7 +352,17 @@
                 << quickbook::detail::path_to_stream(fileout)
                 << std::endl;
 
- return quickbook::parse_document(filein, fileout, indent, linewidth, pretty_print);
+ int r = quickbook::parse_document(filein, fileout, indent, linewidth, pretty_print);
+
+ if (expect_errors)
+ {
+ if (!r) quickbook::detail::outerr() << "No errors detected for --expect-errors." << std::endl;
+ return !r;
+ }
+ else
+ {
+ return r;
+ }
         }
         else
         {

Modified: branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
@@ -14,8 +14,9 @@
     ;
 
 build-project doc-info ;
+build-project command-line ;
 
-import quickbook-testing : quickbook-test quickbook-fail-test ;
+import quickbook-testing : quickbook-test quickbook-error-test ;
 
 test-suite quickbook.test :
     [ quickbook-test quickbook-manual ]
@@ -34,7 +35,7 @@
     [ quickbook-test template-section ]
     [ quickbook-test mismatched-brackets-1 ]
     [ quickbook-test mismatched-brackets-2 ]
- [ quickbook-fail-test mismatched-brackets-3 ]
+ [ quickbook-error-test mismatched-brackets-3 ]
     #[ quickbook-test xinclude ]
     [ quickbook-test import ]
     [ quickbook-test include_1_5 ]
@@ -61,26 +62,26 @@
     [ quickbook-test newline ]
     [ quickbook-test anchor ]
     [ quickbook-test command_line_macro : : : <quickbook-test-define>__macro__=*bold* ]
- [ quickbook-fail-test fail-include ]
- [ quickbook-fail-test fail-import ]
- [ quickbook-fail-test fail-template-arguments1 ]
- [ quickbook-fail-test fail-template-arguments2 ]
- [ quickbook-fail-test fail-template-arguments3 ]
- [ quickbook-fail-test fail-cpp-mismatched-escape ]
- [ quickbook-fail-test fail-python-mismatched-escape ]
- [ quickbook-fail-test fail-post-process ]
- [ quickbook-fail-test fail-parse-error1 ]
- [ quickbook-fail-test fail-parse-error2 ]
- [ quickbook-fail-test fail-template-lookup1 ]
- [ quickbook-fail-test fail-template-section-1 ]
- [ quickbook-fail-test fail-template-section-2 ]
- [ quickbook-fail-test fail-template-section-3 ]
- [ quickbook-fail-test fail-unknown-quickbook-1 ]
- [ quickbook-fail-test fail-unknown-quickbook-2 ]
- [ quickbook-fail-test fail-unknown-quickbook-3 ]
+ [ quickbook-error-test fail-include ]
+ [ quickbook-error-test fail-import ]
+ [ quickbook-error-test fail-template-arguments1 ]
+ [ quickbook-error-test fail-template-arguments2 ]
+ [ quickbook-error-test fail-template-arguments3 ]
+ [ quickbook-error-test fail-cpp-mismatched-escape ]
+ [ quickbook-error-test fail-python-mismatched-escape ]
+ [ quickbook-error-test fail-post-process ]
+ [ quickbook-error-test fail-parse-error1 ]
+ [ quickbook-error-test fail-parse-error2 ]
+ [ quickbook-error-test fail-template-lookup1 ]
+ [ quickbook-error-test fail-template-section-1 ]
+ [ quickbook-error-test fail-template-section-2 ]
+ [ quickbook-error-test fail-template-section-3 ]
+ [ quickbook-error-test fail-unknown-quickbook-1 ]
+ [ quickbook-error-test fail-unknown-quickbook-2 ]
+ [ quickbook-error-test fail-unknown-quickbook-3 ]
     [ quickbook-test utf-8 ]
     [ quickbook-test utf-8-bom ]
     [ quickbook-test unicode-escape ]
- [ quickbook-fail-test utf-16be-bom ]
- [ quickbook-fail-test utf-16le-bom ]
+ [ quickbook-error-test utf-16be-bom ]
+ [ quickbook-error-test utf-16le-bom ]
     ;

Added: branches/quickbook-filenames/tools/quickbook/test/command-line/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/command-line/Jamfile.v2 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,20 @@
+
+#
+# Copyright (c) 2011 Daniel James
+#
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+#
+
+# Just checking that expect-errors works as advertised.
+
+project quickook/tests/command-line ;
+
+import quickbook-testing : quickbook-test quickbook-fail-test quickbook-error-test ;
+
+test-suite command-line.test :
+ [ quickbook-fail-test error-fail : : <testing.arg>--expect-errors ]
+ [ quickbook-error-test error1 ]
+ [ quickbook-error-test error2 ]
+ ;
\ No newline at end of file

Added: branches/quickbook-filenames/tools/quickbook/test/command-line/error-fail.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/command-line/error-fail.quickbook 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,5 @@
+[article Valid file to just that expect errors fails
+[quickbook 1.5]
+]
+
+No errors.
\ No newline at end of file

Added: branches/quickbook-filenames/tools/quickbook/test/command-line/error1.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/command-line/error1.quickbook 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,3 @@
+[article A file with an error in the docinfo
+[quickbook 0.8]
+]

Added: branches/quickbook-filenames/tools/quickbook/test/command-line/error2.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/command-line/error2.quickbook 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,7 @@
+[article A file with an error in the body
+[quickbook 1.5]
+]
+
+[table
+[x]
+]
\ No newline at end of file

Modified: branches/quickbook-filenames/tools/quickbook/test/doc-info/Jamfile.v2
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/doc-info/Jamfile.v2 (original)
+++ branches/quickbook-filenames/tools/quickbook/test/doc-info/Jamfile.v2 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
@@ -8,7 +8,7 @@
 
 project quickook/tests/doc-info ;
 
-import quickbook-testing : quickbook-test quickbook-fail-test ;
+import quickbook-testing : quickbook-test quickbook-error-test ;
 
 test-suite quickbook.test :
     [ quickbook-test escape-1.6 ]
@@ -22,6 +22,6 @@
     [ quickbook-test source-mode-1.5 ]
     [ quickbook-test source-mode-1.6 ]
     [ quickbook-test copyright1 ]
- [ quickbook-fail-test copyright-fail1 ]
- [ quickbook-fail-test copyright-fail2 ]
+ [ quickbook-error-test copyright-fail1 ]
+ [ quickbook-error-test copyright-fail2 ]
     ;

Modified: branches/quickbook-filenames/tools/quickbook/test/quickbook-testing.jam
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/quickbook-testing.jam (original)
+++ branches/quickbook-filenames/tools/quickbook/test/quickbook-testing.jam 2011-02-22 15:45:26 EST (Tue, 22 Feb 2011)
@@ -95,6 +95,32 @@
     return $(t) ;
 }
 
+rule quickbook-error-test ( target-name : input ? : requirements * )
+{
+ input ?= $(target-name).quickbook ;
+
+ local project = [ project.current ] ;
+
+ local boost-root = [ modules.peek : BOOST_ROOT ] ;
+
+ local t =
+ [ targets.create-typed-target RUN
+ : $(project)
+ : $(target-name)
+ : $(boost-root)/tools/quickbook/src//quickbook
+ : $(requirements)
+ <testing.input-file>$(input)
+ <testing.arg>--expect-errors
+ <preserve-test-targets>on
+ <dependency>$(input)
+ ]
+ ;
+
+ modules.poke testing : .all-tests : \$\(all-tests\) $(t) ;
+
+ return $(t) ;
+}
+
 ################################################################################
 toolset.flags quickbook-testing.process-quickbook quickbook-command <quickbook-testing.quickbook-command> ;
 toolset.flags quickbook-testing.process-quickbook QB-DEFINES <quickbook-test-define> ;
@@ -106,6 +132,6 @@
 
 actions process-quickbook bind quickbook-command
 {
- $(quickbook-command) $(>) --output-file=$(<) --debug -D"$(QB-DEFINES)"
+ $(quickbook-command) $(>) --output-file=$(<) --debug -D"$(QB-DEFINES)" $(OPTIONS)
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk