diff options
author | Adrian Kummerlaender | 2016-01-05 21:17:42 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2016-01-05 21:17:42 +0100 |
commit | 1df71e9b78fd516f9902f42db733f0b02808ad50 (patch) | |
tree | f6a79cdb5f43ed112a880c47f234203857f6bc40 /src/function/external_command.cc | |
parent | 93af7b2094759d1187c5e9ead8eba6cab557ca18 (diff) | |
download | InputXSLT-1df71e9b78fd516f9902f42db733f0b02808ad50.tar InputXSLT-1df71e9b78fd516f9902f42db733f0b02808ad50.tar.gz InputXSLT-1df71e9b78fd516f9902f42db733f0b02808ad50.tar.bz2 InputXSLT-1df71e9b78fd516f9902f42db733f0b02808ad50.tar.lz InputXSLT-1df71e9b78fd516f9902f42db733f0b02808ad50.tar.xz InputXSLT-1df71e9b78fd516f9902f42db733f0b02808ad50.tar.zst InputXSLT-1df71e9b78fd516f9902f42db733f0b02808ad50.zip |
Fix `generate` problem caused by _boost_ update
i.e. the directory tree was not correctly created in all circumstances which led to both the `generate` and `write-file` test cases failing. This was combined with some accumulated changes such as the extraction of process context instantiation.
Diffstat (limited to 'src/function/external_command.cc')
-rw-r--r-- | src/function/external_command.cc | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/function/external_command.cc b/src/function/external_command.cc index 606ff8f..dda403e 100644 --- a/src/function/external_command.cc +++ b/src/function/external_command.cc @@ -16,12 +16,6 @@ namespace { using InputXSLT::XercesStringGuard; -inline std::string wrapOutput(const std::string& rawOutput) { - return std::string( - "<inputxslt_wrapper>" + rawOutput + "</inputxslt_wrapper>" - ); -} - inline bool isWrappedOutput(const XMLCh* nodeName) { return xercesc::XMLString::equals( nodeName, @@ -42,7 +36,7 @@ std::unique_ptr<std::stringstream> readOutput( ); } else { return std::make_unique<std::stringstream>( - wrapOutput(rawOutput) + "<inputxslt_wrapper>" + rawOutput + "</inputxslt_wrapper>" ); } } @@ -67,6 +61,20 @@ boost::optional<xercesc::DOMNode*> importDocumentElement( } } +boost::process::context createContext( + const InputXSLT::FilesystemContext& fsContext) { + boost::process::context context; + + context.environment = boost::process::self::get_environment(); + context.stdout_behavior = boost::process::capture_stream(); + context.stdin_behavior = boost::process::capture_stream(); + context.work_directory = boost::filesystem::canonical( + fsContext.getBase().parent_path() + ).string(); + + return context; +} + } namespace InputXSLT { @@ -76,21 +84,13 @@ DomDocumentCache::document_ptr FunctionExternalCommand::constructDocument( std::string command, boost::optional<std::string> input ) const { - DomDocumentCache::document_ptr domDocument( + DomDocumentCache::document_ptr domDocument{ DomDocumentCache::createDocument("content") - ); - - boost::process::context context; - context.environment = boost::process::self::get_environment(); - context.stdout_behavior = boost::process::capture_stream(); - context.stdin_behavior = boost::process::capture_stream(); - context.work_directory = boost::filesystem::canonical( - fsContext.getBase().parent_path() - ).string(); + }; - boost::process::child commandProcess( - boost::process::launch_shell(command, context) - ); + boost::process::child commandProcess{ + boost::process::launch_shell(command, createContext(fsContext)) + }; if ( input ) { boost::process::postream& inputStream = commandProcess.get_stdin(); @@ -140,7 +140,6 @@ DomDocumentCache::document_ptr FunctionExternalCommand::constructDocument( result.setAttribute("result", "error"); } - return domDocument; } |