Do use super::*; instead of use crate::common::*; (#1239)

This commit is contained in:
Casey Rodarmor 2022-06-18 21:56:31 -07:00 committed by GitHub
parent 180672b0e1
commit 01fae9b1e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
119 changed files with 279 additions and 301 deletions

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// An alias, e.g. `name := target` /// An alias, e.g. `name := target`
#[derive(Debug, PartialEq, Clone, Serialize)] #[derive(Debug, PartialEq, Clone, Serialize)]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use CompileErrorKind::*; use CompileErrorKind::*;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// An assignment, e.g `foo := bar` /// An assignment, e.g `foo := bar`
pub(crate) type Assignment<'src> = Binding<'src, Expression<'src>>; pub(crate) type Assignment<'src> = Binding<'src, Expression<'src>>;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use CompileErrorKind::*; use CompileErrorKind::*;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// The top-level type produced by the parser. Not all successful parses result /// The top-level type produced by the parser. Not all successful parses result
/// in valid justfiles, so additional consistency checks and name resolution /// in valid justfiles, so additional consistency checks and name resolution

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// A binding of `name` to `value` /// A binding of `name` to `value`
#[derive(Debug, Clone, PartialEq, Serialize)] #[derive(Debug, Clone, PartialEq, Serialize)]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use ansi_term::{ANSIGenericString, Color::*, Prefix, Style, Suffix}; use ansi_term::{ANSIGenericString, Color::*, Prefix, Style, Suffix};
use atty::Stream; use atty::Stream;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) trait ColorDisplay { pub(crate) trait ColorDisplay {
fn color_display<'a>(&'a self, color: Color) -> Wrapper<'a> fn color_display<'a>(&'a self, color: Color) -> Wrapper<'a>

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) trait CommandExt { pub(crate) trait CommandExt {
fn export(&mut self, settings: &Settings, dotenv: &BTreeMap<String, String>, scope: &Scope); fn export(&mut self, settings: &Settings, dotenv: &BTreeMap<String, String>, scope: &Scope);

View File

@ -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};

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub(crate) struct CompileError<'src> { pub(crate) struct CompileError<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub(crate) enum CompileErrorKind<'src> { pub(crate) enum CompileErrorKind<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct Compiler; pub(crate) struct Compiler;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// A conditional expression operator. /// A conditional expression operator.
#[derive(PartialEq, Debug, Copy, Clone)] #[derive(PartialEq, Debug, Copy, Clone)]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, ArgSettings}; use clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, ArgSettings};

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, Snafu)] #[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)), context(suffix(Context)))] #[snafu(visibility(pub(crate)), context(suffix(Context)))]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub struct Count<T: Display>(pub T, pub usize); pub struct Count<T: Display>(pub T, pub usize);

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(PartialEq, Debug, Serialize)] #[derive(PartialEq, Debug, Serialize)]
pub(crate) struct Dependency<'src> { pub(crate) struct Dependency<'src> {

View File

@ -1,7 +1,7 @@
// `Self` cannot be used where type takes generic arguments // `Self` cannot be used where type takes generic arguments
#![allow(clippy::use_self)] #![allow(clippy::use_self)]
use crate::common::*; use super::*;
pub struct Enclosure<T: Display> { pub struct Enclosure<T: Display> {
enclosure: &'static str, enclosure: &'static str,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug)] #[derive(Debug)]
pub(crate) enum Error<'src> { pub(crate) enum Error<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct Evaluator<'src: 'run, 'run> { pub(crate) struct Evaluator<'src: 'run, 'run> {
assignments: Option<&'run Table<'src, Assignment<'src>>>, assignments: Option<&'run Table<'src, Assignment<'src>>>,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// An expression. Note that the Just language grammar has both an `expression` /// An expression. Note that the Just language grammar has both an `expression`
/// production of additions (`a + b`) and values, and a `value` production of /// production of additions (`a + b`) and values, and a `value` production of

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// A line fragment consisting either of… /// A line fragment consisting either of…
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Debug, Clone)]

View File

@ -1,7 +1,7 @@
#![allow(unknown_lints)] #![allow(unknown_lints)]
#![allow(clippy::unnecessary_wraps)] #![allow(clippy::unnecessary_wraps)]
use crate::common::*; use super::*;
use Function::*; use Function::*;
pub(crate) enum Function { pub(crate) enum Function {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct FunctionContext<'run> { pub(crate) struct FunctionContext<'run> {
pub(crate) dotenv: &'run BTreeMap<String, String>, pub(crate) dotenv: &'run BTreeMap<String, String>,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) fn compile(text: &str) { pub(crate) fn compile(text: &str) {
if let Err(error) = Parser::parse(text) { if let Err(error) = Parser::parse(text) {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct InterruptGuard; pub(crate) struct InterruptGuard;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct InterruptHandler { pub(crate) struct InterruptHandler {
blocks: u32, blocks: u32,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// A single top-level item /// A single top-level item
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use serde::Serialize; use serde::Serialize;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) trait Keyed<'key> { pub(crate) trait Keyed<'key> {
fn key(&self) -> &'key str; fn key(&self) -> &'key str;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, Eq, PartialEq, IntoStaticStr, Display, Copy, Clone, EnumString)] #[derive(Debug, Eq, PartialEq, IntoStaticStr, Display, Copy, Clone, EnumString)]
#[strum(serialize_all = "kebab_case")] #[strum(serialize_all = "kebab_case")]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use CompileErrorKind::*; use CompileErrorKind::*;
use TokenKind::*; use TokenKind::*;

View File

@ -14,12 +14,81 @@
clippy::wildcard_imports 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; pub use crate::run::run;
// Used in integration tests. // Used in integration tests.
#[doc(hidden)] #[doc(hidden)]
pub use unindent::unindent; 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] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
@ -52,7 +121,6 @@ mod binding;
mod color; mod color;
mod color_display; mod color_display;
mod command_ext; mod command_ext;
mod common;
mod compile_error; mod compile_error;
mod compile_error_kind; mod compile_error_kind;
mod compiler; mod compiler;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// A single line in a recipe body, consisting of any number of `Fragment`s. /// A single line in a recipe body, consisting of any number of `Fragment`s.
#[derive(Debug, Clone, PartialEq, Serialize)] #[derive(Debug, Clone, PartialEq, Serialize)]

View File

@ -1,7 +1,7 @@
// `Self` cannot be used where type takes generic arguments // `Self` cannot be used where type takes generic arguments
#![allow(clippy::use_self)] #![allow(clippy::use_self)]
use crate::common::*; use super::*;
pub struct List<T: Display, I: Iterator<Item = T> + Clone> { pub struct List<T: Display, I: Iterator<Item = T> + Clone> {
conjunction: &'static str, conjunction: &'static str,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
const DEFAULT_DOTENV_FILENAME: &str = ".env"; const DEFAULT_DOTENV_FILENAME: &str = ".env";

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct Loader { pub(crate) struct Loader {
arena: Arena<String>, arena: Arena<String>,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// A name. This is effectively just a `Token` of kind `Identifier`, but we give /// A name. This is effectively just a `Token` of kind `Identifier`, but we give
/// it its own type for clarity. /// it its own type for clarity.

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// Methods common to all AST nodes. Currently only used in parser unit tests. /// Methods common to all AST nodes. Currently only used in parser unit tests.
pub(crate) trait Node<'src> { pub(crate) trait Node<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// Run a command and return the data it wrote to stdout as a string /// Run a command and return the data it wrote to stdout as a string
pub(crate) fn output(mut command: Command) -> Result<String, OutputError> { pub(crate) fn output(mut command: Command) -> Result<String, OutputError> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug)] #[derive(Debug)]
pub(crate) enum OutputError { pub(crate) enum OutputError {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// A single function parameter /// A single function parameter
#[derive(PartialEq, Debug, Clone, Serialize)] #[derive(PartialEq, Debug, Clone, Serialize)]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// Parameters can either be… /// Parameters can either be…
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use TokenKind::*; use TokenKind::*;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct Platform; pub(crate) struct Platform;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) trait PlatformInterface { pub(crate) trait PlatformInterface {
/// Construct a command equivalent to running the script at `path` with the /// Construct a command equivalent to running the script at `path` with the

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// A struct containing the parsed representation of positional command-line /// A struct containing the parsed representation of positional command-line
/// arguments, i.e. arguments that are not flags, options, or the subcommand. /// arguments, i.e. arguments that are not flags, options, or the subcommand.

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) trait RangeExt<T> { pub(crate) trait RangeExt<T> {
fn range_contains(&self, i: &T) -> bool; fn range_contains(&self, i: &T) -> bool;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use std::process::{ExitStatus, Stdio}; use std::process::{ExitStatus, Stdio};

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct RecipeContext<'src: 'run, 'run> { pub(crate) struct RecipeContext<'src: 'run, 'run> {
pub(crate) config: &'run Config, pub(crate) config: &'run Config,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use CompileErrorKind::*; use CompileErrorKind::*;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub fn run() -> Result<(), i32> { pub fn run() -> Result<(), i32> {
#[cfg(windows)] #[cfg(windows)]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct Scope<'src: 'run, 'run> { pub(crate) struct Scope<'src: 'run, 'run> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use std::path::Component; use std::path::Component;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// Controls how `just` will search for the justfile. /// Controls how `just` will search for the justfile.
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, Snafu)] #[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))] #[snafu(visibility(pub(crate)))]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) struct Set<'src> { pub(crate) struct Set<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) enum Setting<'src> { pub(crate) enum Setting<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) const DEFAULT_SHELL: &str = "sh"; pub(crate) const DEFAULT_SHELL: &str = "sh";
pub(crate) const DEFAULT_SHELL_ARGS: &[&str] = &["-cu"]; pub(crate) const DEFAULT_SHELL_ARGS: &[&str] = &["-cu"];

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, Clone, PartialEq, Serialize)] #[derive(Debug, Clone, PartialEq, Serialize)]
pub(crate) struct Shell<'src> { pub(crate) struct Shell<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
/// String wrapper that uses nonblank characters to display spaces and tabs /// String wrapper that uses nonblank characters to display spaces and tabs
pub struct ShowWhitespace<'str>(pub &'str str); pub struct ShowWhitespace<'str>(pub &'str str);

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)] #[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)]
pub(crate) struct StringKind { pub(crate) struct StringKind {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Debug, Clone)]
pub(crate) struct StringLiteral<'src> { pub(crate) struct StringLiteral<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
const INIT_JUSTFILE: &str = "default:\n echo 'Hello, world!'\n"; const INIT_JUSTFILE: &str = "default:\n echo 'Hello, world!'\n";

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) struct Suggestion<'src> { pub(crate) struct Suggestion<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use std::collections::btree_map; use std::collections::btree_map;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use crate::compiler::Compiler; use crate::compiler::Compiler;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Derivative)] #[derive(Derivative)]
#[derivative(Debug, Clone, PartialEq = "feature_allow_slow_enum")] #[derivative(Debug, Clone, PartialEq = "feature_allow_slow_enum")]

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Clone, Copy)]
pub(crate) struct Token<'src> { pub(crate) struct Token<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)] #[derive(Debug, PartialEq, Clone, Copy, Ord, PartialOrd, Eq)]
pub(crate) enum TokenKind { pub(crate) enum TokenKind {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
use std::{borrow::Cow, mem}; use std::{borrow::Cow, mem};

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Debug, Clone)]
pub(crate) struct UnresolvedDependency<'src> { pub(crate) struct UnresolvedDependency<'src> {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) type UnresolvedRecipe<'src> = Recipe<'src, UnresolvedDependency<'src>>; pub(crate) type UnresolvedRecipe<'src> = Recipe<'src, UnresolvedDependency<'src>>;

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) struct Variables<'expression, 'src> { pub(crate) struct Variables<'expression, 'src> {
stack: Vec<&'expression Expression<'src>>, stack: Vec<&'expression Expression<'src>>,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub(crate) enum Warning {} pub(crate) enum Warning {}

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[test] #[test]
fn allow_duplicate_recipes() { fn allow_duplicate_recipes() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) fn assert_stdout(output: &Output, stdout: &str) { pub(crate) fn assert_stdout(output: &Output, stdout: &str) {
assert_success(output); assert_success(output);

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
pub(crate) fn assert_success(output: &Output) { pub(crate) fn assert_success(output: &Output) {
if !output.status.success() { if !output.status.success() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[test] #[test]
fn ignore_leading_byte_order_mark() { fn ignore_leading_byte_order_mark() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[test] #[test]
fn print_changelog() { fn print_changelog() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
test! { test! {
name: env, name: env,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
test! { test! {
name: long, name: long,

View File

@ -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,
};

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[test] #[test]
fn output() { fn output() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
test! { test! {
name: then_branch_unevaluated, name: then_branch_unevaluated,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
test! { test! {
name: mismatched_delimiter, name: mismatched_delimiter,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[test] #[test]
fn dotenv() { fn dotenv() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
const JUSTFILE: &str = "Yooooooo, hopefully this never becomes valid syntax."; const JUSTFILE: &str = "Yooooooo, hopefully this never becomes valid syntax.";

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[test] #[test]
fn export_recipe() { fn export_recipe() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
test! { test! {
name: expected_keyword, name: expected_keyword,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
test! { test! {
name: evaluate, name: evaluate,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[test] #[test]
fn examples() { fn examples() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[test] #[test]
fn runs_recipe_in_parent_if_not_found_in_current() { fn runs_recipe_in_parent_if_not_found_in_current() {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
test! { test! {
name: unstable_not_passed, name: unstable_not_passed,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
test! { test! {
name: test_os_arch_functions_in_interpolation, name: test_os_arch_functions_in_interpolation,

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
const EXPECTED: &str = "default:\n echo 'Hello, world!'\n"; const EXPECTED: &str = "default:\n echo 'Hello, world!'\n";

View File

@ -1,90 +1,87 @@
#[cfg(unix)] use super::*;
mod unix {
use crate::common::*;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
fn kill(process_id: u32) { fn kill(process_id: u32) {
unsafe { unsafe {
libc::kill(process_id as i32, libc::SIGINT); 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) { if elapsed < Duration::from_millis(100) {
let tmp = tempdir(); panic!("process returned too early : {:?}", elapsed);
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));
} }
#[test] assert_eq!(status.code(), Some(130));
#[ignore] }
fn interrupt_shebang() {
interrupt_test( #[test]
&[], #[ignore]
" fn interrupt_shebang() {
interrupt_test(
&[],
"
default: default:
#!/usr/bin/env sh #!/usr/bin/env sh
sleep 1 sleep 1
", ",
); );
} }
#[test] #[test]
#[ignore] #[ignore]
fn interrupt_line() { fn interrupt_line() {
interrupt_test( interrupt_test(
&[], &[],
" "
default: default:
@sleep 1 @sleep 1
", ",
); );
} }
#[test] #[test]
#[ignore] #[ignore]
fn interrupt_backtick() { fn interrupt_backtick() {
interrupt_test( interrupt_test(
&[], &[],
" "
foo := `sleep 1` foo := `sleep 1`
default: default:
@echo {{foo}} @echo {{foo}}
", ",
); );
} }
#[test] #[test]
#[ignore] #[ignore]
fn interrupt_command() { fn interrupt_command() {
interrupt_test(&["--command", "sleep", "1"], ""); interrupt_test(&["--command", "sleep", "1"], "");
}
} }

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
#[cfg(unix)] #[cfg(unix)]
fn convert_native_path(path: &Path) -> String { fn convert_native_path(path: &Path) -> String {

View File

@ -1,4 +1,4 @@
use crate::common::*; use super::*;
fn test(justfile: &str, value: Value) { fn test(justfile: &str, value: Value) {
Test::new() Test::new()

Some files were not shown because too many files have changed in this diff Show More