Do use super::*;
instead of use crate::common::*;
(#1239)
This commit is contained in:
parent
180672b0e1
commit
01fae9b1e4
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// An alias, e.g. `name := target`
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use CompileErrorKind::*;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// An assignment, e.g `foo := bar`
|
||||
pub(crate) type Assignment<'src> = Binding<'src, Expression<'src>>;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use CompileErrorKind::*;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// The top-level type produced by the parser. Not all successful parses result
|
||||
/// in valid justfiles, so additional consistency checks and name resolution
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// A binding of `name` to `value`
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use ansi_term::{ANSIGenericString, Color::*, Prefix, Style, Suffix};
|
||||
use atty::Stream;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) trait ColorDisplay {
|
||||
fn color_display<'a>(&'a self, color: Color) -> Wrapper<'a>
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) trait CommandExt {
|
||||
fn export(&mut self, settings: &Settings, dotenv: &BTreeMap<String, String>, scope: &Scope);
|
||||
|
@ -1,86 +0,0 @@
|
||||
// stdlib
|
||||
pub(crate) use std::{
|
||||
cmp,
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
env,
|
||||
ffi::{OsStr, OsString},
|
||||
fmt::{self, Debug, Display, Formatter},
|
||||
fs,
|
||||
io::{self, Cursor, Write},
|
||||
iter::{self, FromIterator},
|
||||
mem,
|
||||
ops::{Index, Range, RangeInclusive},
|
||||
path::{self, Path, PathBuf},
|
||||
process::{self, Command, ExitStatus, Stdio},
|
||||
rc::Rc,
|
||||
str::{self, Chars},
|
||||
sync::{Mutex, MutexGuard},
|
||||
usize, vec,
|
||||
};
|
||||
|
||||
// dependencies
|
||||
pub(crate) use ::{
|
||||
camino::Utf8Path,
|
||||
derivative::Derivative,
|
||||
edit_distance::edit_distance,
|
||||
lexiclean::Lexiclean,
|
||||
libc::EXIT_FAILURE,
|
||||
log::{info, warn},
|
||||
regex::Regex,
|
||||
serde::{
|
||||
ser::{SerializeMap, SerializeSeq},
|
||||
Serialize, Serializer,
|
||||
},
|
||||
snafu::{ResultExt, Snafu},
|
||||
strum::{Display, EnumString, IntoStaticStr},
|
||||
typed_arena::Arena,
|
||||
unicode_width::{UnicodeWidthChar, UnicodeWidthStr},
|
||||
};
|
||||
|
||||
// modules
|
||||
pub(crate) use crate::{completions, config, config_error, keyed};
|
||||
|
||||
// functions
|
||||
pub(crate) use crate::{load_dotenv::load_dotenv, output::output, unindent::unindent};
|
||||
|
||||
// traits
|
||||
pub(crate) use crate::{
|
||||
color_display::ColorDisplay, command_ext::CommandExt, keyed::Keyed, ordinal::Ordinal,
|
||||
platform_interface::PlatformInterface, range_ext::RangeExt,
|
||||
};
|
||||
|
||||
// structs and enums
|
||||
pub(crate) use crate::{
|
||||
alias::Alias, analyzer::Analyzer, assignment::Assignment,
|
||||
assignment_resolver::AssignmentResolver, ast::Ast, binding::Binding, color::Color,
|
||||
compile_error::CompileError, compile_error_kind::CompileErrorKind,
|
||||
conditional_operator::ConditionalOperator, config::Config, config_error::ConfigError,
|
||||
count::Count, delimiter::Delimiter, dependency::Dependency, dump_format::DumpFormat,
|
||||
enclosure::Enclosure, error::Error, evaluator::Evaluator, expression::Expression,
|
||||
fragment::Fragment, function::Function, function_context::FunctionContext,
|
||||
interrupt_guard::InterruptGuard, interrupt_handler::InterruptHandler, item::Item,
|
||||
justfile::Justfile, keyword::Keyword, lexer::Lexer, line::Line, list::List, loader::Loader,
|
||||
name::Name, output_error::OutputError, parameter::Parameter, parameter_kind::ParameterKind,
|
||||
parser::Parser, platform::Platform, position::Position, positional::Positional, recipe::Recipe,
|
||||
recipe_context::RecipeContext, recipe_resolver::RecipeResolver, scope::Scope, search::Search,
|
||||
search_config::SearchConfig, search_error::SearchError, set::Set, setting::Setting,
|
||||
settings::Settings, shebang::Shebang, shell::Shell, show_whitespace::ShowWhitespace,
|
||||
string_kind::StringKind, string_literal::StringLiteral, subcommand::Subcommand,
|
||||
suggestion::Suggestion, table::Table, thunk::Thunk, token::Token, token_kind::TokenKind,
|
||||
unresolved_dependency::UnresolvedDependency, unresolved_recipe::UnresolvedRecipe,
|
||||
use_color::UseColor, variables::Variables, verbosity::Verbosity, warning::Warning,
|
||||
};
|
||||
|
||||
// type aliases
|
||||
pub(crate) type CompileResult<'a, T> = Result<T, CompileError<'a>>;
|
||||
pub(crate) type ConfigResult<T> = Result<T, ConfigError>;
|
||||
pub(crate) type RunResult<'a, T> = Result<T, Error<'a>>;
|
||||
pub(crate) type SearchResult<T> = Result<T, SearchError>;
|
||||
|
||||
// modules used in tests
|
||||
#[cfg(test)]
|
||||
pub(crate) use crate::testing;
|
||||
|
||||
// structs and enums used in tests
|
||||
#[cfg(test)]
|
||||
pub(crate) use crate::{node::Node, tree::Tree};
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub(crate) struct CompileError<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub(crate) enum CompileErrorKind<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct Compiler;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// A conditional expression operator.
|
||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, ArgSettings};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[snafu(visibility(pub(crate)), context(suffix(Context)))]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub struct Count<T: Display>(pub T, pub usize);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(PartialEq, Debug, Serialize)]
|
||||
pub(crate) struct Dependency<'src> {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// `Self` cannot be used where type takes generic arguments
|
||||
#![allow(clippy::use_self)]
|
||||
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub struct Enclosure<T: Display> {
|
||||
enclosure: &'static str,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum Error<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct Evaluator<'src: 'run, 'run> {
|
||||
assignments: Option<&'run Table<'src, Assignment<'src>>>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// An expression. Note that the Just language grammar has both an `expression`
|
||||
/// production of additions (`a + b`) and values, and a `value` production of
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// A line fragment consisting either of…
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use Function::*;
|
||||
pub(crate) enum Function {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct FunctionContext<'run> {
|
||||
pub(crate) dotenv: &'run BTreeMap<String, String>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) fn compile(text: &str) {
|
||||
if let Err(error) = Parser::parse(text) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct InterruptGuard;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct InterruptHandler {
|
||||
blocks: u32,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// A single top-level item
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) trait Keyed<'key> {
|
||||
fn key(&self) -> &'key str;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, IntoStaticStr, Display, Copy, Clone, EnumString)]
|
||||
#[strum(serialize_all = "kebab_case")]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use CompileErrorKind::*;
|
||||
use TokenKind::*;
|
||||
|
70
src/lib.rs
70
src/lib.rs
@ -14,12 +14,81 @@
|
||||
clippy::wildcard_imports
|
||||
)]
|
||||
|
||||
pub(crate) use {
|
||||
crate::{
|
||||
alias::Alias, analyzer::Analyzer, assignment::Assignment,
|
||||
assignment_resolver::AssignmentResolver, ast::Ast, binding::Binding, color::Color,
|
||||
color_display::ColorDisplay, command_ext::CommandExt, compile_error::CompileError,
|
||||
compile_error_kind::CompileErrorKind, conditional_operator::ConditionalOperator,
|
||||
config::Config, config_error::ConfigError, count::Count, delimiter::Delimiter,
|
||||
dependency::Dependency, dump_format::DumpFormat, enclosure::Enclosure, error::Error,
|
||||
evaluator::Evaluator, expression::Expression, fragment::Fragment, function::Function,
|
||||
function_context::FunctionContext, interrupt_guard::InterruptGuard,
|
||||
interrupt_handler::InterruptHandler, item::Item, justfile::Justfile, keyed::Keyed,
|
||||
keyword::Keyword, lexer::Lexer, line::Line, list::List, load_dotenv::load_dotenv,
|
||||
loader::Loader, name::Name, ordinal::Ordinal, output::output, output_error::OutputError,
|
||||
parameter::Parameter, parameter_kind::ParameterKind, parser::Parser, platform::Platform,
|
||||
platform_interface::PlatformInterface, position::Position, positional::Positional,
|
||||
range_ext::RangeExt, recipe::Recipe, recipe_context::RecipeContext,
|
||||
recipe_resolver::RecipeResolver, scope::Scope, search::Search, search_config::SearchConfig,
|
||||
search_error::SearchError, set::Set, setting::Setting, settings::Settings, shebang::Shebang,
|
||||
shell::Shell, show_whitespace::ShowWhitespace, string_kind::StringKind,
|
||||
string_literal::StringLiteral, subcommand::Subcommand, suggestion::Suggestion, table::Table,
|
||||
thunk::Thunk, token::Token, token_kind::TokenKind, unresolved_dependency::UnresolvedDependency,
|
||||
unresolved_recipe::UnresolvedRecipe, use_color::UseColor, variables::Variables,
|
||||
verbosity::Verbosity, warning::Warning,
|
||||
},
|
||||
std::{
|
||||
cmp,
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
env,
|
||||
ffi::{OsStr, OsString},
|
||||
fmt::{self, Debug, Display, Formatter},
|
||||
fs,
|
||||
io::{self, Cursor, Write},
|
||||
iter::{self, FromIterator},
|
||||
mem,
|
||||
ops::{Index, Range, RangeInclusive},
|
||||
path::{self, Path, PathBuf},
|
||||
process::{self, Command, ExitStatus, Stdio},
|
||||
rc::Rc,
|
||||
str::{self, Chars},
|
||||
sync::{Mutex, MutexGuard},
|
||||
usize, vec,
|
||||
},
|
||||
{
|
||||
camino::Utf8Path,
|
||||
derivative::Derivative,
|
||||
edit_distance::edit_distance,
|
||||
lexiclean::Lexiclean,
|
||||
libc::EXIT_FAILURE,
|
||||
log::{info, warn},
|
||||
regex::Regex,
|
||||
serde::{
|
||||
ser::{SerializeMap, SerializeSeq},
|
||||
Serialize, Serializer,
|
||||
},
|
||||
snafu::{ResultExt, Snafu},
|
||||
strum::{Display, EnumString, IntoStaticStr},
|
||||
typed_arena::Arena,
|
||||
unicode_width::{UnicodeWidthChar, UnicodeWidthStr},
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) use crate::{node::Node, tree::Tree};
|
||||
|
||||
pub use crate::run::run;
|
||||
|
||||
// Used in integration tests.
|
||||
#[doc(hidden)]
|
||||
pub use unindent::unindent;
|
||||
|
||||
pub(crate) type CompileResult<'a, T> = Result<T, CompileError<'a>>;
|
||||
pub(crate) type ConfigResult<T> = Result<T, ConfigError>;
|
||||
pub(crate) type RunResult<'a, T> = Result<T, Error<'a>>;
|
||||
pub(crate) type SearchResult<T> = Result<T, SearchError>;
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
@ -52,7 +121,6 @@ mod binding;
|
||||
mod color;
|
||||
mod color_display;
|
||||
mod command_ext;
|
||||
mod common;
|
||||
mod compile_error;
|
||||
mod compile_error_kind;
|
||||
mod compiler;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// A single line in a recipe body, consisting of any number of `Fragment`s.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
|
@ -1,7 +1,7 @@
|
||||
// `Self` cannot be used where type takes generic arguments
|
||||
#![allow(clippy::use_self)]
|
||||
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub struct List<T: Display, I: Iterator<Item = T> + Clone> {
|
||||
conjunction: &'static str,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
const DEFAULT_DOTENV_FILENAME: &str = ".env";
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct Loader {
|
||||
arena: Arena<String>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// A name. This is effectively just a `Token` of kind `Identifier`, but we give
|
||||
/// it its own type for clarity.
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// Methods common to all AST nodes. Currently only used in parser unit tests.
|
||||
pub(crate) trait Node<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// Run a command and return the data it wrote to stdout as a string
|
||||
pub(crate) fn output(mut command: Command) -> Result<String, OutputError> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum OutputError {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// A single function parameter
|
||||
#[derive(PartialEq, Debug, Clone, Serialize)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// Parameters can either be…
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use TokenKind::*;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct Platform;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) trait PlatformInterface {
|
||||
/// Construct a command equivalent to running the script at `path` with the
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// A struct containing the parsed representation of positional command-line
|
||||
/// arguments, i.e. arguments that are not flags, options, or the subcommand.
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) trait RangeExt<T> {
|
||||
fn range_contains(&self, i: &T) -> bool;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use std::process::{ExitStatus, Stdio};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct RecipeContext<'src: 'run, 'run> {
|
||||
pub(crate) config: &'run Config,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use CompileErrorKind::*;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub fn run() -> Result<(), i32> {
|
||||
#[cfg(windows)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Scope<'src: 'run, 'run> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use std::path::Component;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// Controls how `just` will search for the justfile.
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[snafu(visibility(pub(crate)))]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct Set<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) enum Setting<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) const DEFAULT_SHELL: &str = "sh";
|
||||
pub(crate) const DEFAULT_SHELL_ARGS: &[&str] = &["-cu"];
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
pub(crate) struct Shell<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
/// String wrapper that uses nonblank characters to display spaces and tabs
|
||||
pub struct ShowWhitespace<'str>(pub &'str str);
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)]
|
||||
pub(crate) struct StringKind {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub(crate) struct StringLiteral<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
const INIT_JUSTFILE: &str = "default:\n echo 'Hello, world!'\n";
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub(crate) struct Suggestion<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use std::collections::btree_map;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use crate::compiler::Compiler;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug, Clone, PartialEq = "feature_allow_slow_enum")]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
pub(crate) struct Token<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)]
|
||||
pub(crate) enum TokenKind {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use std::{borrow::Cow, mem};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub(crate) struct UnresolvedDependency<'src> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) type UnresolvedRecipe<'src> = Recipe<'src, UnresolvedDependency<'src>>;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) struct Variables<'expression, 'src> {
|
||||
stack: Vec<&'expression Expression<'src>>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) enum Warning {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn allow_duplicate_recipes() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) fn assert_stdout(output: &Output, stdout: &str) {
|
||||
assert_success(output);
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
pub(crate) fn assert_success(output: &Output) {
|
||||
if !output.status.success() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn ignore_leading_byte_order_mark() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn print_changelog() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
test! {
|
||||
name: env,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
test! {
|
||||
name: long,
|
||||
|
@ -1,30 +0,0 @@
|
||||
pub(crate) use std::{
|
||||
collections::BTreeMap,
|
||||
env::{self, consts::EXE_SUFFIX},
|
||||
error::Error,
|
||||
fmt::Debug,
|
||||
fs,
|
||||
io::Write,
|
||||
iter,
|
||||
path::{Path, PathBuf, MAIN_SEPARATOR},
|
||||
process::{Command, Output, Stdio},
|
||||
str,
|
||||
};
|
||||
|
||||
pub(crate) use ::{
|
||||
cradle::input::Input,
|
||||
executable_path::executable_path,
|
||||
just::unindent,
|
||||
libc::{EXIT_FAILURE, EXIT_SUCCESS},
|
||||
pretty_assertions::Comparison,
|
||||
regex::Regex,
|
||||
serde_json::{json, Value},
|
||||
tempfile::TempDir,
|
||||
temptree::{temptree, tree, Tree},
|
||||
which::which,
|
||||
yaml_rust::YamlLoader,
|
||||
};
|
||||
|
||||
pub(crate) use crate::{
|
||||
assert_stdout::assert_stdout, assert_success::assert_success, tempdir::tempdir, test::Test,
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn output() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
test! {
|
||||
name: then_branch_unevaluated,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
test! {
|
||||
name: mismatched_delimiter,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn dotenv() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
const JUSTFILE: &str = "Yooooooo, hopefully this never becomes valid syntax.";
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn export_recipe() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
test! {
|
||||
name: expected_keyword,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
test! {
|
||||
name: evaluate,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn examples() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn runs_recipe_in_parent_if_not_found_in_current() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
test! {
|
||||
name: unstable_not_passed,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
test! {
|
||||
name: test_os_arch_functions_in_interpolation,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
const EXPECTED: &str = "default:\n echo 'Hello, world!'\n";
|
||||
|
||||
|
@ -1,90 +1,87 @@
|
||||
#[cfg(unix)]
|
||||
mod unix {
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
fn kill(process_id: u32) {
|
||||
unsafe {
|
||||
libc::kill(process_id as i32, libc::SIGINT);
|
||||
}
|
||||
fn kill(process_id: u32) {
|
||||
unsafe {
|
||||
libc::kill(process_id as i32, libc::SIGINT);
|
||||
}
|
||||
}
|
||||
|
||||
fn interrupt_test(arguments: &[&str], justfile: &str) {
|
||||
let tmp = tempdir();
|
||||
let mut justfile_path = tmp.path().to_path_buf();
|
||||
justfile_path.push("justfile");
|
||||
fs::write(justfile_path, unindent(justfile)).unwrap();
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
let mut child = Command::new(&executable_path("just"))
|
||||
.current_dir(&tmp)
|
||||
.args(arguments)
|
||||
.spawn()
|
||||
.expect("just invocation failed");
|
||||
|
||||
while start.elapsed() < Duration::from_millis(500) {}
|
||||
|
||||
kill(child.id());
|
||||
|
||||
let status = child.wait().unwrap();
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
if elapsed > Duration::from_secs(2) {
|
||||
panic!("process returned too late: {:?}", elapsed);
|
||||
}
|
||||
|
||||
fn interrupt_test(arguments: &[&str], justfile: &str) {
|
||||
let tmp = tempdir();
|
||||
let mut justfile_path = tmp.path().to_path_buf();
|
||||
justfile_path.push("justfile");
|
||||
fs::write(justfile_path, unindent(justfile)).unwrap();
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
let mut child = Command::new(&executable_path("just"))
|
||||
.current_dir(&tmp)
|
||||
.args(arguments)
|
||||
.spawn()
|
||||
.expect("just invocation failed");
|
||||
|
||||
while start.elapsed() < Duration::from_millis(500) {}
|
||||
|
||||
kill(child.id());
|
||||
|
||||
let status = child.wait().unwrap();
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
if elapsed > Duration::from_secs(2) {
|
||||
panic!("process returned too late: {:?}", elapsed);
|
||||
}
|
||||
|
||||
if elapsed < Duration::from_millis(100) {
|
||||
panic!("process returned too early : {:?}", elapsed);
|
||||
}
|
||||
|
||||
assert_eq!(status.code(), Some(130));
|
||||
if elapsed < Duration::from_millis(100) {
|
||||
panic!("process returned too early : {:?}", elapsed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn interrupt_shebang() {
|
||||
interrupt_test(
|
||||
&[],
|
||||
"
|
||||
assert_eq!(status.code(), Some(130));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn interrupt_shebang() {
|
||||
interrupt_test(
|
||||
&[],
|
||||
"
|
||||
default:
|
||||
#!/usr/bin/env sh
|
||||
sleep 1
|
||||
",
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn interrupt_line() {
|
||||
interrupt_test(
|
||||
&[],
|
||||
"
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn interrupt_line() {
|
||||
interrupt_test(
|
||||
&[],
|
||||
"
|
||||
default:
|
||||
@sleep 1
|
||||
",
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn interrupt_backtick() {
|
||||
interrupt_test(
|
||||
&[],
|
||||
"
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn interrupt_backtick() {
|
||||
interrupt_test(
|
||||
&[],
|
||||
"
|
||||
foo := `sleep 1`
|
||||
|
||||
default:
|
||||
@echo {{foo}}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn interrupt_command() {
|
||||
interrupt_test(&["--command", "sleep", "1"], "");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn interrupt_command() {
|
||||
interrupt_test(&["--command", "sleep", "1"], "");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
#[cfg(unix)]
|
||||
fn convert_native_path(path: &Path) -> String {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::*;
|
||||
use super::*;
|
||||
|
||||
fn test(justfile: &str, value: Value) {
|
||||
Test::new()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user