mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
Merge pull request #882 from jbcrail/fix-windows-build
Improve Windows build
This commit is contained in:
commit
bdc1ca7426
57 changed files with 128 additions and 211 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -12,6 +12,7 @@ dependencies = [
|
||||||
"comm 0.0.1",
|
"comm 0.0.1",
|
||||||
"cp 0.0.1",
|
"cp 0.0.1",
|
||||||
"cut 0.0.1",
|
"cut 0.0.1",
|
||||||
|
"dircolors 0.0.1",
|
||||||
"dirname 0.0.1",
|
"dirname 0.0.1",
|
||||||
"du 0.0.1",
|
"du 0.0.1",
|
||||||
"echo 0.0.1",
|
"echo 0.0.1",
|
||||||
|
@ -39,6 +40,7 @@ dependencies = [
|
||||||
"memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mkdir 0.0.1",
|
"mkdir 0.0.1",
|
||||||
"mkfifo 0.0.1",
|
"mkfifo 0.0.1",
|
||||||
|
"mknod 0.0.1",
|
||||||
"mktemp 0.0.1",
|
"mktemp 0.0.1",
|
||||||
"mv 0.0.1",
|
"mv 0.0.1",
|
||||||
"nice 0.0.1",
|
"nice 0.0.1",
|
||||||
|
@ -208,6 +210,16 @@ dependencies = [
|
||||||
"uucore 0.0.1",
|
"uucore 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dircolors"
|
||||||
|
version = "0.0.1"
|
||||||
|
dependencies = [
|
||||||
|
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"uucore 0.0.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirname"
|
name = "dirname"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
@ -324,6 +336,11 @@ name = "getopts"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glob"
|
||||||
|
version = "0.2.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "groups"
|
name = "groups"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
@ -482,6 +499,15 @@ dependencies = [
|
||||||
"uucore 0.0.1",
|
"uucore 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mknod"
|
||||||
|
version = "0.0.1"
|
||||||
|
dependencies = [
|
||||||
|
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"uucore 0.0.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mktemp"
|
name = "mktemp"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
|
|
@ -194,3 +194,6 @@ tempdir="*"
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "uutils"
|
name = "uutils"
|
||||||
path = "src/uutils/uutils.rs"
|
path = "src/uutils/uutils.rs"
|
||||||
|
|
||||||
|
[[test]]
|
||||||
|
name = "tests"
|
||||||
|
|
|
@ -12,12 +12,9 @@ install:
|
||||||
- cargo -V
|
- cargo -V
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- cargo build --features generic --no-default-features
|
- cargo build --release --features generic --no-default-features
|
||||||
- 7z a -tzip uutils.zip .\target\release\deps\*.exe
|
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: uutils.zip
|
|
||||||
name: zipfile
|
|
||||||
- path: target\release\uutils.exe
|
- path: target\release\uutils.exe
|
||||||
name: uutils.exe
|
name: uutils.exe
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ extern crate uucore;
|
||||||
|
|
||||||
use std::io::{Error, Result};
|
use std::io::{Error, Result};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::windows::ffi::OsStringExt;
|
|
||||||
use uucore::wide::FromWide;
|
use uucore::wide::FromWide;
|
||||||
|
|
||||||
pub unsafe fn getusername() -> Result<String> {
|
pub unsafe fn getusername() -> Result<String> {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
extern crate tempdir;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::{self, File, OpenOptions};
|
use std::fs::{self, File, OpenOptions};
|
||||||
use std::io::{Read, Write, Result};
|
use std::io::{Read, Write, Result};
|
||||||
|
@ -14,10 +12,10 @@ use std::path::{Path, PathBuf};
|
||||||
use std::process::{Command, Stdio, Child};
|
use std::process::{Command, Stdio, Child};
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use self::tempdir::TempDir;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use tempdir::TempDir;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
static PROGNAME: &'static str = "target\\debug\\uutils.exe";
|
static PROGNAME: &'static str = "target\\debug\\uutils.exe";
|
||||||
|
@ -71,15 +69,17 @@ pub fn repeat_str(s: &str, n: u32) -> String {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! path_concat {
|
macro_rules! path_concat {
|
||||||
($e:expr, ..$n:expr) => {{
|
($e:expr, ..$n:expr) => {{
|
||||||
|
use std::path::PathBuf;
|
||||||
let n = $n;
|
let n = $n;
|
||||||
let mut pb = std::path::PathBuf::new();
|
let mut pb = PathBuf::new();
|
||||||
for _ in 0..n {
|
for _ in 0..n {
|
||||||
pb.push($e);
|
pb.push($e);
|
||||||
}
|
}
|
||||||
pb.to_str().unwrap().to_owned()
|
pb.to_str().unwrap().to_owned()
|
||||||
}};
|
}};
|
||||||
($($e:expr),*) => {{
|
($($e:expr),*) => {{
|
||||||
let mut pb = std::path::PathBuf::new();
|
use std::path::PathBuf;
|
||||||
|
let mut pb = PathBuf::new();
|
||||||
$(
|
$(
|
||||||
pb.push($e);
|
pb.push($e);
|
||||||
)*
|
)*
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "base64";
|
static UTIL_NAME: &'static str = "base64";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "basename";
|
static UTIL_NAME: &'static str = "basename";
|
||||||
|
@ -44,6 +41,7 @@ fn expect_error(input: Vec<&str>, expected_stdout: &str) {
|
||||||
assert!(results.stderr.len() > 0);
|
assert!(results.stderr.len() > 0);
|
||||||
assert_eq!(expected_stdout, results.stdout.trim_right());
|
assert_eq!(expected_stdout, results.stdout.trim_right());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
|
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_multiple_param() {
|
fn test_multiple_param() {
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "cat";
|
static UTIL_NAME: &'static str = "cat";
|
|
@ -1,33 +1,29 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use std::os::unix::raw::mode_t;
|
|
||||||
use std::os::unix::fs::PermissionsExt;
|
|
||||||
use std::os::unix::fs::OpenOptionsExt;
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
use std::fs::{metadata, OpenOptions, set_permissions};
|
||||||
|
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "chmod";
|
static UTIL_NAME: &'static str = "chmod";
|
||||||
static TEST_FILE: &'static str = "file";
|
static TEST_FILE: &'static str = "file";
|
||||||
static REFERENCE_FILE: &'static str = "reference";
|
static REFERENCE_FILE: &'static str = "reference";
|
||||||
static REFERENCE_PERMS: mode_t = 0o247;
|
static REFERENCE_PERMS: u32 = 0o247;
|
||||||
|
|
||||||
struct TestCase {
|
struct TestCase {
|
||||||
args: Vec<&'static str>,
|
args: Vec<&'static str>,
|
||||||
before: mode_t,
|
before: u32,
|
||||||
after: mode_t
|
after: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mkfile(file: &str, mode: mode_t) {
|
fn mkfile(file: &str, mode: u32) {
|
||||||
std::fs::OpenOptions::new().mode(mode).create(true).write(true).open(file).unwrap();
|
OpenOptions::new().mode(mode).create(true).write(true).open(file).unwrap();
|
||||||
let mut perms = std::fs::metadata(file).unwrap().permissions();
|
let mut perms = metadata(file).unwrap().permissions();
|
||||||
perms.set_mode(mode);
|
perms.set_mode(mode);
|
||||||
std::fs::set_permissions(file, perms).unwrap();
|
set_permissions(file, perms).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) {
|
fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) {
|
||||||
mkfile(&at.plus_as_string(TEST_FILE), test.before);
|
mkfile(&at.plus_as_string(TEST_FILE), test.before);
|
||||||
let perms = at.metadata(TEST_FILE).permissions().mode();
|
let perms = at.metadata(TEST_FILE).permissions().mode();
|
||||||
if perms != test.before{
|
if perms != test.before {
|
||||||
panic!(format!("{}: expected: {:o} got: {:o}", "setting permissions failed", test.after, perms));
|
panic!(format!("{}: expected: {:o} got: {:o}", "setting permissions failed", test.after, perms));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "cksum";
|
static UTIL_NAME: &'static str = "cksum";
|
|
@ -1,8 +1,6 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::testing;
|
use common::util::testing;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "comm";
|
static UTIL_NAME: &'static str = "comm";
|
||||||
|
|
||||||
fn comm<A: AsRef<OsStr>, B: AsRef<str>>(args: &[A],
|
fn comm<A: AsRef<OsStr>, B: AsRef<str>>(args: &[A],
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "cp";
|
static UTIL_NAME: &'static str = "cp";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "cut";
|
static UTIL_NAME: &'static str = "cut";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "dircolors";
|
static UTIL_NAME: &'static str = "dircolors";
|
|
@ -1,11 +1,7 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "dirname";
|
static UTIL_NAME: &'static str = "dirname";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_path_with_trailing_slashes() {
|
fn test_path_with_trailing_slashes() {
|
||||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "echo";
|
static UTIL_NAME: &'static str = "echo";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "env";
|
static UTIL_NAME: &'static str = "env";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "expr";
|
static UTIL_NAME: &'static str = "expr";
|
|
@ -7,21 +7,11 @@
|
||||||
// that was distributed with this source code.
|
// that was distributed with this source code.
|
||||||
//
|
//
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
extern crate libc;
|
|
||||||
extern crate rand;
|
|
||||||
|
|
||||||
use rand::{weak_rng, Rng};
|
use rand::{weak_rng, Rng};
|
||||||
use rand::distributions::{IndependentSample, Range};
|
use rand::distributions::{IndependentSample, Range};
|
||||||
use sieve::Sieve;
|
use sieve::Sieve;
|
||||||
|
|
||||||
#[path="../src/factor/sieve.rs"]
|
|
||||||
mod sieve;
|
|
||||||
|
|
||||||
const NUM_PRIMES: usize = 10000;
|
const NUM_PRIMES: usize = 10000;
|
||||||
const LOG_PRIMES: f64 = 14.0; // ceil(log2(NUM_PRIMES))
|
const LOG_PRIMES: f64 = 14.0; // ceil(log2(NUM_PRIMES))
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "false";
|
static UTIL_NAME: &'static str = "false";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_exit_code() {
|
fn test_exit_code() {
|
||||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "fold";
|
static UTIL_NAME: &'static str = "fold";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
macro_rules! get_hash(
|
macro_rules! get_hash(
|
||||||
($str:expr) => (
|
($str:expr) => (
|
||||||
$str.split(' ').collect::<Vec<&str>>()[0]
|
$str.split(' ').collect::<Vec<&str>>()[0]
|
|
@ -1,13 +1,9 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "head";
|
static UTIL_NAME: &'static str = "head";
|
||||||
|
|
||||||
static INPUT: &'static str = "lorem_ipsum.txt";
|
static INPUT: &'static str = "lorem_ipsum.txt";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stdin_default() {
|
fn test_stdin_default() {
|
||||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
let (at, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
|
@ -1,12 +1,7 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "ln";
|
static UTIL_NAME: &'static str = "ln";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_symlink_existing_file() {
|
fn test_symlink_existing_file() {
|
||||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
let (at, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,16 +1,13 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "ls";
|
static UTIL_NAME: &'static str = "ls";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ls_ls() {
|
fn test_ls_ls() {
|
||||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||||
|
|
||||||
let result = ucmd.run();
|
let result = ucmd.run();
|
||||||
|
|
||||||
let exit_success = result.success;
|
let exit_success = result.success;
|
||||||
assert_eq!(exit_success, true);
|
assert_eq!(exit_success, true);
|
||||||
}
|
}
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "mkdir";
|
static UTIL_NAME: &'static str = "mkdir";
|
||||||
|
@ -11,7 +8,6 @@ static TEST_DIR3: &'static str = "mkdir_test3";
|
||||||
static TEST_DIR4: &'static str = "mkdir_test4/mkdir_test4_1";
|
static TEST_DIR4: &'static str = "mkdir_test4/mkdir_test4_1";
|
||||||
static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1";
|
static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mkdir_mkdir() {
|
fn test_mkdir_mkdir() {
|
||||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,8 +1,5 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
use common::util::tempdir::TempDir;
|
use tempdir::TempDir;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "mktemp";
|
static UTIL_NAME: &'static str = "mktemp";
|
||||||
|
|
||||||
|
@ -20,7 +17,6 @@ static TEST_TEMPLATE8: &'static str = "tempXXXla\\te";
|
||||||
|
|
||||||
const TMPDIR: &'static str = "TMPDIR";
|
const TMPDIR: &'static str = "TMPDIR";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mktemp_mktemp() {
|
fn test_mktemp_mktemp() {
|
||||||
let ts = TestSet::new(UTIL_NAME);
|
let ts = TestSet::new(UTIL_NAME);
|
|
@ -1,13 +1,10 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
extern crate kernel32;
|
extern crate kernel32;
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
extern crate filetime;
|
extern crate filetime;
|
||||||
|
|
||||||
use filetime::*;
|
use self::filetime::*;
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "mv";
|
static UTIL_NAME: &'static str = "mv";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "nl";
|
static UTIL_NAME: &'static str = "nl";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::env;
|
use std::env;
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "paste";
|
static UTIL_NAME: &'static str = "paste";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "printf";
|
static UTIL_NAME: &'static str = "printf";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "ptx";
|
static UTIL_NAME: &'static str = "ptx";
|
|
@ -1,11 +1,7 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "pwd";
|
static UTIL_NAME: &'static str = "pwd";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_default() {
|
fn test_default() {
|
||||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
let (at, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,13 +1,9 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "readlink";
|
static UTIL_NAME: &'static str = "readlink";
|
||||||
|
|
||||||
static GIBBERISH: &'static str = "supercalifragilisticexpialidocious";
|
static GIBBERISH: &'static str = "supercalifragilisticexpialidocious";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_canonicalize() {
|
fn test_canonicalize() {
|
||||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
let (at, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "realpath";
|
static UTIL_NAME: &'static str = "realpath";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "rm";
|
static UTIL_NAME: &'static str = "rm";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "seq";
|
static UTIL_NAME: &'static str = "seq";
|
|
@ -1,11 +1,7 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "sort";
|
static UTIL_NAME: &'static str = "sort";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_numeric_floats_and_ints() {
|
fn test_numeric_floats_and_ints() {
|
||||||
test_helper("numeric_floats_and_ints", "-n");
|
test_helper("numeric_floats_and_ints", "-n");
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
|
|
||||||
|
@ -13,8 +10,6 @@ use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "split";
|
static UTIL_NAME: &'static str = "split";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn random_chars(n: usize) -> String {
|
fn random_chars(n: usize) -> String {
|
||||||
thread_rng().gen_ascii_chars().take(n).collect::<String>()
|
thread_rng().gen_ascii_chars().take(n).collect::<String>()
|
||||||
}
|
}
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "stdbuf";
|
static UTIL_NAME: &'static str = "stdbuf";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "sum";
|
static UTIL_NAME: &'static str = "sum";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "tac";
|
static UTIL_NAME: &'static str = "tac";
|
|
@ -1,13 +1,9 @@
|
||||||
extern crate uu_tail;
|
extern crate uu_tail;
|
||||||
use uu_tail::parse_size;
|
|
||||||
|
|
||||||
use std::io::Read;
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
use std::char::from_digit;
|
||||||
|
use std::io::{Read, Write};
|
||||||
|
use uu_tail::parse_size;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "tail";
|
static UTIL_NAME: &'static str = "tail";
|
||||||
|
|
||||||
|
@ -110,14 +106,14 @@ fn test_bytes_big() {
|
||||||
|
|
||||||
let mut big_input = at.make_scoped_file(FILE);
|
let mut big_input = at.make_scoped_file(FILE);
|
||||||
for i in 0..BYTES {
|
for i in 0..BYTES {
|
||||||
let digit = std::char::from_digit((i % 10) as u32, 10).unwrap();
|
let digit = from_digit((i % 10) as u32, 10).unwrap();
|
||||||
write!(&mut big_input, "{}", digit).expect("Could not write to FILE");
|
write!(&mut big_input, "{}", digit).expect("Could not write to FILE");
|
||||||
}
|
}
|
||||||
big_input.flush().expect("Could not flush FILE");
|
big_input.flush().expect("Could not flush FILE");
|
||||||
|
|
||||||
let mut big_expected = at.make_scoped_file(EXPECTED_FILE);
|
let mut big_expected = at.make_scoped_file(EXPECTED_FILE);
|
||||||
for i in (BYTES - N_ARG)..BYTES {
|
for i in (BYTES - N_ARG)..BYTES {
|
||||||
let digit = std::char::from_digit((i % 10) as u32, 10).unwrap();
|
let digit = from_digit((i % 10) as u32, 10).unwrap();
|
||||||
write!(&mut big_expected, "{}", digit).expect("Could not write to EXPECTED_FILE");
|
write!(&mut big_expected, "{}", digit).expect("Could not write to EXPECTED_FILE");
|
||||||
}
|
}
|
||||||
big_expected.flush().expect("Could not flush EXPECTED_FILE");
|
big_expected.flush().expect("Could not flush EXPECTED_FILE");
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// This file is part of the uutils coreutils package.
|
// This file is part of the uutils coreutils package.
|
||||||
//
|
//
|
||||||
|
@ -14,7 +11,6 @@ use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "test";
|
static UTIL_NAME: &'static str = "test";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_op_prec_and_or_1() {
|
fn test_op_prec_and_or_1() {
|
||||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,11 +1,8 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
extern crate time;
|
|
||||||
extern crate filetime;
|
extern crate filetime;
|
||||||
|
extern crate time;
|
||||||
|
|
||||||
use filetime::FileTime;
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
use self::filetime::FileTime;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "touch";
|
static UTIL_NAME: &'static str = "touch";
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "tr";
|
static UTIL_NAME: &'static str = "tr";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_toupper() {
|
fn test_toupper() {
|
||||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
let (_, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "true";
|
static UTIL_NAME: &'static str = "true";
|
|
@ -1,8 +1,5 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use std::io::{Seek, SeekFrom, Write};
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
use std::io::{Seek, SeekFrom, Write};
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "truncate";
|
static UTIL_NAME: &'static str = "truncate";
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "tsort";
|
static UTIL_NAME: &'static str = "tsort";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "unexpand";
|
static UTIL_NAME: &'static str = "unexpand";
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "uniq";
|
static UTIL_NAME: &'static str = "uniq";
|
||||||
|
@ -9,7 +6,6 @@ static INPUT: &'static str = "sorted.txt";
|
||||||
static SKIP_CHARS: &'static str = "skip-chars.txt";
|
static SKIP_CHARS: &'static str = "skip-chars.txt";
|
||||||
static SKIP_FIELDS: &'static str = "skip-fields.txt";
|
static SKIP_FIELDS: &'static str = "skip-fields.txt";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stdin_default() {
|
fn test_stdin_default() {
|
||||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
let (at, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,11 +1,7 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "unlink";
|
static UTIL_NAME: &'static str = "unlink";
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unlink_file() {
|
fn test_unlink_file() {
|
||||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
let (at, mut ucmd) = testing(UTIL_NAME);
|
|
@ -1,6 +1,3 @@
|
||||||
#[macro_use]
|
|
||||||
mod common;
|
|
||||||
|
|
||||||
use common::util::*;
|
use common::util::*;
|
||||||
|
|
||||||
static UTIL_NAME: &'static str = "wc";
|
static UTIL_NAME: &'static str = "wc";
|
69
tests/tests.rs
Normal file
69
tests/tests.rs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
extern crate filetime;
|
||||||
|
extern crate libc;
|
||||||
|
extern crate rand;
|
||||||
|
extern crate regex;
|
||||||
|
extern crate tempdir;
|
||||||
|
extern crate time;
|
||||||
|
extern crate uu_tail;
|
||||||
|
|
||||||
|
#[cfg(windows)] extern crate kernel32;
|
||||||
|
#[cfg(windows)] extern crate winapi;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
mod common;
|
||||||
|
|
||||||
|
#[path="../src/factor/sieve.rs"]
|
||||||
|
mod sieve;
|
||||||
|
|
||||||
|
#[cfg(unix)] mod test_chmod;
|
||||||
|
#[cfg(unix)] mod test_mv;
|
||||||
|
#[cfg(unix)] mod test_stdbuf;
|
||||||
|
#[cfg(unix)] mod test_touch;
|
||||||
|
#[cfg(unix)] mod test_unlink;
|
||||||
|
|
||||||
|
mod test_base64;
|
||||||
|
mod test_basename;
|
||||||
|
mod test_cat;
|
||||||
|
mod test_cksum;
|
||||||
|
mod test_comm;
|
||||||
|
mod test_cp;
|
||||||
|
mod test_cut;
|
||||||
|
mod test_dircolors;
|
||||||
|
mod test_dirname;
|
||||||
|
mod test_echo;
|
||||||
|
mod test_env;
|
||||||
|
mod test_expr;
|
||||||
|
mod test_factor;
|
||||||
|
mod test_false;
|
||||||
|
mod test_fold;
|
||||||
|
mod test_hashsum;
|
||||||
|
mod test_head;
|
||||||
|
mod test_link;
|
||||||
|
mod test_ln;
|
||||||
|
mod test_ls;
|
||||||
|
mod test_mkdir;
|
||||||
|
mod test_mktemp;
|
||||||
|
mod test_nl;
|
||||||
|
mod test_od;
|
||||||
|
mod test_paste;
|
||||||
|
mod test_printf;
|
||||||
|
mod test_ptx;
|
||||||
|
mod test_pwd;
|
||||||
|
mod test_readlink;
|
||||||
|
mod test_realpath;
|
||||||
|
mod test_rm;
|
||||||
|
mod test_rmdir;
|
||||||
|
mod test_seq;
|
||||||
|
mod test_sort;
|
||||||
|
mod test_split;
|
||||||
|
mod test_sum;
|
||||||
|
mod test_tac;
|
||||||
|
mod test_tail;
|
||||||
|
mod test_test;
|
||||||
|
mod test_tr;
|
||||||
|
mod test_true;
|
||||||
|
mod test_truncate;
|
||||||
|
mod test_tsort;
|
||||||
|
mod test_unexpand;
|
||||||
|
mod test_uniq;
|
||||||
|
mod test_wc;
|
Loading…
Reference in a new issue