Skip to content

Commit

Permalink
misc: Use compile-time macro env!
Browse files Browse the repository at this point in the history
  • Loading branch information
fox0 committed Oct 26, 2024
1 parent 87b53d4 commit e86e3fb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 3 additions & 1 deletion misc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
plib = { path = "../plib" }
clap.workspace = true
libc.workspace = true
gettext-rs.workspace = true

[dev-dependencies]
plib = { path = "../plib" }

[lints]
workspace = true

Expand Down
12 changes: 5 additions & 7 deletions misc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
// - fix and test unary ops
//

use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
use plib::PROJECT_NAME;
use std::os::unix::fs::FileTypeExt;
use std::os::unix::fs::MetadataExt;
use std::os::unix::fs::PermissionsExt;
use std::os::unix::fs::{FileTypeExt, MetadataExt, PermissionsExt};
use std::path::Path;

use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};

/// Unary operators
#[allow(clippy::upper_case_acronyms)]
#[derive(PartialEq)]
Expand Down Expand Up @@ -281,8 +279,8 @@ fn eval_binary(s1: &str, op_str: &str, s2: &str) -> bool {

fn main() -> Result<(), Box<dyn std::error::Error>> {
setlocale(LocaleCategory::LcAll, "");
textdomain(PROJECT_NAME)?;
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
textdomain(env!("PROJECT_NAME"))?;
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;

let mut args: Vec<String> = std::env::args().collect();

Expand Down
2 changes: 1 addition & 1 deletion misc/tests/false/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// SPDX-License-Identifier: MIT
//

use plib::{run_test, TestPlan};
use plib::testing::{run_test, TestPlan};

fn truefalse_test(cmd: &str, expected_exit_code: i32) {
run_test(TestPlan {
Expand Down
2 changes: 1 addition & 1 deletion misc/tests/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// SPDX-License-Identifier: MIT
//

use plib::{run_test, TestPlan};
use plib::testing::{run_test, TestPlan};

fn test_test(args: &[&str], expected_code: i32) {
let str_args: Vec<String> = args.iter().map(|s| String::from(*s)).collect();
Expand Down
2 changes: 1 addition & 1 deletion misc/tests/true/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// SPDX-License-Identifier: MIT
//

use plib::{run_test, TestPlan};
use plib::testing::{run_test, TestPlan};

fn truefalse_test(cmd: &str, expected_exit_code: i32) {
run_test(TestPlan {
Expand Down

0 comments on commit e86e3fb

Please sign in to comment.