|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70187 - in trunk/tools/quickbook: . src test test/command-line test/doc-info
From: dnljms_at_[hidden]
Date: 2011-03-19 11:09:56
Author: danieljames
Date: 2011-03-19 11:09:54 EDT (Sat, 19 Mar 2011)
New Revision: 70187
URL: http://svn.boost.org/trac/boost/changeset/70187
Log:
Quickbook: A couple of hidden flags for testing.
Added:
trunk/tools/quickbook/test/command-line/
- copied from r69181, /branches/quickbook-filenames/tools/quickbook/test/command-line/
trunk/tools/quickbook/test/command-line/Jamfile.v2
- copied unchanged from r69181, /branches/quickbook-filenames/tools/quickbook/test/command-line/Jamfile.v2
trunk/tools/quickbook/test/command-line/error-fail.quickbook
- copied unchanged from r69181, /branches/quickbook-filenames/tools/quickbook/test/command-line/error-fail.quickbook
trunk/tools/quickbook/test/command-line/error1.quickbook
- copied unchanged from r69181, /branches/quickbook-filenames/tools/quickbook/test/command-line/error1.quickbook
trunk/tools/quickbook/test/command-line/error2.quickbook
- copied unchanged from r69181, /branches/quickbook-filenames/tools/quickbook/test/command-line/error2.quickbook
Properties modified:
trunk/tools/quickbook/ (props changed)
Text files modified:
trunk/tools/quickbook/src/actions.cpp | 4 +-
trunk/tools/quickbook/src/actions_class.cpp | 8 ++--
trunk/tools/quickbook/src/actions_class.hpp | 4 +-
trunk/tools/quickbook/src/quickbook.cpp | 62 ++++++++++++++++++++++++++++++++++-----
trunk/tools/quickbook/test/Jamfile.v2 | 45 ++++++++++++++--------------
trunk/tools/quickbook/test/doc-info/Jamfile.v2 | 6 +-
trunk/tools/quickbook/test/quickbook-testing.jam | 30 ++++++++++++++++++
trunk/tools/quickbook/test/xinclude.gold | 2
8 files changed, 117 insertions(+), 44 deletions(-)
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2011-03-19 11:09:54 EDT (Sat, 19 Mar 2011)
@@ -1531,8 +1531,8 @@
{
fs::path infile = fs::absolute(actions.filename).normalize();
path = (infile.parent_path() / path).normalize();
- fs::path outdir = fs::absolute(actions.outdir).normalize();
- path = path_difference(outdir, path);
+ fs::path xinclude_base = fs::absolute(actions.xinclude_base).normalize();
+ path = path_difference(xinclude_base, path);
}
return path;
}
Modified: trunk/tools/quickbook/src/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.cpp (original)
+++ trunk/tools/quickbook/src/actions_class.cpp 2011-03-19 11:09:54 EDT (Sat, 19 Mar 2011)
@@ -20,7 +20,7 @@
namespace quickbook
{
- actions::actions(fs::path const& filein_, fs::path const& outdir_, string_stream& out_)
+ actions::actions(fs::path const& filein_, fs::path const& xinclude_base_, string_stream& out_)
: grammar_()
// header info
@@ -45,7 +45,7 @@
// state
, filename(fs::absolute(filein_))
- , outdir(outdir_)
+ , xinclude_base(xinclude_base_)
, macro_change_depth(0)
, macro()
, section_level(0)
@@ -116,7 +116,7 @@
state_stack.push(
boost::make_tuple(
filename
- , outdir
+ , xinclude_base
, macro_change_depth
, section_level
, min_section_level
@@ -156,7 +156,7 @@
boost::tie(
filename
- , outdir
+ , xinclude_base
, macro_change_depth
, section_level
, min_section_level
Modified: trunk/tools/quickbook/src/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.hpp (original)
+++ trunk/tools/quickbook/src/actions_class.hpp 2011-03-19 11:09:54 EDT (Sat, 19 Mar 2011)
@@ -23,7 +23,7 @@
struct actions
{
- actions(fs::path const& filein_, fs::path const& outdir, string_stream& out_);
+ actions(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_);
private:
boost::scoped_ptr<quickbook_grammar> grammar_;
@@ -63,7 +63,7 @@
// state
fs::path filename;
- fs::path outdir;
+ fs::path xinclude_base;
std::size_t macro_change_depth;
string_symbols macro;
int section_level;
Modified: trunk/tools/quickbook/src/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/src/quickbook.cpp (original)
+++ trunk/tools/quickbook/src/quickbook.cpp 2011-03-19 11:09:54 EDT (Sat, 19 Mar 2011)
@@ -110,9 +110,10 @@
}
static int
- parse_document(fs::path const& filein_, fs::path const& outdir, string_stream& out, bool ignore_docinfo = false)
+ parse_document(fs::path const& filein_, fs::path const& xinclude_base,
+ string_stream& out, bool ignore_docinfo = false)
{
- actions actor(filein_, outdir, out);
+ actions actor(filein_, xinclude_base, out);
set_macros(actor);
bool r = parse_file(filein_, actor);
@@ -134,16 +135,14 @@
parse_document(
fs::path const& filein_
, fs::path const& fileout_
+ , fs::path const& xinclude_base_
, int indent
, int linewidth
, bool pretty_print)
{
int result = 0;
- fs::path outdir = fileout_.parent_path();
- if (outdir.empty())
- outdir = ".";
string_stream buffer;
- result = parse_document(filein_, outdir, buffer);
+ result = parse_document(filein_, xinclude_base_, buffer);
if (result == 0)
{
@@ -194,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
@@ -215,6 +216,17 @@
("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.")
+ ("xinclude-base", PO_VALUE<input_string>(),
+ "Generate xincludes as if generating for this target "
+ "directory.")
+ ;
+
+ all.add(desc).add(hidden);
+
positional_options_description p;
p.add("input-file", -1);
@@ -232,15 +244,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;
@@ -337,12 +358,35 @@
fileout = filein;
fileout.replace_extension(".xml");
}
+
+ fs::path xinclude_base;
+ if (vm.count("xinclude-base"))
+ {
+ xinclude_base = quickbook::detail::input_to_path(
+ vm["xinclude-base"].as<input_string>());
+ }
+ else
+ {
+ xinclude_base = fileout.parent_path();
+ if (xinclude_base.empty())
+ xinclude_base = ".";
+ }
quickbook::detail::out() << "Generating Output File: "
<< 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, xinclude_base, 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: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2 (original)
+++ trunk/tools/quickbook/test/Jamfile.v2 2011-03-19 11:09:54 EDT (Sat, 19 Mar 2011)
@@ -13,8 +13,9 @@
build-project doc-info ;
build-project unit ;
+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 ]
@@ -33,8 +34,8 @@
[ quickbook-test template-section ]
[ quickbook-test mismatched-brackets-1 ]
[ quickbook-test mismatched-brackets-2 ]
- [ quickbook-fail-test mismatched-brackets-3 ]
- #[ quickbook-test xinclude ]
+ [ quickbook-error-test mismatched-brackets-3 ]
+ [ quickbook-test xinclude : : : <quickbook-xinclude-base>../src ]
[ quickbook-test import ]
[ quickbook-test include_1_5 ]
[ quickbook-test include_1_6 ]
@@ -60,26 +61,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 ]
;
Modified: trunk/tools/quickbook/test/doc-info/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/doc-info/Jamfile.v2 (original)
+++ trunk/tools/quickbook/test/doc-info/Jamfile.v2 2011-03-19 11:09:54 EDT (Sat, 19 Mar 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: trunk/tools/quickbook/test/quickbook-testing.jam
==============================================================================
--- trunk/tools/quickbook/test/quickbook-testing.jam (original)
+++ trunk/tools/quickbook/test/quickbook-testing.jam 2011-03-19 11:09:54 EDT (Sat, 19 Mar 2011)
@@ -17,6 +17,7 @@
feature.feature quickbook-testing.quickbook-command : : free dependency ;
feature.feature <quickbook-test-define> : : free ;
+feature.feature <quickbook-xinclude-base> : : free ;
type.register QUICKBOOK_INPUT : quickbook ;
type.register QUICKBOOK_OUTPUT ;
@@ -95,9 +96,36 @@
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> ;
+toolset.flags quickbook-testing.process-quickbook XINCLUDE <quickbook-xinclude-base> ;
rule process-quickbook ( target : source : properties * )
{
@@ -106,6 +134,6 @@
actions process-quickbook bind quickbook-command
{
- $(quickbook-command) $(>) --output-file=$(<) --debug -D"$(QB-DEFINES)"
+ $(quickbook-command) $(>) --output-file=$(<) --debug -D"$(QB-DEFINES)" --xinclude-base=$(XINCLUDE)
}
Modified: trunk/tools/quickbook/test/xinclude.gold
==============================================================================
--- trunk/tools/quickbook/test/xinclude.gold (original)
+++ trunk/tools/quickbook/test/xinclude.gold 2011-03-19 11:09:54 EDT (Sat, 19 Mar 2011)
@@ -2,5 +2,5 @@
<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<article id="include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Include</title>
- <xi:include href="../../../../../../../../../tools/quickbook/test/stub.xml" />
+ <xi:include href="../test/stub.xml" />
</article>
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