Example #1
0
/// Puts a context into the database.
///
/// \pre The context has not been put yet.
/// \post The context is stored into the database with a new identifier.
///
/// \param context The context to put.
///
/// \throw error If there is any problem when talking to the database.
void
store::write_transaction::put_context(const model::context& context)
{
    try {
        sqlite::statement stmt = _pimpl->_db.create_statement(
            "INSERT INTO contexts (cwd) VALUES (:cwd)");
        stmt.bind(":cwd", context.cwd().str());
        stmt.step_without_results();

        put_env_vars(_pimpl->_db, context.env());
    } catch (const sqlite::error& e) {
        throw error(e.what());
    }
}
Example #2
0
/// Callback executed when the context is loaded.
///
/// \param context The context loaded from the database.
void
drivers::report_junit_hooks::got_context(const model::context& context)
{
    _output << "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
    _output << "<testsuite>\n";

    _output << "<properties>\n";
    _output << F("<property name=\"cwd\" value=\"%s\"/>\n")
        % text::escape_xml(context.cwd().str());
    for (model::properties_map::const_iterator iter =
             context.env().begin(); iter != context.env().end(); ++iter) {
        _output << F("<property name=\"env.%s\" value=\"%s\"/>\n")
            % text::escape_xml((*iter).first)
            % text::escape_xml((*iter).second);
    }
    _output << "</properties>\n";
}