/// Computes the path to a new database for the given test suite. /// /// \param root Path to the root of the test suite being run; needed to properly /// autogenerate the identifiers. /// \param when Timestamp for the test suite being run; needed to properly /// autogenerate the identifiers. /// /// \return Identifier of the created results file, if applicable, and the path /// to such file. fs::path layout::new_db_for_migration(const fs::path& root, const datetime::timestamp& when) { const std::string generated_id = new_id(test_suite_for_path(root), when); const fs::path path = query_store_dir() / ( F("results.%s.db") % generated_id); fs::mkdir_p(path.branch_path(), 0755); return path; }
/// Parses a test suite configuration file. /// /// \param file The file to parse. /// \param user_build_root If not none, specifies a path to a directory /// containing the test programs themselves. The layout of the build root /// must match the layout of the source root (which is just the directory /// from which the Kyuafile is being read). /// /// \return High-level representation of the configuration file. /// /// \throw load_error If there is any problem loading the file. This includes /// file access errors and syntax errors. engine::kyuafile engine::kyuafile::load(const fs::path& file, const optional< fs::path > user_build_root) { const fs::path source_root_ = file.branch_path(); const fs::path build_root_ = user_build_root ? user_build_root.get() : source_root_; return kyuafile(source_root_, build_root_, parser(source_root_, build_root_, fs::path(file.leaf_name())).parse()); }
/// Creates a directory and any missing parents. /// /// This is separate from the fs::mkdir function to clearly differentiate the /// libc wrapper from the more complex algorithm implemented here. /// /// \param dir The path to the directory to create. /// \param mode The permissions for the new directories. /// /// \throw system_error If any call to mkdir(2) fails. void fs::mkdir_p(const fs::path& dir, const int mode) { try { fs::mkdir(dir, mode); } catch (const fs::system_error& e) { if (e.original_errno() == ENOENT) { fs::mkdir_p(dir.branch_path(), mode); fs::mkdir(dir, mode); } else if (e.original_errno() != EEXIST) throw e; } }