diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..2cbfe4016 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,116 @@ +version: "{build} ~ {branch}" + +branches: + except: + - gh-pages + +os: Visual Studio 2015 + +matrix: + allow_failures: + - CHANNEL: nightly + +environment: + global: + FEATURES: "generic" + matrix: + - CHANNEL: 1.27.0 + ARCH: i686 + TOOLCHAIN: msvc + - CHANNEL: stable + ARCH: i686 + TOOLCHAIN: msvc + - CHANNEL: stable + ARCH: x86_64 + TOOLCHAIN: msvc +# - CHANNEL: beta +# ARCH: i686 +# TOOLCHAIN: msvc +# - CHANNEL: beta +# ARCH: x86_64 +# TOOLCHAIN: msvc + - CHANNEL: nightly + ARCH: i686 + TOOLCHAIN: msvc + - CHANNEL: nightly + ARCH: x86_64 + TOOLCHAIN: msvc + - CHANNEL: stable + ARCH: i686 + TOOLCHAIN: gnu + - CHANNEL: stable + ARCH: x86_64 + TOOLCHAIN: gnu +# - CHANNEL: beta +# ARCH: i686 +# TOOLCHAIN: gnu +# - CHANNEL: beta +# ARCH: x86_64 +# TOOLCHAIN: gnu + - CHANNEL: nightly + ARCH: i686 + TOOLCHAIN: gnu + - CHANNEL: nightly + ARCH: x86_64 + TOOLCHAIN: gnu + - CHANNEL: stable + ARCH: i686 + TOOLCHAIN: gnu + MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download + MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z + MINGW_DIR: mingw32 + DIR_TEMP_MINGW: C:\cached\mingw + +install: + # force branch checkout (if knowable), then reset to the specific commit ## (can be needed for accurate code coverage info) + # * this allows later apps to see the branch name using standard `git branch` operations, yet always builds the correct specific commit + # * ref: [`@`](https://archive.is/RVpnF) + - if DEFINED APPVEYOR_REPO_BRANCH if /I "%APPVEYOR_REPO_SCM%"=="git" ( git checkout "%APPVEYOR_REPO_BRANCH%" & git reset --hard "%APPVEYOR_REPO_COMMIT%" ) + # ensure CWD is project main directory + - cd "%APPVEYOR_BUILD_FOLDER%" + # create a working area + - ps: if ( ! $env:CI_TEMP_DIR ) { $env:CI_TEMP_DIR = "${env:TEMP}\${env:APPVEYOR_JOB_ID}" ; mkdir -force $env:CI_TEMP_DIR | out-null } + - set "TARGET=%ARCH%-pc-windows-%TOOLCHAIN%" + # install `rust` via `rustup` + - call appveyor DownloadFile "https://win.rustup.rs/" -FileName "%CI_TEMP_DIR%\rustup-init.exe" + - call "%CI_TEMP_DIR%\\rustup-init.exe" -y --default-toolchain %CHANNEL% --default-host %TARGET% --no-modify-path + - set "PATH=%PATH%;%USERPROFILE%\.cargo\bin" + - rustc -vV + - cargo -vV + + # finalize FEATURES + - if /I "%CHANNEL%"=="nightly" set "FEATURES=nightly %FEATURES%" + + # "gnu" toolchain setup + - if /I "%TOOLCHAIN%"=="gnu" set "PATH=%PATH%;C:\MinGW\bin" + # * use the system MSYS if we can + - if /I "%TOOLCHAIN%"=="gnu" if /I "%ARCH%"=="i686" set "MSYS_BITS=32" + - if /I "%TOOLCHAIN%"=="gnu" if /I "%ARCH%"=="x86_64" set "MSYS_BITS=64" + - if defined MSYS_BITS set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH% + # * specific MinGW, if specified + - ps: | + if ((Test-Path Env:\MINGW_ARCHIVE) -and -not (Test-Path "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}")) { + if (Test-Path "${env:DIR_TEMP_MINGW}") { + rm -Recurse ${env:DIR_TEMP_MINGW}\*; + } + New-Item -ItemType Directory -Force -Path ${env:DIR_TEMP_MINGW} | Out-Null; + $download_loc = ${env:MINGW_URL}; + appveyor DownloadFile $download_loc -FileName "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}"; + } + - if defined MINGW_ARCHIVE 7z x -y "%DIR_TEMP_MINGW%\%MINGW_ARCHIVE%" > nul + - if defined MINGW_ARCHIVE set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% + + # "msvc" toolchain setup + - if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "i686" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" + - if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "x86_64" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 + - if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "x86_64" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 + +artifacts: + - path: target\debug\uutils.exe + name: uutils.exe + +build_script: + - cargo build --features "%FEATURES%" --no-default-features + +test_script: + - cargo test --no-fail-fast --features "%FEATURES%" --no-default-features diff --git a/codecov.yml b/.codecov.yml similarity index 100% rename from codecov.yml rename to .codecov.yml diff --git a/.travis.yml b/.travis.yml index d55c91fbf..6673c1fa9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,29 @@ language: rust + +rust: + - stable + - beta + +os: + - linux + - osx + +env: + # sphinx v1.8.0 is bugged & fails for linux builds; so, force specfic `sphinx` version + global: FEATURES='' TEST_INSTALL='' SPHINX_VERSIONED='sphinx==1.7.8' + matrix: + allow_failures: + - rust: nightly fast_finish: true include: + - rust: 1.27.0 - rust: stable os: linux - env: FEATURES='' + env: TEST_INSTALL=true - rust: stable os: osx - env: FEATURES='' - - rust: beta - os: linux - env: FEATURES='' - - rust: beta - os: osx - env: FEATURES='' + env: TEST_INSTALL=true - rust: nightly os: linux env: FEATURES=nightly @@ -23,10 +33,6 @@ matrix: - rust: nightly os: linux env: FEATURES=nightly,redox CC=x86_64-unknown-redox-gcc CARGO_ARGS='--no-default-features --target=x86_64-unknown-redox' REDOX=1 - allow_failures: - - rust: nightly - os: linux - env: FEATURES=nightly,redox CC=x86_64-unknown-redox-gcc CARGO_ARGS='--no-default-features --target=x86_64-unknown-redox' REDOX=1 cache: directories: @@ -38,20 +44,18 @@ before_install: - if [ $REDOX ]; then ./.travis/redox-toolchain.sh; fi install: - - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install python-pip && sudo pip install sphinx; fi + - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install python-pip && sudo pip install $SPHINX_VERSIONED; fi - | if [ $TRAVIS_OS_NAME = osx ]; then brew update brew upgrade python - pip3 install sphinx + pip3 install $SPHINX_VERSIONED fi script: - cargo build $CARGO_ARGS --features "$FEATURES" - if [ ! $REDOX ]; then cargo test $CARGO_ARGS --features "$FEATURES" --no-fail-fast; fi - - mkdir installdir_test - - DESTDIR=installdir_test make install - - "[ `ls installdir_test/usr/local/bin | wc -l` -gt 0 ]" + - if [ -n "$TEST_INSTALL" ]; then mkdir installdir_test; DESTDIR=installdir_test make install; [ `ls installdir_test/usr/local/bin | wc -l` -gt 0 ]; fi addons: apt: @@ -64,4 +68,3 @@ after_success: | cargo tarpaulin --out Xml bash <(curl -s https://codecov.io/bash) fi - diff --git a/Cargo.toml b/Cargo.toml index 76acc235e..8b74f668f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "uutils" version = "0.0.1" authors = [] build = "build.rs" +autotests = false [features] unix = [ diff --git a/README.md b/README.md index d3ccfe778..c8713e36f 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Requirements ### Rust Version ### uutils follows Rust's release channels and is tested against stable, beta and nightly. -The current oldest supported version of the Rust compiler is `1.22.0`. +The current oldest supported version of the Rust compiler is `1.27.0`. On both Windows and Redox, only the nightly version is tested currently. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index bcf2fecae..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,58 +0,0 @@ -os: Visual Studio 2015 - -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - MSYS_BITS: 64 - TOOLCHAIN: msvc - PLATFORM: x86_64 - - TARGET: i686-pc-windows-msvc - MSYS_BITS: 32 - TOOLCHAIN: msvc - PLATFORM: i686 - - TARGET: i686-pc-windows-gnu - MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download - MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z - MINGW_DIR: mingw32 - DIR_TEMP_MINGW: C:\cached\mingw - - TARGET: x86_64-pc-windows-gnu - MSYS_BITS: 64 - -install: - - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin;C:\MinGW\bin - - # Use the system msys if we can - - if defined MSYS_BITS set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH% - - - ps: >- - Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"; - if ((Test-Path Env:\MINGW_ARCHIVE) -and -not (Test-Path "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}")) { - if (Test-Path "${env:DIR_TEMP_MINGW}") { - rm -Recurse ${env:DIR_TEMP_MINGW}\*; - } - New-Item -ItemType Directory -Force -Path ${env:DIR_TEMP_MINGW} | Out-Null; - $download_loc = ${env:MINGW_URL}; - Start-FileDownload $download_loc -FileName "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}"; - } - - if defined MINGW_ARCHIVE 7z x -y "%DIR_TEMP_MINGW%\%MINGW_ARCHIVE%" > nul - - if defined MINGW_ARCHIVE set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% - - - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - - - rustc -V - - cargo -V - - if "%TOOLCHAIN%" == "msvc" if "%PLATFORM%" == "i686" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" - - if "%TOOLCHAIN%" == "msvc" if "%PLATFORM%" == "x86_64" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 - - if "%TOOLCHAIN%" == "msvc" if "%PLATFORM%" == "x86_64" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 - -artifacts: - - path: target\debug\uutils.exe - name: uutils.exe - -build: false - -test_script: - - cargo test --no-fail-fast --features "nightly generic" --no-default-features - -cache: - - c:\cached diff --git a/mkmain.rs b/mkmain.rs index 9270b5390..f065ea8b2 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -13,7 +13,7 @@ use uu_@UTIL_CRATE@::uumain; fn main() { uucore::panic::install_sigpipe_hook(); - let code = uumain(std::env::args().collect()); + let code = uumain(uucore::args().collect()); // Since stdout is line-buffered by default, we need to ensure any pending // writes are flushed before exiting. Ideally, this should be enforced by // each utility. diff --git a/src/cp/cp.rs b/src/cp/cp.rs index de05619c4..e19904ef1 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -24,9 +24,6 @@ extern crate walkdir; #[cfg(unix)] extern crate xattr; -#[cfg(windows)] -use std::os::windows::io::AsRawHandle; - #[cfg(windows)] extern crate kernel32; #[cfg(windows)] @@ -733,7 +730,7 @@ fn preserve_hardlinks( } #[cfg(windows)] { - let mut stat = mem::uninitialized(); + let stat = mem::uninitialized(); let handle = CreateFile2( src_path.as_ptr() as *const u16, winapi::um::winnt::GENERIC_READ, @@ -748,7 +745,7 @@ fn preserve_hardlinks( std::io::Error::last_os_error() ).into()); } - inode = (((*stat).nFileIndexHigh as u64) << 32 | (*stat).nFileIndexLow as u64); + inode = ((*stat).nFileIndexHigh as u64) << 32 | (*stat).nFileIndexLow as u64; nlinks = (*stat).nNumberOfLinks as u64; } diff --git a/src/du/du.rs b/src/du/du.rs index 8e17a7bd4..7acdd08d5 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -14,8 +14,6 @@ extern crate time; #[macro_use] extern crate uucore; -// XXX: remove when we no longer support 1.22.0 -use std::ascii::AsciiExt; use std::collections::HashSet; use std::env; use std::fs; diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index e0f5ff428..a902290c4 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -32,8 +32,6 @@ use regex::Regex; use sha1::Sha1; use sha2::{Sha224, Sha256, Sha384, Sha512}; use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shake256}; -#[allow(unused_imports)] -use std::ascii::AsciiExt; use std::fs::File; use std::io::{self, stdin, BufRead, BufReader, Read}; use std::path::Path; diff --git a/src/ls/ls.rs b/src/ls/ls.rs index 80f57f448..25bd83834 100644 --- a/src/ls/ls.rs +++ b/src/ls/ls.rs @@ -18,6 +18,7 @@ use pretty_bytes::converter::convert; use term_grid::{Cell, Direction, Filling, Grid, GridOptions}; use time::{strftime, Timespec}; +#[cfg(unix)] #[macro_use] extern crate lazy_static; @@ -587,11 +588,13 @@ fn color_name(name: String, typ: &str) -> String { } } +#[cfg(unix)] macro_rules! has { ($mode:expr, $perm:expr) => ( $mode & ($perm as mode_t) != 0 ) } + #[cfg(unix)] fn display_file_name( path: &Path, @@ -698,4 +701,3 @@ fn display_symlink_count(metadata: &Metadata) -> String { fn display_symlink_count(metadata: &Metadata) -> String { metadata.nlink().to_string() } - diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index 9e8581c67..c3bc0107e 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -16,7 +16,7 @@ extern crate libc; extern crate uucore; use std::fs; -use std::path::{Path, PathBuf}; +use std::path::Path; static NAME: &str = "mkdir"; static VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/src/pinky/pinky.rs b/src/pinky/pinky.rs index 697dd158a..0edf3e0f2 100644 --- a/src/pinky/pinky.rs +++ b/src/pinky/pinky.rs @@ -164,8 +164,6 @@ pub trait Capitalize { impl Capitalize for str { fn capitalize(&self) -> String { - #[allow(unused_imports)] - use std::ascii::AsciiExt; self.char_indices() .fold(String::with_capacity(self.len()), |mut acc, x| { if x.0 != 0 { diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 47da3149e..47070d9a7 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -14,8 +14,6 @@ extern crate getopts; #[macro_use] extern crate uucore; -#[allow(unused_imports)] -use std::ascii::AsciiExt; use std::fs::{metadata, File, OpenOptions}; use std::io::Result; use std::path::Path; diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 3a5a09a66..578c9eb3b 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -10,6 +10,7 @@ failure_derive = { version = "0.1.1", optional = true } time = { version = "0.1.40", optional = true } data-encoding = { version = "^2.1", optional = true } libc = { version = "0.2.42", optional = true } +wild = "2.0.1" [target.'cfg(target_os = "redox")'.dependencies] termion = "1.5" diff --git a/src/uucore/fs.rs b/src/uucore/fs.rs index 39a7c4757..65819afcc 100644 --- a/src/uucore/fs.rs +++ b/src/uucore/fs.rs @@ -25,6 +25,7 @@ use std::io::Result as IOResult; use std::path::{Component, Path, PathBuf}; use std::borrow::Cow; +#[cfg(unix)] macro_rules! has { ($mode:expr, $perm:expr) => ( $mode & ($perm as u32) != 0 diff --git a/src/uucore/lib.rs b/src/uucore/lib.rs index e391d6975..dc8c3f904 100644 --- a/src/uucore/lib.rs +++ b/src/uucore/lib.rs @@ -1,3 +1,9 @@ +extern crate wild; + +pub fn args() -> impl Iterator { + wild::args() +} + #[cfg(feature = "libc")] pub extern crate libc; #[cfg(feature = "winapi")] diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index e1480893a..a2481bcf7 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -13,7 +13,6 @@ include!(concat!(env!("OUT_DIR"), "/uutils_crates.rs")); use std::collections::hash_map::HashMap; use std::path::Path; -use std::env; use std::io::Write; extern crate uucore; @@ -40,7 +39,7 @@ fn main() { uucore::panic::install_sigpipe_hook(); let umap = util_map(); - let mut args: Vec = env::args().collect(); + let mut args: Vec = uucore::args().collect(); // try binary name as util name. let args0 = args[0].clone(); diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 7bc6d5d7f..d96682c11 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -16,8 +16,6 @@ extern crate uucore; use getopts::{Matches, Options}; -#[allow(unused_imports)] -use std::ascii::AsciiExt; use std::fs::File; use std::io::{stdin, BufRead, BufReader, Read}; use std::path::Path; diff --git a/tests/test_cp.rs b/tests/test_cp.rs index 82651be57..d47fbb5c9 100644 --- a/tests/test_cp.rs +++ b/tests/test_cp.rs @@ -1,4 +1,5 @@ use common::util::*; +#[cfg(not(windows))] use std::fs::set_permissions; static TEST_EXISTING_FILE: &str = "existing_file.txt"; diff --git a/tests/tests.rs b/tests/tests.rs index 08552a4d5..5885d8f9b 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,6 +1,7 @@ #[macro_use] mod common; +#[cfg(unix)] #[macro_use] extern crate lazy_static;