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`
#[derive(Debug, PartialEq, Clone, Serialize)]

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
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
/// 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`
#[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 atty::Stream;

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
pub(crate) trait ColorDisplay {
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 {
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)]
pub(crate) struct CompileError<'src> {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
#[derive(Debug, Snafu)]
#[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);

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
pub(crate) struct Evaluator<'src: 'run, 'run> {
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`
/// 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…
#[derive(PartialEq, Debug, Clone)]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
pub(crate) trait Keyed<'key> {
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)]
#[strum(serialize_all = "kebab_case")]

View File

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

View File

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

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.
#[derive(Debug, Clone, PartialEq, Serialize)]

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
pub(crate) struct Loader {
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
/// 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.
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
pub(crate) fn output(mut command: Command) -> Result<String, OutputError> {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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.

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
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) config: &'run Config,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
#[derive(Debug, Clone)]
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_ARGS: &[&str] = &["-cu"];

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
#[derive(Debug, Clone, PartialEq, Serialize)]
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
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)]
pub(crate) struct StringKind {

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
#[derive(PartialEq, Debug, Clone)]
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";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
#[derive(PartialEq, Debug, Clone)]
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>>;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
test! {
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]
fn output() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
use crate::common::*;
use super::*;
test! {
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";

View File

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

View File

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

View File

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