mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-23 11:02:43 +03:00
Fix import name for path utilities.
This commit is contained in:
parent
ec39c59d05
commit
ba3c95c02d
@ -16,7 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::util;
|
||||
use crate::util::path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Represents the directories used to run a Hurl file.
|
||||
@ -60,7 +60,7 @@ impl ContextDir {
|
||||
let file = self.get_path(filename);
|
||||
let absolute_file = self.current_dir.join(file);
|
||||
let absolute_file_root = self.current_dir.join(&self.file_root);
|
||||
util::is_descendant(absolute_file.as_path(), absolute_file_root.as_path())
|
||||
path::is_descendant(absolute_file.as_path(), absolute_file_root.as_path())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,12 @@ use colored::*;
|
||||
use hurl::cli::{CliError, CliOptions, Logger, OutputType};
|
||||
use hurl::http;
|
||||
use hurl::report;
|
||||
use hurl::report::{canonicalize_filename, html};
|
||||
use hurl::report::html;
|
||||
use hurl::runner;
|
||||
use hurl::runner::HurlResult;
|
||||
use hurl::runner::RunnerOptions;
|
||||
use hurl::util::logger::{BaseLogger, LoggerBuilder};
|
||||
use hurl::util::path;
|
||||
use hurl::{cli, output};
|
||||
use hurl_core::ast::HurlFile;
|
||||
use hurl_core::parser;
|
||||
@ -294,6 +295,7 @@ fn create_junit_report(runs: &[Run], filename: &str) -> Result<(), CliError> {
|
||||
fn create_html_report(runs: &[Run], dir_path: &Path) -> Result<(), CliError> {
|
||||
let hurl_results = runs.iter().map(|it| &it.result).collect::<Vec<_>>();
|
||||
html::write_report(dir_path, &hurl_results)?;
|
||||
|
||||
for run in runs.iter() {
|
||||
let filename = &run.result.filename;
|
||||
format_html(filename, dir_path)?;
|
||||
@ -355,7 +357,7 @@ fn get_input_files(
|
||||
}
|
||||
|
||||
fn format_html(input_file: &str, dir_path: &Path) -> Result<(), CliError> {
|
||||
let relative_input_file = canonicalize_filename(input_file);
|
||||
let relative_input_file = path::canonicalize_filename(input_file);
|
||||
let absolute_input_file = dir_path.join(format!("{relative_input_file}.html"));
|
||||
|
||||
let parent = absolute_input_file.parent().expect("a parent");
|
||||
|
@ -19,8 +19,8 @@
|
||||
//! HTML report
|
||||
|
||||
use crate::cli::CliError;
|
||||
use crate::report::canonicalize_filename;
|
||||
use crate::runner::HurlResult;
|
||||
use crate::util::path;
|
||||
use chrono::{DateTime, Local};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
@ -44,7 +44,7 @@ pub fn write_report(dir_path: &Path, hurl_results: &[&HurlResult]) -> Result<(),
|
||||
let mut results = parse_html(&index_path)?;
|
||||
for result in hurl_results.iter() {
|
||||
let html_result = HTMLResult {
|
||||
filename: canonicalize_filename(&result.filename),
|
||||
filename: path::canonicalize_filename(&result.filename),
|
||||
time_in_ms: result.time_in_ms,
|
||||
success: result.success,
|
||||
};
|
||||
|
@ -20,12 +20,3 @@
|
||||
|
||||
pub mod html;
|
||||
pub mod junit;
|
||||
use std::path::Path;
|
||||
|
||||
/// Returns the canonical fullname relative to / (technically a relative path)
|
||||
/// The function will panic if the input file does not exist
|
||||
pub fn canonicalize_filename(input_file: &str) -> String {
|
||||
let relative_input_file = Path::new(input_file).canonicalize().expect("existing file");
|
||||
let relative_input_file = relative_input_file.to_string_lossy();
|
||||
relative_input_file.trim_start_matches('/').to_string()
|
||||
}
|
||||
|
@ -15,7 +15,5 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
pub use self::path::is_descendant;
|
||||
|
||||
pub mod logger;
|
||||
mod path;
|
||||
pub mod path;
|
||||
|
@ -17,6 +17,14 @@
|
||||
*/
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
|
||||
/// Returns the canonical fullname relative to / (technically a relative path)
|
||||
/// The function will panic if the input file does not exist
|
||||
pub fn canonicalize_filename(input_file: &str) -> String {
|
||||
let relative_input_file = Path::new(input_file).canonicalize().expect("existing file");
|
||||
let relative_input_file = relative_input_file.to_string_lossy();
|
||||
relative_input_file.trim_start_matches('/').to_string()
|
||||
}
|
||||
|
||||
/// Return true if `path` is a descendant path of `ancestor`, false otherwise.
|
||||
pub fn is_descendant(path: &Path, ancestor: &Path) -> bool {
|
||||
let path = normalize_path(path);
|
||||
|
Loading…
Reference in New Issue
Block a user