mirror of
https://github.com/uutils/awk.git
synced 2026-06-10 16:15:04 -07:00
chore: add rustfmt.toml
Pretty sure nobody was working on anything atm, sorry otherwise...
This commit is contained in:
+6
-14
@@ -12,10 +12,10 @@
|
||||
|
||||
pub mod lower;
|
||||
|
||||
pub use lower::test_interpreter;
|
||||
|
||||
use std::fmt::{Debug, Display};
|
||||
|
||||
pub use lower::test_interpreter;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[repr(transparent)]
|
||||
pub struct NonLocal(pub u16);
|
||||
@@ -113,9 +113,7 @@ impl Instruction {
|
||||
debug_assert!(opcode.is_unary());
|
||||
Self {
|
||||
opcode,
|
||||
args: Arguments {
|
||||
unary_local: (dest, src.reg()),
|
||||
},
|
||||
args: Arguments { unary_local: (dest, src.reg()) },
|
||||
hint: src.hint(),
|
||||
}
|
||||
}
|
||||
@@ -137,9 +135,7 @@ impl Instruction {
|
||||
};
|
||||
Self {
|
||||
opcode,
|
||||
args: Arguments {
|
||||
binary_local: (dest, lhs.reg(), rhs.reg()),
|
||||
},
|
||||
args: Arguments { binary_local: (dest, lhs.reg(), rhs.reg()) },
|
||||
hint,
|
||||
}
|
||||
}
|
||||
@@ -149,9 +145,7 @@ impl Instruction {
|
||||
debug_assert!(opcode.is_load_store());
|
||||
Self {
|
||||
opcode,
|
||||
args: Arguments {
|
||||
load_store: (dest, src),
|
||||
},
|
||||
args: Arguments { load_store: (dest, src) },
|
||||
hint: Hint::None,
|
||||
}
|
||||
}
|
||||
@@ -167,9 +161,7 @@ impl Instruction {
|
||||
fn branch(cond: Reg, true_to: Label, false_to: Label) -> Self {
|
||||
Self {
|
||||
opcode: OpCode::Branch,
|
||||
args: Arguments {
|
||||
branch: (cond, true_to, false_to),
|
||||
},
|
||||
args: Arguments { branch: (cond, true_to, false_to) },
|
||||
hint: Hint::None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// files that was distributed with this source code.
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::hash::Hash;
|
||||
use std::mem::forget;
|
||||
use std::{fmt::Display, hash::Hash, mem::forget};
|
||||
|
||||
use bumpalo::{Bump, collections::Vec};
|
||||
use indexmap::IndexSet;
|
||||
@@ -42,11 +40,7 @@ impl Code<'_> {
|
||||
|
||||
fn lower_statement(&mut self, stmnt: &Statement) {
|
||||
match stmnt {
|
||||
Statement::If {
|
||||
condition,
|
||||
then_body,
|
||||
else_body,
|
||||
} => {
|
||||
Statement::If { condition, then_body, else_body } => {
|
||||
let mut state = RegsState::new(self);
|
||||
let condition = self.lower_expr(condition);
|
||||
let label_then = self.following_instr(1);
|
||||
@@ -65,10 +59,7 @@ impl Code<'_> {
|
||||
self.bc.nth(end_label).args.jump = self.following_instr(0);
|
||||
}
|
||||
}
|
||||
Statement::While {
|
||||
condition,
|
||||
then_body,
|
||||
} => {
|
||||
Statement::While { condition, then_body } => {
|
||||
let cond_label = self.following_instr(0);
|
||||
let condition = self.lower_expr(condition);
|
||||
let while_label = self.bc.emit(Instruction::branch(
|
||||
@@ -81,10 +72,7 @@ impl Code<'_> {
|
||||
self.bc.emit(Instruction::jump(cond_label));
|
||||
self.bc.nth(while_label).args.branch.2 = self.following_instr(0);
|
||||
}
|
||||
Statement::DoWhile {
|
||||
then_body,
|
||||
condition,
|
||||
} => {
|
||||
Statement::DoWhile { then_body, condition } => {
|
||||
let do_label = self.following_instr(0);
|
||||
self.lower_body(then_body);
|
||||
let condition = self.lower_expr(condition);
|
||||
@@ -209,9 +197,7 @@ struct RegsState {
|
||||
|
||||
impl<'a> Bytecode<'a> {
|
||||
fn new_in(bump: &'a Bump) -> Self {
|
||||
Self {
|
||||
code: Vec::with_capacity_in(64, bump),
|
||||
}
|
||||
Self { code: Vec::with_capacity_in(64, bump) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@@ -241,10 +227,7 @@ impl RegsState {
|
||||
let old = code.reg_pointer;
|
||||
code.reg_pointer = self.reg_pointer;
|
||||
code.free_regs.truncate(self.n_free_regs);
|
||||
Self {
|
||||
reg_pointer: old,
|
||||
n_free_regs: self.n_free_regs,
|
||||
}
|
||||
Self { reg_pointer: old, n_free_regs: self.n_free_regs }
|
||||
}
|
||||
fn scope_hwm<T>(self, code: &mut Code, f: impl FnOnce(&mut Code) -> T) {
|
||||
f(code);
|
||||
|
||||
+2
-6
@@ -15,8 +15,7 @@ use std::{
|
||||
};
|
||||
|
||||
use bumpalo::{Bump, collections::Vec};
|
||||
use logos::Logos;
|
||||
use logos::Skip;
|
||||
use logos::{Logos, Skip};
|
||||
pub use logos::{Span, SpannedIter};
|
||||
use memchr::{memchr, memchr3};
|
||||
use thiserror::Error;
|
||||
@@ -524,10 +523,7 @@ fn parse_indirect_call<'a, const QUALIFIED: bool>(lex: &mut Lexer<'a>) -> Result
|
||||
|
||||
impl<'a> Identifier<'a> {
|
||||
fn without_namespace<const SKIP: usize>(lex: &mut Lexer<'a>) -> Self {
|
||||
Self {
|
||||
namespace: None,
|
||||
literal: parse_ident(lex, SKIP..),
|
||||
}
|
||||
Self { namespace: None, literal: parse_ident(lex, SKIP..) }
|
||||
}
|
||||
|
||||
fn with_namespace<const SKIP: usize>(lex: &mut Lexer<'a>) -> Result<Self> {
|
||||
|
||||
+11
-37
@@ -5,12 +5,13 @@
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
use crate::{Identifier, Token};
|
||||
use bumpalo::{
|
||||
Bump,
|
||||
collections::{CollectIn, Vec},
|
||||
};
|
||||
|
||||
use crate::{Identifier, Token};
|
||||
|
||||
fn lex<'a>(
|
||||
src: &'a [u8],
|
||||
arena: &'a Bump,
|
||||
@@ -113,14 +114,8 @@ fn lexer_test_gnu_pattern() {
|
||||
assert_eq!(
|
||||
&lex(b"BEGINFILE ENDFILE", &arena, true, false),
|
||||
&[
|
||||
Token::Identifier(Identifier {
|
||||
namespace: None,
|
||||
literal: "BEGINFILE"
|
||||
}),
|
||||
Token::Identifier(Identifier {
|
||||
namespace: None,
|
||||
literal: "ENDFILE"
|
||||
})
|
||||
Token::Identifier(Identifier { namespace: None, literal: "BEGINFILE" }),
|
||||
Token::Identifier(Identifier { namespace: None, literal: "ENDFILE" })
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -166,25 +161,13 @@ fn lexer_test_ident_rules_non_posix() {
|
||||
&lex(b"1a::a a::1a _a", &arena, false, false),
|
||||
&[
|
||||
Token::Number(1.),
|
||||
Token::Identifier(Identifier {
|
||||
namespace: Some("a"),
|
||||
literal: "a"
|
||||
}),
|
||||
Token::Identifier(Identifier {
|
||||
namespace: None,
|
||||
literal: "a"
|
||||
}),
|
||||
Token::Identifier(Identifier { namespace: Some("a"), literal: "a" }),
|
||||
Token::Identifier(Identifier { namespace: None, literal: "a" }),
|
||||
Token::Colon,
|
||||
Token::Colon,
|
||||
Token::Number(1.),
|
||||
Token::Identifier(Identifier {
|
||||
namespace: None,
|
||||
literal: "a"
|
||||
}),
|
||||
Token::Identifier(Identifier {
|
||||
namespace: None,
|
||||
literal: "_a"
|
||||
})
|
||||
Token::Identifier(Identifier { namespace: None, literal: "a" }),
|
||||
Token::Identifier(Identifier { namespace: None, literal: "_a" })
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -215,10 +198,7 @@ fn lexer_test_general_tokens() {
|
||||
Token::BeginPattern,
|
||||
Token::OpenBrace,
|
||||
Token::Print,
|
||||
Token::Identifier(Identifier {
|
||||
namespace: None,
|
||||
literal: "a"
|
||||
}),
|
||||
Token::Identifier(Identifier { namespace: None, literal: "a" }),
|
||||
Token::Plus,
|
||||
Token::Number(1.),
|
||||
Token::ClosedBrace,
|
||||
@@ -231,10 +211,7 @@ fn lexer_test_general_tokens() {
|
||||
Token::Record,
|
||||
Token::Number(1.),
|
||||
Token::EqualTo,
|
||||
Token::Identifier(Identifier {
|
||||
namespace: Some("foo"),
|
||||
literal: "bar"
|
||||
}),
|
||||
Token::Identifier(Identifier { namespace: Some("foo"), literal: "bar" }),
|
||||
Token::ClosedBrace,
|
||||
Token::Newline
|
||||
]
|
||||
@@ -250,10 +227,7 @@ fn lexer_test_regex_ambiguity() {
|
||||
Token::Number(1.),
|
||||
Token::SlashAssign,
|
||||
Token::Number(1.),
|
||||
Token::Identifier(Identifier {
|
||||
namespace: None,
|
||||
literal: "a"
|
||||
}),
|
||||
Token::Identifier(Identifier { namespace: None, literal: "a" }),
|
||||
Token::SlashAssign,
|
||||
Token::Number(1.)
|
||||
]
|
||||
|
||||
@@ -84,11 +84,7 @@ impl Display for Statement<'_> {
|
||||
|
||||
match self {
|
||||
Self::Simple(simple) => <_ as Display>::fmt(simple, f),
|
||||
Self::If {
|
||||
condition,
|
||||
then_body,
|
||||
else_body,
|
||||
} => {
|
||||
Self::If { condition, then_body, else_body } => {
|
||||
write!(f, "if ({condition:ew$}) ")?;
|
||||
write_body(f, then_body, indent)?;
|
||||
if let Some(else_body) = else_body {
|
||||
@@ -97,27 +93,16 @@ impl Display for Statement<'_> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Self::While {
|
||||
condition,
|
||||
then_body,
|
||||
} => {
|
||||
Self::While { condition, then_body } => {
|
||||
write!(f, "while ({condition:ew$}) ")?;
|
||||
write_body(f, then_body, indent)
|
||||
}
|
||||
Self::DoWhile {
|
||||
then_body,
|
||||
condition,
|
||||
} => {
|
||||
Self::DoWhile { then_body, condition } => {
|
||||
write!(f, "do ")?;
|
||||
write_body(f, then_body, indent)?;
|
||||
write!(f, " while ({condition:ew$})")
|
||||
}
|
||||
Self::For {
|
||||
init,
|
||||
condition,
|
||||
update,
|
||||
body,
|
||||
} => {
|
||||
Self::For { init, condition, update, body } => {
|
||||
write!(f, "for (")?;
|
||||
if let Some(e) = init {
|
||||
write!(f, "{e:ew$}")?;
|
||||
@@ -133,19 +118,11 @@ impl Display for Statement<'_> {
|
||||
write!(f, ") ")?;
|
||||
write_body(f, body, indent)
|
||||
}
|
||||
Self::ForEach {
|
||||
variable,
|
||||
array,
|
||||
body,
|
||||
} => {
|
||||
Self::ForEach { variable, array, body } => {
|
||||
write!(f, "for ({variable} in {array}) ")?;
|
||||
write_body(f, body, indent)
|
||||
}
|
||||
Self::Switch {
|
||||
scrutinee,
|
||||
branches,
|
||||
default,
|
||||
} => {
|
||||
Self::Switch { scrutinee, branches, default } => {
|
||||
writeln!(f, "switch ({scrutinee:ew$}) {{")?;
|
||||
let default_pos = default.as_ref().map_or(branches.len(), |x| x.1);
|
||||
for i in 0..default_pos {
|
||||
@@ -187,21 +164,13 @@ impl Display for SimpleStatement<'_> {
|
||||
|
||||
match self {
|
||||
SimpleStatement::Expression(expr) => write!(f, "{expr:ew$}"),
|
||||
SimpleStatement::Command {
|
||||
name,
|
||||
args,
|
||||
redirection: Some((rx, expr)),
|
||||
} => {
|
||||
SimpleStatement::Command { name, args, redirection: Some((rx, expr)) } => {
|
||||
write!(f, "{name}(")?;
|
||||
write_args(f, args, indent)?;
|
||||
write!(f, "){rx}{expr}")?;
|
||||
Ok(())
|
||||
}
|
||||
SimpleStatement::Command {
|
||||
name,
|
||||
args,
|
||||
redirection: None,
|
||||
} => {
|
||||
SimpleStatement::Command { name, args, redirection: None } => {
|
||||
write!(f, "{name} ")?;
|
||||
write_args(f, args, indent)
|
||||
}
|
||||
|
||||
+1
-2
@@ -8,13 +8,12 @@ use std::{fmt::Debug, iter::Peekable};
|
||||
use bumpalo::Bump;
|
||||
use lexer::{Identifier, LexingError, Slice, Span, SpannedIter, Token};
|
||||
|
||||
use super::Result;
|
||||
use crate::{
|
||||
ParsingError,
|
||||
ast::{Command, SpecialPattern},
|
||||
};
|
||||
|
||||
use super::Result;
|
||||
|
||||
pub struct Lexer<'a> {
|
||||
inner: Peekable<SpannedIter<'a, Token<'a>>>,
|
||||
span: Span,
|
||||
|
||||
+9
-40
@@ -21,8 +21,7 @@ use either::Either::{Left, Right};
|
||||
use hashbrown::HashMap;
|
||||
use lexer::{LexingError, Span, Token};
|
||||
|
||||
pub use crate::ast::*;
|
||||
pub use crate::lex::Lexer;
|
||||
pub use crate::{ast::*, lex::Lexer};
|
||||
use crate::{
|
||||
diagnostics::{ParsingError, report_error},
|
||||
lex::TokenExt,
|
||||
@@ -108,10 +107,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
} else if lex.peek_is(&Token::OpenBrace) {
|
||||
let actions = Some(self.parse_body(lex)?);
|
||||
self.add_rule(Rule {
|
||||
pattern: None,
|
||||
actions,
|
||||
});
|
||||
self.add_rule(Rule { pattern: None, actions });
|
||||
} else {
|
||||
match lex.expect_next()? {
|
||||
Token::LoadDirective => {
|
||||
@@ -260,11 +256,7 @@ impl<'a> Parser<'a> {
|
||||
.consume(&Token::Else)
|
||||
.then(|| self.parse_statement_body(lex))
|
||||
.transpose()?;
|
||||
Statement::If {
|
||||
condition,
|
||||
then_body,
|
||||
else_body,
|
||||
}
|
||||
Statement::If { condition, then_body, else_body }
|
||||
}
|
||||
Token::For => {
|
||||
lex.expect(&Token::OpenParent, ParsingError::ExpectedOpeningParenthesis)?;
|
||||
@@ -337,28 +329,18 @@ impl<'a> Parser<'a> {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Statement::Switch {
|
||||
scrutinee,
|
||||
branches,
|
||||
default,
|
||||
}
|
||||
Statement::Switch { scrutinee, branches, default }
|
||||
}
|
||||
Token::While => {
|
||||
let condition = self.parse_parenthesized_expr(lex)?;
|
||||
let then_body = self.parse_statement_body(lex)?;
|
||||
Statement::While {
|
||||
condition,
|
||||
then_body,
|
||||
}
|
||||
Statement::While { condition, then_body }
|
||||
}
|
||||
Token::Do => {
|
||||
let then_body = self.parse_body(lex)?;
|
||||
lex.expect(&Token::While, ParsingError::MissingWhileAfterDo)?;
|
||||
let condition = self.parse_parenthesized_expr(lex)?;
|
||||
Statement::DoWhile {
|
||||
then_body,
|
||||
condition,
|
||||
}
|
||||
Statement::DoWhile { then_body, condition }
|
||||
}
|
||||
Token::Break => Statement::Break,
|
||||
Token::Continue => Statement::Continue,
|
||||
@@ -426,12 +408,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
lex.expect(&Token::ClosedParent, ParsingError::InvalidForLoop)?;
|
||||
let body = self.parse_statement_body(lex)?;
|
||||
Ok(Statement::For {
|
||||
init,
|
||||
condition,
|
||||
update,
|
||||
body,
|
||||
})
|
||||
Ok(Statement::For { init, condition, update, body })
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
@@ -462,11 +439,7 @@ impl<'a> Parser<'a> {
|
||||
)?;
|
||||
|
||||
let body = self.parse_statement_body(lex)?;
|
||||
Ok(Statement::ForEach {
|
||||
variable,
|
||||
array,
|
||||
body,
|
||||
})
|
||||
Ok(Statement::ForEach { variable, array, body })
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
@@ -504,11 +477,7 @@ impl<'a> Parser<'a> {
|
||||
self.parse_command_args(lex)?
|
||||
};
|
||||
let redirection = self.parse_command_redirection(lex)?;
|
||||
Ok(SimpleStatement::Command {
|
||||
name,
|
||||
args,
|
||||
redirection,
|
||||
})
|
||||
Ok(SimpleStatement::Command { name, args, redirection })
|
||||
}
|
||||
|
||||
/// Parses arguments to command or function calls; consumes to the end of
|
||||
|
||||
+1
-4
@@ -24,10 +24,7 @@ pub struct Pratt<'a, 'b> {
|
||||
|
||||
impl<'a, 'b> Pratt<'a, 'b> {
|
||||
pub fn new(parser: &'b mut Parser<'a>, typed_regex: bool) -> Self {
|
||||
Self {
|
||||
parser,
|
||||
typed_regex,
|
||||
}
|
||||
Self { parser, typed_regex }
|
||||
}
|
||||
|
||||
pub fn parse(&mut self, lex: &mut Lexer<'a>) -> Result<Expr<'a>> {
|
||||
|
||||
+8
-39
@@ -23,11 +23,7 @@ impl Debug for Statement<'_> {
|
||||
|
||||
match self {
|
||||
Statement::Simple(simple) => <_ as Debug>::fmt(simple, f),
|
||||
Self::If {
|
||||
condition,
|
||||
then_body,
|
||||
else_body,
|
||||
} => {
|
||||
Self::If { condition, then_body, else_body } => {
|
||||
if alt {
|
||||
write!(f, "(if {condition:?}\n{pad}")?;
|
||||
write!(f, "{then_body:#ni$?}")?;
|
||||
@@ -46,32 +42,21 @@ impl Debug for Statement<'_> {
|
||||
write!(f, "(if {condition:?} {then_body:?})")
|
||||
}
|
||||
}
|
||||
Self::While {
|
||||
condition,
|
||||
then_body,
|
||||
} => {
|
||||
Self::While { condition, then_body } => {
|
||||
if alt {
|
||||
write!(f, "(while {condition:?}\n{pad}{then_body:#ni$?})")
|
||||
} else {
|
||||
write!(f, "(while {condition:?} {then_body:?})")
|
||||
}
|
||||
}
|
||||
Self::DoWhile {
|
||||
then_body,
|
||||
condition,
|
||||
} => {
|
||||
Self::DoWhile { then_body, condition } => {
|
||||
if alt {
|
||||
write!(f, "(do-while\n{pad}{then_body:#ni$?}\n{pad}{condition:?})")
|
||||
} else {
|
||||
write!(f, "(do-while {then_body:?} {condition:?})")
|
||||
}
|
||||
}
|
||||
Self::For {
|
||||
init,
|
||||
condition,
|
||||
update,
|
||||
body,
|
||||
} => {
|
||||
Self::For { init, condition, update, body } => {
|
||||
write!(f, "(for")?;
|
||||
if alt {
|
||||
let write_fragment = |f: &mut Formatter, x: Option<&dyn Debug>| {
|
||||
@@ -99,22 +84,14 @@ impl Debug for Statement<'_> {
|
||||
write!(f, " {body:?})")
|
||||
}
|
||||
}
|
||||
Self::ForEach {
|
||||
variable,
|
||||
array,
|
||||
body,
|
||||
} => {
|
||||
Self::ForEach { variable, array, body } => {
|
||||
if alt {
|
||||
write!(f, "(for-each {variable:?} {array:?}\n{pad}{body:#ni$?})")
|
||||
} else {
|
||||
write!(f, "(for-each {variable:?} {array:?} {body:?})")
|
||||
}
|
||||
}
|
||||
Self::Switch {
|
||||
scrutinee,
|
||||
branches,
|
||||
default,
|
||||
} => {
|
||||
Self::Switch { scrutinee, branches, default } => {
|
||||
if alt {
|
||||
if let Some((dx, i)) = default {
|
||||
write!(
|
||||
@@ -166,11 +143,7 @@ impl Debug for SimpleStatement<'_> {
|
||||
write!(f, "{expr:?}")
|
||||
}
|
||||
}
|
||||
Self::Command {
|
||||
name,
|
||||
args,
|
||||
redirection: Some((rx, expr)),
|
||||
} => {
|
||||
Self::Command { name, args, redirection: Some((rx, expr)) } => {
|
||||
if alt {
|
||||
write!(
|
||||
f,
|
||||
@@ -182,11 +155,7 @@ impl Debug for SimpleStatement<'_> {
|
||||
write!(f, "({name:?}{:?} ({rx:?} {expr:?}))", ListLispFmt(args))
|
||||
}
|
||||
}
|
||||
Self::Command {
|
||||
name,
|
||||
args,
|
||||
redirection: None,
|
||||
} => {
|
||||
Self::Command { name, args, redirection: None } => {
|
||||
write!(f, "({name:?}{:?})", ListLispFmt(args))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
imports_granularity = "Crate"
|
||||
group_imports = "StdExternalCrate"
|
||||
max_width = 100
|
||||
struct_lit_width = 50
|
||||
newline_style = "Unix"
|
||||
+5
-7
@@ -8,8 +8,10 @@
|
||||
mod cli;
|
||||
mod utils;
|
||||
|
||||
use std::env::args_os;
|
||||
use std::io::{self, Write};
|
||||
use std::{
|
||||
env::args_os,
|
||||
io::{self, Write},
|
||||
};
|
||||
|
||||
use bumpalo::Bump;
|
||||
use clap::Parser as _;
|
||||
@@ -54,11 +56,7 @@ fn uu_main() -> Result<()> {
|
||||
}
|
||||
dbg!(arena.chunk_capacity());
|
||||
|
||||
if let Some(Rule {
|
||||
actions: Some(body),
|
||||
pattern: _,
|
||||
}) = ast.rules.first()
|
||||
{
|
||||
if let Some(Rule { actions: Some(body), pattern: _ }) = ast.rules.first() {
|
||||
let x = test_interpreter(body);
|
||||
if let Err(e) = writeln!(io::stdout(), "---\n{x}")
|
||||
&& e.kind() != io::ErrorKind::BrokenPipe
|
||||
|
||||
+6
-4
@@ -3,10 +3,12 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// files that was distributed with this source code.
|
||||
|
||||
use std::fmt::{Debug, Display};
|
||||
use std::io::{self, Write};
|
||||
use std::panic::{UnwindSafe, catch_unwind, set_hook, take_hook};
|
||||
use std::process::exit;
|
||||
use std::{
|
||||
fmt::{Debug, Display},
|
||||
io::{self, Write},
|
||||
panic::{UnwindSafe, catch_unwind, set_hook, take_hook},
|
||||
process::exit,
|
||||
};
|
||||
|
||||
use color_eyre::config::HookBuilder;
|
||||
use tracing_error::ErrorLayer;
|
||||
|
||||
@@ -24,8 +24,10 @@ fn no_args_fails_code_one() {
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn write_to_dev_full_does_not_panic() {
|
||||
use std::fs::OpenOptions;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::{
|
||||
fs::OpenOptions,
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
let Ok(dev_full) = OpenOptions::new().write(true).open("/dev/full") else {
|
||||
return; // /dev/full not available; skip.
|
||||
|
||||
Reference in New Issue
Block a user