mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-24 22:06:40 +03:00
Reorganize import.
This commit is contained in:
parent
65f85f9e53
commit
3361aaaf24
@ -16,9 +16,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use cc::Build;
|
||||
use std::path::Path;
|
||||
|
||||
use cc::Build;
|
||||
#[cfg(windows)]
|
||||
use winres::WindowsResource;
|
||||
|
||||
|
@ -15,11 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::cli::CliError;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
use crate::cli::CliError;
|
||||
|
||||
/// Remove BOM from the input bytes
|
||||
fn strip_bom(bytes: &mut Vec<u8>) {
|
||||
if bytes.starts_with(&[0xefu8, 0xbb, 0xbf]) {
|
||||
|
@ -15,11 +15,9 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use hurl_core::ast::Entry;
|
||||
#[cfg(target_family = "unix")]
|
||||
use hurl_core::ast::{MultipartParam, Request, SectionValue};
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
use {
|
||||
std::io::{stderr, stdin, Write},
|
||||
|
@ -20,18 +20,16 @@ mod interactive;
|
||||
mod options;
|
||||
mod variables;
|
||||
|
||||
use hurl::{output, report};
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
|
||||
use hurl::{output, report};
|
||||
|
||||
pub use self::fs::read_to_string;
|
||||
pub use self::options::app;
|
||||
pub use self::options::output_color;
|
||||
pub use self::options::parse_options;
|
||||
pub use self::options::{get_strings, has_flag};
|
||||
pub use self::options::{CliOptions, OutputType};
|
||||
pub use self::variables::parse as parse_variable;
|
||||
pub use self::variables::parse_value as parse_variable_value;
|
||||
pub use self::options::{
|
||||
app, get_strings, has_flag, output_color, parse_options, CliOptions, OutputType,
|
||||
};
|
||||
pub use self::variables::{parse as parse_variable, parse_value as parse_variable_value};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CliError {
|
||||
|
@ -15,14 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::cli;
|
||||
use crate::cli::CliError;
|
||||
use crate::runner::RunnerOptionsBuilder;
|
||||
use crate::runner::{RunnerOptions, Value, Verbosity};
|
||||
use atty::Stream;
|
||||
use clap::{value_parser, ArgAction, ArgMatches, Command};
|
||||
use hurl::util::path::ContextDir;
|
||||
use hurl_core::ast::Entry;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
@ -30,6 +22,15 @@ use std::io::{BufRead, BufReader};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
use atty::Stream;
|
||||
use clap::{value_parser, ArgAction, ArgMatches, Command};
|
||||
use hurl::util::path::ContextDir;
|
||||
use hurl_core::ast::Entry;
|
||||
|
||||
use crate::cli;
|
||||
use crate::cli::CliError;
|
||||
use crate::runner::{RunnerOptions, RunnerOptionsBuilder, Value, Verbosity};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CliOptions {
|
||||
pub cacert_file: Option<String>,
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::cli::CliError;
|
||||
use crate::runner::Value;
|
||||
|
||||
|
@ -15,9 +15,10 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use lazy_static::lazy_static;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
// HTML5 named character references
|
||||
//
|
||||
// Generated from https://html.spec.whatwg.org/entities.json and
|
||||
|
@ -15,10 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::html::entities::HTML5_ENTITIES;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use regex::{Captures, Regex};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::html::entities::HTML5_ENTITIES;
|
||||
|
||||
// Ref https://html.spec.whatwg.org/#decimal-character-reference-start-state
|
||||
lazy_static! {
|
||||
|
@ -15,10 +15,11 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use std::collections::HashMap;
|
||||
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
|
||||
use crate::http::easy_ext::CertInfo;
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Certificate {
|
||||
|
@ -17,28 +17,27 @@
|
||||
*/
|
||||
use std::io::Read;
|
||||
use std::str;
|
||||
|
||||
use curl::easy;
|
||||
use encoding::all::ISO_8859_1;
|
||||
use encoding::{DecoderTrap, Encoding};
|
||||
use std::str::FromStr;
|
||||
use std::time::Instant;
|
||||
|
||||
use super::core::*;
|
||||
use super::options::ClientOptions;
|
||||
use super::request::*;
|
||||
use super::request_spec::*;
|
||||
use super::response::*;
|
||||
use super::{Header, HttpError, Verbosity};
|
||||
use crate::http::certificate::Certificate;
|
||||
use crate::http::easy_ext;
|
||||
use crate::util::logger::Logger;
|
||||
use crate::util::path::ContextDir;
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use curl::easy;
|
||||
use curl::easy::{List, SslOpt};
|
||||
use std::str::FromStr;
|
||||
use encoding::all::ISO_8859_1;
|
||||
use encoding::{DecoderTrap, Encoding};
|
||||
use url::Url;
|
||||
|
||||
use crate::http::certificate::Certificate;
|
||||
use crate::http::core::*;
|
||||
use crate::http::options::ClientOptions;
|
||||
use crate::http::request::*;
|
||||
use crate::http::request_spec::*;
|
||||
use crate::http::response::*;
|
||||
use crate::http::{easy_ext, Header, HttpError, Verbosity};
|
||||
use crate::util::logger::Logger;
|
||||
use crate::util::path::ContextDir;
|
||||
|
||||
/// Defines an HTTP client to execute HTTP requests.
|
||||
///
|
||||
/// Most of the methods are delegated to libcurl functions, while some
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use core::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -15,11 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use std::ffi::CStr;
|
||||
use std::ptr;
|
||||
|
||||
use curl::easy::Easy;
|
||||
use curl::Error;
|
||||
use curl_sys::{curl_certinfo, curl_slist};
|
||||
use std::ffi::CStr;
|
||||
use std::ptr;
|
||||
|
||||
/// Represents certificate information.
|
||||
/// `data` has format "name:content";
|
||||
@ -125,10 +126,11 @@ fn to_list(slist: *mut curl_slist) -> Vec<String> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::to_list;
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
|
||||
use super::to_list;
|
||||
|
||||
#[test]
|
||||
fn convert_curl_slist_to_vec() {
|
||||
let mut slist = ptr::null_mut();
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use core::fmt;
|
||||
|
||||
/// Represents an HTTP header
|
||||
@ -40,12 +39,7 @@ impl Header {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns all header values for given name
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `headers` - A list of HTTP headers
|
||||
/// * `name` - A name to filter header (case insensitively)
|
||||
/// Returns all `headers` values for given `name`.
|
||||
pub fn get_values(headers: &[Header], name: &str) -> Vec<String> {
|
||||
headers
|
||||
.iter()
|
||||
|
@ -15,12 +15,11 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use super::core::*;
|
||||
use super::Header;
|
||||
use crate::http::{header, HttpError};
|
||||
use url::Url;
|
||||
|
||||
use crate::http::core::*;
|
||||
use crate::http::{header, Header, HttpError};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Request {
|
||||
pub url: String,
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::http::{debug, mimetype, Request};
|
||||
use crate::util::logger::Logger;
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use encoding::{DecoderTrap, EncodingRef};
|
||||
|
||||
use crate::http::{mimetype, HttpError, Request};
|
||||
use encoding::{DecoderTrap, EncodingRef};
|
||||
|
||||
impl Request {
|
||||
/// Returns character encoding of the HTTP request.
|
||||
|
@ -15,11 +15,10 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use super::{header, Header};
|
||||
use core::fmt;
|
||||
|
||||
use super::core::*;
|
||||
use crate::http::core::*;
|
||||
use crate::http::{header, Header};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct RequestSpec {
|
||||
|
@ -15,12 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::core::*;
|
||||
use super::RequestSpec;
|
||||
use crate::http::*;
|
||||
use crate::util::path::ContextDir;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::http::core::*;
|
||||
use crate::http::{RequestSpec, *};
|
||||
use crate::util::path::ContextDir;
|
||||
|
||||
impl RequestSpec {
|
||||
/// Returns this request as curl arguments.
|
||||
/// It does not contain the requests cookies (they will be accessed from the client)
|
||||
@ -234,9 +234,10 @@ fn escape_string(s: &str) -> String {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use super::*;
|
||||
use crate::http;
|
||||
use std::path::Path;
|
||||
|
||||
fn form_http_request() -> RequestSpec {
|
||||
RequestSpec {
|
||||
|
@ -15,12 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use super::{header, Header};
|
||||
use crate::http::certificate::Certificate;
|
||||
use core::fmt;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::http::certificate::Certificate;
|
||||
use crate::http::{header, Header};
|
||||
|
||||
/// Represents an HTTP response.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Response {
|
||||
|
@ -15,8 +15,7 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::Response;
|
||||
use super::ResponseCookie;
|
||||
use crate::http::{Response, ResponseCookie};
|
||||
|
||||
impl Response {
|
||||
pub fn cookies(&self) -> Vec<ResponseCookie> {
|
||||
|
@ -16,7 +16,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use encoding::{DecoderTrap, EncodingRef};
|
||||
///
|
||||
/// Decompresses body response
|
||||
/// using the Content-Encoding response header
|
||||
@ -24,6 +23,8 @@ use encoding::{DecoderTrap, EncodingRef};
|
||||
/// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
|
||||
use std::io::prelude::*;
|
||||
|
||||
use encoding::{DecoderTrap, EncodingRef};
|
||||
|
||||
use crate::http::{mimetype, HttpError, Response};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@ -35,11 +36,7 @@ pub enum ContentEncoding {
|
||||
}
|
||||
|
||||
impl ContentEncoding {
|
||||
/// Returns an encoding from an HTTP header value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `s` - A Content-Encoding header value
|
||||
/// Returns an encoding from an HTTP header value `s`.
|
||||
pub fn parse(s: &str) -> Result<ContentEncoding, HttpError> {
|
||||
match s {
|
||||
"br" => Ok(ContentEncoding::Brotli),
|
||||
@ -52,11 +49,7 @@ impl ContentEncoding {
|
||||
}
|
||||
}
|
||||
|
||||
/// Decompresses bytes.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `data` - A compressed bytes array
|
||||
/// Decompresses `data` bytes.
|
||||
pub fn decode(&self, data: &[u8]) -> Result<Vec<u8>, HttpError> {
|
||||
match self {
|
||||
ContentEncoding::Identity => Ok(data.to_vec()),
|
||||
@ -132,11 +125,7 @@ impl Response {
|
||||
}
|
||||
}
|
||||
|
||||
/// Decompresses Brotli compressed data.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * data - Compressed bytes.
|
||||
/// Decompresses Brotli compressed `data`.
|
||||
fn uncompress_brotli(data: &[u8]) -> Result<Vec<u8>, HttpError> {
|
||||
let buffer_size = 4096;
|
||||
let mut reader = brotli::Decompressor::new(data, buffer_size);
|
||||
@ -149,11 +138,7 @@ fn uncompress_brotli(data: &[u8]) -> Result<Vec<u8>, HttpError> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Decompresses GZip compressed data.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * data - Compressed bytes.
|
||||
/// Decompresses GZip compressed `data`.
|
||||
fn uncompress_gzip(data: &[u8]) -> Result<Vec<u8>, HttpError> {
|
||||
let mut decoder = match libflate::gzip::Decoder::new(data) {
|
||||
Ok(v) => v,
|
||||
@ -172,11 +157,7 @@ fn uncompress_gzip(data: &[u8]) -> Result<Vec<u8>, HttpError> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Decompresses Zlib compressed data.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * data - Compressed bytes.
|
||||
/// Decompresses Zlib compressed `data`.
|
||||
fn uncompress_zlib(data: &[u8]) -> Result<Vec<u8>, HttpError> {
|
||||
let mut decoder = match libflate::zlib::Decoder::new(data) {
|
||||
Ok(v) => v,
|
||||
|
@ -16,10 +16,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use regex::Regex;
|
||||
use std::default::Default;
|
||||
use std::time::Duration;
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
use crate::http::*;
|
||||
use crate::util::logger::LoggerBuilder;
|
||||
use crate::util::path::ContextDir;
|
||||
@ -1112,9 +1113,10 @@ fn test_version() {
|
||||
// This test function can be used to reproduce bug
|
||||
#[test]
|
||||
fn test_libcurl_directly() {
|
||||
use curl;
|
||||
use std::io::{stdout, Write};
|
||||
|
||||
use curl;
|
||||
|
||||
let mut easy = curl::easy::Easy::new();
|
||||
easy.url("http://localhost:8000/hello").unwrap();
|
||||
easy.write_function(|data| {
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use crate::runner;
|
||||
use crate::runner::RunnerOptions;
|
||||
use crate::util::logger::LoggerBuilder;
|
||||
use hurl_core::ast::*;
|
||||
|
||||
fn hello_request() -> Request {
|
||||
// GET http://localhost;8000/hello
|
||||
|
@ -15,12 +15,13 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
use crate::http::{
|
||||
Certificate, Cookie, Header, Param, Request, RequestCookie, Response, ResponseCookie, Version,
|
||||
};
|
||||
use crate::runner::{AssertResult, Call, CaptureResult, EntryResult, HurlResult};
|
||||
use crate::util::logger;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
impl HurlResult {
|
||||
/// Serializes an [`HurlResult`] to a JSON representation.
|
||||
|
@ -16,10 +16,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::runner::Value;
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
|
||||
use crate::runner::Value;
|
||||
|
||||
impl Value {
|
||||
pub fn to_json(&self) -> serde_json::Value {
|
||||
match self {
|
||||
|
@ -16,9 +16,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use super::ast::*;
|
||||
use float_cmp::approx_eq;
|
||||
|
||||
use super::ast::*;
|
||||
|
||||
pub type JsonpathResult = Vec<serde_json::Value>;
|
||||
|
||||
impl Query {
|
||||
|
@ -17,8 +17,7 @@
|
||||
*/
|
||||
use super::super::ast::*;
|
||||
use super::error::{Error, ParseError};
|
||||
use super::ParseResult;
|
||||
use super::Reader;
|
||||
use super::{ParseResult, Reader};
|
||||
|
||||
pub fn natural(reader: &mut Reader) -> ParseResult<'static, usize> {
|
||||
let start = reader.state.clone();
|
||||
|
@ -20,10 +20,12 @@
|
||||
//! These tests are not located at the root of the project, like Rust integration tests
|
||||
//! are usually located since we do not want to expose the jsonpath module to our public API.
|
||||
|
||||
use crate::jsonpath;
|
||||
use serde_json::json;
|
||||
use std::fs::read_to_string;
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
use crate::jsonpath;
|
||||
|
||||
fn bookstore_value() -> serde_json::Value {
|
||||
let s = read_to_string("tests/bookstore.json").expect("could not read string from file");
|
||||
serde_json::from_str(s.as_str()).expect("could not parse json file")
|
||||
|
@ -25,13 +25,10 @@ use std::time::Instant;
|
||||
use atty::Stream;
|
||||
use clap::Command;
|
||||
use colored::*;
|
||||
|
||||
use hurl::report;
|
||||
use hurl::report::html;
|
||||
use hurl::runner;
|
||||
use hurl::runner::HurlResult;
|
||||
use hurl::util::logger::{BaseLogger, Logger, LoggerBuilder};
|
||||
use hurl::{libcurl_version_info, output};
|
||||
use hurl::{libcurl_version_info, output, report, runner};
|
||||
use hurl_core::ast::HurlFile;
|
||||
use hurl_core::parser;
|
||||
use report::junit;
|
||||
|
@ -25,12 +25,13 @@ mod json;
|
||||
mod raw;
|
||||
mod stdout;
|
||||
|
||||
pub use self::json::write_json;
|
||||
pub use self::raw::write_body;
|
||||
use std::fmt;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
pub use self::json::write_json;
|
||||
pub use self::raw::write_body;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Error {
|
||||
pub message: String,
|
||||
|
@ -15,15 +15,15 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::http::Response;
|
||||
use crate::output;
|
||||
use crate::runner;
|
||||
use crate::runner::{HurlResult, RunnerError};
|
||||
use crate::util::logger::Logger;
|
||||
use colored::Colorize;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::error::Error;
|
||||
|
||||
use crate::http::Response;
|
||||
use crate::runner::{HurlResult, RunnerError};
|
||||
use crate::util::logger::Logger;
|
||||
use crate::{output, runner};
|
||||
|
||||
/// Writes the `hurl_result` last body response to the file `filename_out`.
|
||||
///
|
||||
/// If `filename` is `None`, stdout is used. If `include_headers` is true, the last HTTP
|
||||
|
@ -15,12 +15,14 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::output::Error;
|
||||
#[cfg(target_family = "windows")]
|
||||
use atty::Stream;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
|
||||
#[cfg(target_family = "windows")]
|
||||
use atty::Stream;
|
||||
|
||||
use crate::output::Error;
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
pub(crate) fn write_stdout(buf: &[u8]) -> Result<(), Error> {
|
||||
let stdout = io::stdout();
|
||||
|
@ -20,12 +20,14 @@
|
||||
|
||||
mod testcase;
|
||||
|
||||
use crate::report::Error;
|
||||
use chrono::{DateTime, Local};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
use chrono::{DateTime, Local};
|
||||
pub use testcase::Testcase;
|
||||
|
||||
use crate::report::Error;
|
||||
|
||||
/// The test result to be displayed in an HTML page
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
struct HTMLResult {
|
||||
|
@ -15,13 +15,15 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::Error;
|
||||
use crate::runner::HurlResult;
|
||||
use hurl_core::ast::HurlFile;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
use hurl_core::ast::HurlFile;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::Error;
|
||||
use crate::runner::HurlResult;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Testcase {
|
||||
pub id: String,
|
||||
|
@ -56,11 +56,13 @@
|
||||
//!
|
||||
mod testcase;
|
||||
|
||||
use crate::report::Error;
|
||||
use std::fs::File;
|
||||
|
||||
pub use testcase::Testcase;
|
||||
use xmltree::{Element, XMLNode};
|
||||
|
||||
use crate::report::Error;
|
||||
|
||||
/// Creates a JUnit from a list of `testcases`.
|
||||
pub fn write_report(filename: &str, testcases: &[Testcase]) -> Result<(), Error> {
|
||||
let mut testsuites = vec![];
|
||||
|
@ -15,9 +15,10 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use xmltree::{Element, XMLNode};
|
||||
|
||||
use crate::runner::HurlResult;
|
||||
use crate::util::logger;
|
||||
use xmltree::{Element, XMLNode};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Testcase {
|
||||
@ -99,9 +100,10 @@ impl Testcase {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
use crate::report::junit::testcase::Testcase;
|
||||
use crate::runner::{EntryResult, Error, HurlResult, RunnerError};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
#[test]
|
||||
fn test_create_testcase_success() {
|
||||
|
@ -15,18 +15,16 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::filter::eval_filters;
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::core::*;
|
||||
use super::core::{Error, RunnerError};
|
||||
use super::predicate::eval_predicate;
|
||||
use super::query::eval_query;
|
||||
use super::value::Value;
|
||||
use crate::http;
|
||||
use crate::runner::core::{Error, RunnerError, *};
|
||||
use crate::runner::filter::eval_filters;
|
||||
use crate::runner::predicate::eval_predicate;
|
||||
use crate::runner::query::eval_query;
|
||||
use crate::runner::value::Value;
|
||||
|
||||
impl AssertResult {
|
||||
/// Evaluates an assert and returns `None` if assert is succeeded or an `Error` if failed.
|
||||
@ -179,10 +177,11 @@ pub fn eval_assert(
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
use super::super::query;
|
||||
use super::*;
|
||||
use crate::http::xml_three_users_http_response;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
// xpath //user countEquals 3
|
||||
pub fn assert_count_user() -> Assert {
|
||||
|
@ -15,17 +15,19 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::core::{Error, RunnerError};
|
||||
use super::json::eval_json_value;
|
||||
use super::value::Value;
|
||||
use crate::http;
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::util::path::ContextDir;
|
||||
use hurl_core::ast::*;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::core::{Error, RunnerError};
|
||||
use crate::runner::json::eval_json_value;
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::value::Value;
|
||||
use crate::util::path::ContextDir;
|
||||
|
||||
pub fn eval_body(
|
||||
body: &Body,
|
||||
variables: &HashMap<String, Value>,
|
||||
@ -88,9 +90,10 @@ pub fn eval_file(filename: &Filename, context_dir: &ContextDir) -> Result<Vec<u8
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use std::path::Path;
|
||||
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
@ -15,17 +15,15 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::filter::eval_filters;
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::core::RunnerError;
|
||||
use super::core::{CaptureResult, Error};
|
||||
use super::query::eval_query;
|
||||
use super::value::Value;
|
||||
use crate::http;
|
||||
use crate::runner::core::{CaptureResult, Error, RunnerError};
|
||||
use crate::runner::filter::eval_filters;
|
||||
use crate::runner::query::eval_query;
|
||||
use crate::runner::value::Value;
|
||||
|
||||
/// Evaluates a `capture` with `variables` map and `http_response`, returns a
|
||||
/// [`CaptureResult`] on success or an [`Error`] .
|
||||
@ -57,9 +55,10 @@ pub fn eval_capture(
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
|
||||
use self::super::super::query;
|
||||
use super::*;
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
|
||||
pub fn user_count_capture() -> Capture {
|
||||
// non scalar value
|
||||
|
@ -17,10 +17,10 @@
|
||||
*/
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::http;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
use super::value::Value;
|
||||
use crate::http;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Verbosity {
|
||||
|
@ -18,20 +18,17 @@
|
||||
use std::collections::HashMap;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::http;
|
||||
use crate::http::ClientOptions;
|
||||
use crate::util::logger::Logger;
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::core::*;
|
||||
use super::core::{Error, RunnerError};
|
||||
use super::request::eval_request;
|
||||
use super::response::{eval_asserts, eval_captures};
|
||||
use super::value::Value;
|
||||
use crate::runner::request::{cookie_storage_clear, cookie_storage_set};
|
||||
use crate::runner::response::eval_version_status_asserts;
|
||||
use crate::http;
|
||||
use crate::http::ClientOptions;
|
||||
use crate::runner::core::{Error, RunnerError, *};
|
||||
use crate::runner::request::{cookie_storage_clear, cookie_storage_set, eval_request};
|
||||
use crate::runner::response::{eval_asserts, eval_captures, eval_version_status_asserts};
|
||||
use crate::runner::runner_options::RunnerOptions;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::value::Value;
|
||||
use crate::util::logger::Logger;
|
||||
|
||||
/// Runs an `entry` with `http_client` and returns one [`EntryResult`].
|
||||
///
|
||||
|
@ -15,11 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::error::Error;
|
||||
|
||||
use crate::http::HttpError;
|
||||
use crate::runner;
|
||||
use crate::runner::RunnerError;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::error::Error;
|
||||
|
||||
/// Textual Output for runner errors
|
||||
impl Error for runner::Error {
|
||||
|
@ -19,8 +19,8 @@ use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::Expr;
|
||||
|
||||
use super::core::{Error, RunnerError};
|
||||
use super::value::Value;
|
||||
use crate::runner::core::{Error, RunnerError};
|
||||
use crate::runner::value::Value;
|
||||
|
||||
/// Evaluates the expression `expr` with `variables` map and `http_response`, returns a
|
||||
/// [`Value`] on success or an [`Error`] .
|
||||
|
@ -15,14 +15,13 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use chrono::NaiveDateTime;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
use hurl_core::ast::{Filter, FilterValue, RegexValue, SourceInfo, Template};
|
||||
use percent_encoding::AsciiSet;
|
||||
|
||||
use crate::html;
|
||||
use hurl_core::ast::{Filter, FilterValue, RegexValue, SourceInfo, Template};
|
||||
|
||||
use crate::runner::regex::eval_regex_value;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::{Error, RunnerError, Value};
|
||||
@ -346,11 +345,12 @@ fn eval_to_int(value: &Value, source_info: &SourceInfo, assert: bool) -> Result<
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use chrono::offset::Utc;
|
||||
use chrono::prelude::*;
|
||||
use hurl_core::ast::{FilterValue, SourceInfo, Template, TemplateElement, Whitespace};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub fn filter_count() -> Filter {
|
||||
Filter {
|
||||
source_info: SourceInfo::new(1, 1, 1, 6),
|
||||
|
@ -19,16 +19,15 @@ use std::collections::HashMap;
|
||||
use std::thread;
|
||||
use std::time::Instant;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::core::*;
|
||||
use crate::runner::entry;
|
||||
use crate::runner::runner_options::RunnerOptions;
|
||||
use crate::runner::Value;
|
||||
use crate::util::logger::Logger;
|
||||
use crate::util::logger::LoggerBuilder;
|
||||
use hurl_core::ast::VersionValue::VersionAnyLegacy;
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::core::*;
|
||||
use crate::runner::runner_options::RunnerOptions;
|
||||
use crate::runner::{entry, Value};
|
||||
use crate::util::logger::{Logger, LoggerBuilder};
|
||||
|
||||
/// Runs a `hurl_file`, issue from the given `content`and `filename` and
|
||||
/// returns a [`HurlResult`] upon completion.
|
||||
///
|
||||
|
@ -20,9 +20,9 @@ use std::collections::HashMap;
|
||||
use hurl_core::ast::{JsonListElement, JsonObjectElement, JsonValue, Template, TemplateElement};
|
||||
use hurl_core::parser::{parse_json_boolean, parse_json_null, parse_json_number, Reader};
|
||||
|
||||
use super::core::{Error, RunnerError};
|
||||
use super::value::Value;
|
||||
use crate::runner::core::{Error, RunnerError};
|
||||
use crate::runner::template::eval_expression;
|
||||
use crate::runner::value::Value;
|
||||
|
||||
/// Evaluates a JSON value to a string given a set of `variables`.
|
||||
/// If `keep_whitespace` is true, whitespace is preserved from the JSonValue, otherwise
|
||||
@ -179,9 +179,10 @@ fn encode_json_char(c: char) -> String {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::super::core::RunnerError;
|
||||
use super::*;
|
||||
use hurl_core::ast::*;
|
||||
|
||||
pub fn json_hello_world_value() -> JsonValue {
|
||||
// "hello\u0020{{name}}!"
|
||||
|
@ -15,12 +15,14 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::{MultilineString, Text};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::runner::json::eval_json_value;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::{Error, Value};
|
||||
use hurl_core::ast::{MultilineString, Text};
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Renders to string a multiline body, given a set of variables.
|
||||
pub fn eval_multiline(
|
||||
@ -55,14 +57,15 @@ pub fn eval_multiline(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
use hurl_core::ast::JsonValue;
|
||||
use hurl_core::ast::{
|
||||
GraphQl, GraphQlVariables, JsonObjectElement, MultilineString, SourceInfo, Template,
|
||||
TemplateElement, Whitespace,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::{
|
||||
GraphQl, GraphQlVariables, JsonObjectElement, JsonValue, MultilineString, SourceInfo,
|
||||
Template, TemplateElement, Whitespace,
|
||||
};
|
||||
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
value: String::from(" "),
|
||||
|
@ -15,17 +15,19 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::core::Error;
|
||||
use super::template::eval_template;
|
||||
use super::value::Value;
|
||||
use crate::http;
|
||||
use crate::runner::body::eval_file;
|
||||
use crate::util::path::ContextDir;
|
||||
use hurl_core::ast::*;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::Path;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::body::eval_file;
|
||||
use crate::runner::core::Error;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::value::Value;
|
||||
use crate::util::path::ContextDir;
|
||||
|
||||
pub fn eval_multipart_param(
|
||||
multipart_param: &MultipartParam,
|
||||
variables: &HashMap<String, Value>,
|
||||
|
@ -18,15 +18,13 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
use regex;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::core::Error;
|
||||
use super::template::eval_template;
|
||||
use super::value::Value;
|
||||
use crate::runner::core::PredicateResult;
|
||||
use crate::runner::core::{Error, PredicateResult};
|
||||
use crate::runner::predicate_value::eval_predicate_value;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::value::Value;
|
||||
use crate::runner::RunnerError;
|
||||
|
||||
pub fn eval_predicate(
|
||||
@ -829,8 +827,7 @@ fn contains(haystack: &[u8], needle: &[u8]) -> bool {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::AssertResult;
|
||||
use super::*;
|
||||
use super::{AssertResult, *};
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
|
@ -17,13 +17,13 @@
|
||||
*/
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::core::Error;
|
||||
use super::expr::eval_expr;
|
||||
use super::template::eval_template;
|
||||
use super::value::Value;
|
||||
use crate::runner::core::Error;
|
||||
use crate::runner::expr::eval_expr;
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::value::Value;
|
||||
|
||||
pub fn eval_predicate_value(
|
||||
predicate_value: &PredicateValue,
|
||||
|
@ -15,19 +15,18 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::core::{Error, RunnerError};
|
||||
use super::template::eval_template;
|
||||
use super::value::Value;
|
||||
use super::xpath;
|
||||
use crate::http;
|
||||
use crate::jsonpath;
|
||||
use hurl_core::ast::*;
|
||||
use regex::Regex;
|
||||
use sha2::Digest;
|
||||
|
||||
use crate::runner::core::{Error, RunnerError};
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::value::Value;
|
||||
use crate::runner::xpath;
|
||||
use crate::{http, jsonpath};
|
||||
|
||||
pub type QueryResult = Result<Option<Value>, Error>;
|
||||
|
||||
/// Evaluates this `query` and returns a [`QueryResult`], using the HTTP response `http_response` and `variables`.
|
||||
@ -381,10 +380,11 @@ impl Value {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use hex_literal::hex;
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub fn xpath_invalid_query() -> Query {
|
||||
// xpath ???
|
||||
let whitespace = Whitespace {
|
||||
|
@ -15,12 +15,10 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
use hurl_core::ast::RegexValue;
|
||||
use regex::Regex;
|
||||
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::{Error, RunnerError, Value};
|
||||
|
@ -15,17 +15,19 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::body::eval_body;
|
||||
use super::core::Error;
|
||||
use super::template::eval_template;
|
||||
use super::value::Value;
|
||||
use crate::http;
|
||||
use crate::runner::multipart::eval_multipart_param;
|
||||
use crate::util::path::ContextDir;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use hurl_core::ast::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::body::eval_body;
|
||||
use crate::runner::core::Error;
|
||||
use crate::runner::multipart::eval_multipart_param;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::value::Value;
|
||||
use crate::util::path::ContextDir;
|
||||
|
||||
/// Transforms an AST `request` to a spec request given a set of `variables`.
|
||||
pub fn eval_request(
|
||||
@ -181,9 +183,10 @@ fn eval_method(method: &Method) -> http::Method {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
use super::super::core::RunnerError;
|
||||
use super::*;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
|
@ -15,19 +15,21 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::assert::eval_assert;
|
||||
use super::body::eval_body;
|
||||
use super::capture::eval_capture;
|
||||
use super::core::*;
|
||||
use super::json::eval_json_value;
|
||||
use super::template::eval_template;
|
||||
use super::value::Value;
|
||||
use crate::http;
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
use crate::util::path::ContextDir;
|
||||
use hurl_core::ast::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use crate::http;
|
||||
use crate::runner::assert::eval_assert;
|
||||
use crate::runner::body::eval_body;
|
||||
use crate::runner::capture::eval_capture;
|
||||
use crate::runner::core::*;
|
||||
use crate::runner::json::eval_json_value;
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
use crate::runner::template::eval_template;
|
||||
use crate::runner::value::Value;
|
||||
use crate::util::path::ContextDir;
|
||||
|
||||
/// Returns a list of assert results on the response status code and HTTP version,
|
||||
/// given a set of `variables`, an actual `http_response` and a spec `response`.
|
||||
pub fn eval_version_status_asserts(
|
||||
@ -326,11 +328,9 @@ pub fn eval_captures(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use self::super::super::{assert, capture};
|
||||
use super::*;
|
||||
|
||||
use self::super::super::assert;
|
||||
use self::super::super::capture;
|
||||
|
||||
pub fn user_response() -> Response {
|
||||
let whitespace = Whitespace {
|
||||
value: String::from(" "),
|
||||
|
@ -15,10 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use std::time::Duration;
|
||||
|
||||
use hurl_core::ast::Entry;
|
||||
|
||||
use crate::runner::Verbosity;
|
||||
use crate::util::path::ContextDir;
|
||||
use hurl_core::ast::Entry;
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct RunnerOptionsBuilder {
|
||||
cacert_file: Option<String>,
|
||||
|
@ -19,8 +19,8 @@ use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::core::{Error, RunnerError};
|
||||
use super::value::Value;
|
||||
use crate::runner::core::{Error, RunnerError};
|
||||
use crate::runner::value::Value;
|
||||
|
||||
/// Renders to string a `template` given a map of variables.
|
||||
pub fn eval_template(
|
||||
|
@ -16,11 +16,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// Unique entry point to libxml2
|
||||
|
||||
/// Unique entry point to libxml2
|
||||
use std::ffi::CStr;
|
||||
|
||||
use super::value::Value;
|
||||
use crate::runner::value::Value;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum XpathError {
|
||||
|
@ -15,11 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use std::cmp::max;
|
||||
|
||||
use crate::runner::{HurlResult, Value};
|
||||
use colored::*;
|
||||
use hurl_core::error::Error;
|
||||
use std::cmp::max;
|
||||
|
||||
use crate::runner::{HurlResult, Value};
|
||||
|
||||
/// A simple logger to log app related event (start, high levels error, etc...).
|
||||
/// When we run an [`hurl_core::ast::HurlFile`], user has to provide a dedicated Hurl logger (see [`Logger`]).
|
||||
@ -601,9 +602,10 @@ fn get_lines(text: &str) -> Vec<&str> {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
use super::*;
|
||||
use crate::runner;
|
||||
use hurl_core::ast::SourceInfo;
|
||||
|
||||
#[test]
|
||||
fn test_add_line_prefix_no_colored() {
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::json;
|
||||
use crate::ast::json;
|
||||
|
||||
///
|
||||
/// Hurl AST
|
||||
|
@ -15,9 +15,10 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::core::*;
|
||||
use core::fmt;
|
||||
|
||||
use crate::ast::core::*;
|
||||
|
||||
impl fmt::Display for Method {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let s = match self {
|
||||
|
@ -15,10 +15,11 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::core::Template;
|
||||
use crate::ast::{Expr, TemplateElement};
|
||||
use core::fmt;
|
||||
|
||||
use crate::ast::core::Template;
|
||||
use crate::ast::{Expr, TemplateElement};
|
||||
|
||||
///
|
||||
/// This the AST for the JSON used within Hurl
|
||||
///
|
||||
|
@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
pub use self::core::*;
|
||||
pub use self::json::ListElement as JsonListElement;
|
||||
pub use self::json::ObjectElement as JsonObjectElement;
|
||||
pub use self::json::Value as JsonValue;
|
||||
pub use self::json::{
|
||||
ListElement as JsonListElement, ObjectElement as JsonObjectElement, Value as JsonValue,
|
||||
};
|
||||
|
||||
mod core;
|
||||
mod display;
|
||||
|
@ -15,11 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::ast::SourceInfo;
|
||||
use super::parser;
|
||||
use super::parser::ParseError;
|
||||
use core::cmp;
|
||||
|
||||
use crate::ast::SourceInfo;
|
||||
use crate::parser;
|
||||
use crate::parser::ParseError;
|
||||
|
||||
pub trait Error {
|
||||
fn source_info(&self) -> SourceInfo;
|
||||
fn description(&self) -> String;
|
||||
|
@ -17,23 +17,11 @@
|
||||
*/
|
||||
use super::reader::Reader;
|
||||
|
||||
// part of hurl
|
||||
// just reuse Parser/Error Position
|
||||
// do not depend on external separator
|
||||
// stop parsing when there is no more base64 character
|
||||
//
|
||||
// what kind of errors can you have?
|
||||
// can only fail if using bad padding?
|
||||
// if padding is used it must be used properly
|
||||
// you can only have an Expecting padding error (missing one for example)
|
||||
|
||||
/*
|
||||
https://en.wikipedia.org/wiki/Base64
|
||||
Test padding/no-padding
|
||||
|
||||
Encoded
|
||||
YW55IGNhcm5hbCBwbGVhcw== any carnal pleas # [97, 110, 121, 32, 99, 97, 114, 110, 97, 108, 32, 112, 108, 101, 97, 115]
|
||||
*/
|
||||
/// <https://en.wikipedia.org/wiki/Base64>
|
||||
/// Test padding/no-padding
|
||||
///
|
||||
/// Encoded
|
||||
/// YW55IGNhcm5hbCBwbGVhcw== any carnal pleas # [97, 110, 121, 32, 99, 97, 114, 110, 97, 108, 32, 112, 108, 101, 97, 115]
|
||||
|
||||
pub fn parse(reader: &mut Reader) -> Vec<u8> {
|
||||
let mut bytes = vec![];
|
||||
|
@ -16,15 +16,13 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::json::parse as parse_json;
|
||||
use crate::parser::multiline::multiline_string;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::string::backtick_template;
|
||||
|
||||
use super::combinators::*;
|
||||
use super::json::parse as parse_json;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::xml;
|
||||
use super::ParseResult;
|
||||
use crate::parser::{xml, ParseResult};
|
||||
|
||||
pub fn bytes(reader: &mut Reader) -> ParseResult<'static, Bytes> {
|
||||
choice(
|
||||
|
@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::error::*;
|
||||
use super::reader::Reader;
|
||||
use super::{ParseFunc, ParseResult};
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::{ParseFunc, ParseResult};
|
||||
|
||||
pub fn optional<'a, T>(f: ParseFunc<'a, T>, reader: &mut Reader) -> ParseResult<'a, Option<T>> {
|
||||
let start = reader.state.clone();
|
||||
@ -48,7 +48,6 @@ pub fn recover<'a, T>(f: ParseFunc<'a, T>, reader: &mut Reader) -> ParseResult<'
|
||||
}
|
||||
|
||||
pub fn nonrecover<'a, T>(f: ParseFunc<'a, T>, reader: &mut Reader) -> ParseResult<'a, T> {
|
||||
//let start = p.state.clone();
|
||||
match f(reader) {
|
||||
Ok(r) => Ok(r),
|
||||
Err(e) => Err(Error {
|
||||
|
@ -15,27 +15,13 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::ast::*;
|
||||
|
||||
use super::combinators::*;
|
||||
use super::error::*;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::string::*;
|
||||
use super::ParseResult;
|
||||
|
||||
/*
|
||||
|
||||
"cookiepath" expression
|
||||
not described in the official grammar
|
||||
|
||||
cookie-query = "cookie" sp sp* """ cookiepath-expr """
|
||||
cookiepath-expr = cookie-query-name ( "[" sp* cookie-query-attribute sp* "]" )
|
||||
cookiepath-name = <[a-zA-Z0-9{}]+>
|
||||
cookiepath-attribute = Value | Expires | Max-Age | Domain | Path | Secure | HttpOnly | SameSite
|
||||
|
||||
*/
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::ParseResult;
|
||||
|
||||
pub fn cookiepath(reader: &mut Reader) -> ParseResult<'static, CookiePath> {
|
||||
let start = reader.state.pos.clone();
|
||||
@ -82,9 +68,8 @@ fn cookiepath_attribute_name(reader: &mut Reader) -> ParseResult<'static, Cookie
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::{Pos, SourceInfo};
|
||||
|
||||
use super::*;
|
||||
use crate::ast::{Pos, SourceInfo};
|
||||
|
||||
#[test]
|
||||
fn test_cookiepath_simple() {
|
||||
|
@ -16,11 +16,10 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
|
||||
use super::error::*;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::ParseResult;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::ParseResult;
|
||||
|
||||
pub fn parse(reader: &mut Reader) -> ParseResult<'static, Expr> {
|
||||
// let start = p.state.clone();
|
||||
@ -79,9 +78,8 @@ fn variable_name(reader: &mut Reader) -> ParseResult<'static, Variable> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::Pos;
|
||||
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_expr() {
|
||||
|
@ -15,12 +15,10 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use super::error::*;
|
||||
use super::reader::Reader;
|
||||
|
||||
use super::ParseResult;
|
||||
use crate::ast::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::ParseResult;
|
||||
|
||||
pub fn parse(reader: &mut Reader) -> ParseResult<'static, Filename> {
|
||||
// This is an absolute file
|
||||
@ -49,9 +47,8 @@ pub fn parse(reader: &mut Reader) -> ParseResult<'static, Filename> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::Pos;
|
||||
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_filename() {
|
||||
|
@ -165,11 +165,10 @@ fn url_decode_filter(reader: &mut Reader) -> ParseResult<'static, FilterValue> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::parser::ParseError;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_count() {
|
||||
let mut reader = Reader::init("count");
|
||||
|
@ -16,14 +16,11 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::{JsonListElement, JsonObjectElement, JsonValue, Pos, SourceInfo, Template};
|
||||
|
||||
use super::combinators::*;
|
||||
use super::error;
|
||||
use super::primitives::*;
|
||||
use super::reader::*;
|
||||
use super::template::*;
|
||||
use super::ParseResult;
|
||||
use crate::parser::expr;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::*;
|
||||
use crate::parser::template::*;
|
||||
use crate::parser::{error, expr, ParseResult};
|
||||
|
||||
pub fn parse(reader: &mut Reader) -> ParseResult<'static, JsonValue> {
|
||||
choice(
|
||||
|
@ -24,10 +24,10 @@ pub fn parse_hurl_file(s: &str) -> ParseResult<'static, HurlFile> {
|
||||
}
|
||||
|
||||
pub use self::error::{Error, ParseError};
|
||||
pub use self::json::boolean_value as parse_json_boolean;
|
||||
pub use self::json::null_value as parse_json_null;
|
||||
pub use self::json::number_value as parse_json_number;
|
||||
pub use self::json::parse as parse_json;
|
||||
pub use self::json::{
|
||||
boolean_value as parse_json_boolean, null_value as parse_json_null,
|
||||
number_value as parse_json_number, parse as parse_json,
|
||||
};
|
||||
pub use self::reader::Reader;
|
||||
pub use self::template::templatize;
|
||||
use crate::ast::HurlFile;
|
||||
|
@ -15,13 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use super::combinators::*;
|
||||
use super::reader::Reader;
|
||||
use super::ParseResult;
|
||||
use crate::ast::*;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::json::object_value;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::{template, Error, ParseError};
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::{template, Error, ParseError, ParseResult};
|
||||
|
||||
pub fn multiline_string(reader: &mut Reader) -> ParseResult<'static, MultilineString> {
|
||||
try_literal("```", reader)?;
|
||||
|
@ -17,15 +17,14 @@
|
||||
*/
|
||||
use crate::ast::VersionValue::VersionAny;
|
||||
use crate::ast::*;
|
||||
|
||||
use super::bytes::*;
|
||||
use super::combinators::*;
|
||||
use super::error::*;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::sections::*;
|
||||
use super::url::url;
|
||||
use super::ParseResult;
|
||||
use crate::parser::bytes::*;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::sections::*;
|
||||
use crate::parser::url::url;
|
||||
use crate::parser::ParseResult;
|
||||
|
||||
pub fn hurl_file(reader: &mut Reader) -> ParseResult<'static, HurlFile> {
|
||||
let entries = zero_or_more(entry, reader)?;
|
||||
|
@ -15,15 +15,13 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::ast::*;
|
||||
|
||||
use super::combinators::*;
|
||||
use super::error::*;
|
||||
use super::predicate_value::predicate_value;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::ParseResult;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::predicate_value::predicate_value;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::ParseResult;
|
||||
|
||||
pub fn predicate(reader: &mut Reader) -> ParseResult<'static, Predicate> {
|
||||
let (not, space0) = predicate_not(reader);
|
||||
@ -361,9 +359,8 @@ fn exist_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncVal
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::Pos;
|
||||
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_predicate_not() {
|
||||
|
@ -15,17 +15,13 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::ast::*;
|
||||
|
||||
use super::combinators::*;
|
||||
use super::expr;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::string::*;
|
||||
use super::ParseResult;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::multiline::multiline_string;
|
||||
use crate::parser::{Error, ParseError};
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{expr, Error, ParseError, ParseResult};
|
||||
|
||||
pub fn predicate_value(reader: &mut Reader) -> ParseResult<'static, PredicateValue> {
|
||||
choice(
|
||||
|
@ -16,14 +16,11 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
|
||||
use super::base64;
|
||||
use super::combinators::*;
|
||||
use super::error::*;
|
||||
use super::filename;
|
||||
use super::reader::Reader;
|
||||
use super::string::*;
|
||||
use super::ParseResult;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{base64, filename, ParseResult};
|
||||
|
||||
pub fn space(reader: &mut Reader) -> ParseResult<'static, Whitespace> {
|
||||
let start = reader.state.clone();
|
||||
@ -595,9 +592,8 @@ pub fn hex_digit(reader: &mut Reader) -> ParseResult<'static, u32> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::Pos;
|
||||
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_space() {
|
||||
|
@ -16,14 +16,12 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::{Error, ParseError};
|
||||
|
||||
use super::combinators::*;
|
||||
use super::cookiepath::cookiepath;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::string::*;
|
||||
use super::ParseResult;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::cookiepath::cookiepath;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{Error, ParseError, ParseResult};
|
||||
|
||||
pub fn query(reader: &mut Reader) -> ParseResult<'static, Query> {
|
||||
let start = reader.state.pos.clone();
|
||||
|
@ -16,17 +16,15 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::filter::filters;
|
||||
|
||||
use super::combinators::*;
|
||||
use super::error::*;
|
||||
use super::filename;
|
||||
use super::predicate::predicate;
|
||||
use super::primitives::*;
|
||||
use super::query::query;
|
||||
use super::reader::Reader;
|
||||
use super::string::*;
|
||||
use super::ParseResult;
|
||||
use crate::parser::predicate::predicate;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::query::query;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{filename, ParseResult};
|
||||
|
||||
pub fn request_sections(reader: &mut Reader) -> ParseResult<'static, Vec<Section>> {
|
||||
let sections = zero_or_more(request_section, reader)?;
|
||||
|
@ -16,18 +16,16 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::{template, ParseResult};
|
||||
|
||||
use super::combinators::*;
|
||||
use super::error::*;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::template;
|
||||
use super::ParseResult;
|
||||
|
||||
// Steps:
|
||||
// 1- parse String until end of stream or end of line or #
|
||||
// the string does not contain trailing space
|
||||
// 2- templatize
|
||||
/// Steps:
|
||||
/// 1- parse String until end of stream or end of line or #
|
||||
/// the string does not contain trailing space
|
||||
/// 2- templatize
|
||||
pub fn unquoted_template(reader: &mut Reader) -> ParseResult<'static, Template> {
|
||||
let start = reader.state.clone();
|
||||
let mut chars = vec![];
|
||||
@ -328,9 +326,10 @@ fn hex_value(reader: &mut Reader) -> ParseResult<'static, u32> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_unquoted_template_empty() {
|
||||
let mut reader = Reader::init("");
|
||||
|
@ -15,13 +15,9 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::ast::{Pos, SourceInfo, TemplateElement};
|
||||
|
||||
use super::error;
|
||||
use super::expr;
|
||||
use super::reader::*;
|
||||
use super::ParseResult;
|
||||
use crate::parser::reader::*;
|
||||
use crate::parser::{error, expr, ParseResult};
|
||||
|
||||
pub struct EncodedString {
|
||||
pub source_info: SourceInfo,
|
||||
@ -132,9 +128,8 @@ pub fn templatize(encoded_string: EncodedString) -> ParseResult<'static, Vec<Tem
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::{Expr, Variable, Whitespace};
|
||||
|
||||
use super::*;
|
||||
use crate::ast::{Expr, Variable, Whitespace};
|
||||
|
||||
#[test]
|
||||
fn test_templatize_empty_string() {
|
||||
|
@ -16,12 +16,10 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::*;
|
||||
|
||||
use super::error::*;
|
||||
use super::expr;
|
||||
use super::primitives::*;
|
||||
use super::reader::Reader;
|
||||
use super::ParseResult;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::{expr, ParseResult};
|
||||
|
||||
pub fn url(reader: &mut Reader) -> ParseResult<'static, Template> {
|
||||
// Can not be json-encoded, nor empty.
|
||||
|
@ -18,10 +18,9 @@
|
||||
use sxd_document::parser;
|
||||
|
||||
use crate::ast::Pos;
|
||||
|
||||
use super::error::*;
|
||||
use super::reader::Reader;
|
||||
use super::ParseResult;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::reader::Reader;
|
||||
use crate::parser::ParseResult;
|
||||
|
||||
pub fn parse(reader: &mut Reader) -> ParseResult<'static, String> {
|
||||
let mut buf = String::from("");
|
||||
|
@ -15,11 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::JsonValue;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
use hurl_core::ast::JsonValue;
|
||||
|
||||
#[test]
|
||||
fn debug() {
|
||||
let content = r#""{{name}}""#;
|
||||
|
@ -15,12 +15,12 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::cli::CliError;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
use crate::cli::CliError;
|
||||
|
||||
/// Remove BOM from the input bytes
|
||||
fn strip_bom(bytes: &mut Vec<u8>) {
|
||||
if bytes.starts_with(&[0xefu8, 0xbb, 0xbf]) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
*
|
||||
*/
|
||||
use colored::*;
|
||||
|
||||
use hurl_core::error::Error;
|
||||
use hurl_core::parser;
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use clap::ArgMatches;
|
||||
|
||||
pub fn get_string(matches: &ArgMatches, name: &str) -> Option<String> {
|
||||
|
@ -15,10 +15,8 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::serialize_json::*;
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
pub use self::json::format as format_json;
|
||||
pub use self::text::format as format_text;
|
||||
pub use self::token::{Token, Tokenizable};
|
||||
|
@ -16,10 +16,9 @@
|
||||
*
|
||||
*/
|
||||
use colored::*;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::token::*;
|
||||
use crate::format::token::*;
|
||||
|
||||
pub fn format(hurl_file: HurlFile, color: bool) -> String {
|
||||
let mut buffer = String::from("");
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use hurl_core::ast::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::error::Error;
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
pub use rules::{check_hurl_file, lint_hurl_file};
|
||||
|
||||
pub use self::core::{Error, LinterError};
|
||||
pub use rules::{check_hurl_file, lint_hurl_file};
|
||||
mod core;
|
||||
mod error;
|
||||
mod rules;
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
|
||||
use super::core::{Error, LinterError};
|
||||
use crate::linter::core::{Error, LinterError};
|
||||
|
||||
/// Returns lint errors for the `hurl_file`.
|
||||
pub fn check_hurl_file(hurl_file: &HurlFile) -> Vec<Error> {
|
||||
|
@ -15,17 +15,14 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use std::io::Write;
|
||||
use std::io::{self, Read};
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
|
||||
use atty::Stream;
|
||||
use clap::ArgAction;
|
||||
|
||||
use hurl_core::parser;
|
||||
use hurlfmt::format;
|
||||
use hurlfmt::{cli, linter};
|
||||
use hurlfmt::{cli, format, linter};
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
pub fn init_colored() {
|
||||
|
@ -18,12 +18,11 @@
|
||||
|
||||
use std::fs;
|
||||
|
||||
use proptest::prelude::prop::test_runner::TestRunner;
|
||||
use proptest::prelude::*;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::parser::{parse_json, Reader};
|
||||
use hurlfmt::format::{Token, Tokenizable};
|
||||
use proptest::prelude::prop::test_runner::TestRunner;
|
||||
use proptest::prelude::*;
|
||||
|
||||
fn whitespace() -> BoxedStrategy<String> {
|
||||
prop_oneof![
|
||||
|
4
rustfmt.toml
Normal file
4
rustfmt.toml
Normal file
@ -0,0 +1,4 @@
|
||||
# Reorganize import. Must be used with nightly.
|
||||
# See <https://rust-lang.github.io/rustfmt> for option description
|
||||
#group_imports = "StdExternalCrate"
|
||||
#imports_granularity = "Module"
|
Loading…
Reference in New Issue
Block a user