mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 66afdbb3ae | |||
| bdd85b9bf4 | |||
| 7a57cb97d7 | |||
| 129e5abb54 | |||
| 07be4261b9 | |||
| d26971f869 | |||
| 28018bc8c2 | |||
| 37dd671e5e | |||
| d39224d670 | |||
| 6c20fae3e8 | |||
| 3ab81fcd2f | |||
| 0703784cab | |||
| f51bd0d6a3 | |||
| 514bdcdc74 | |||
| 4b64585290 | |||
| 10eba445c9 | |||
| a0c0779849 | |||
| 62bf1e14de | |||
| de2d748a88 | |||
| 509d51e872 | |||
| f98b841d23 | |||
| 67d23e80ff | |||
| 968377eebd |
+33
-343
@@ -1,359 +1,49 @@
|
|||||||
name: CICD
|
name: CICD
|
||||||
|
|
||||||
# spell-checker:ignore CICD CODECOV MSVC MacOS Peltoche SHAs buildable clippy esac fakeroot gnueabihf halium libssl mkdir musl popd printf pushd rustfmt softprops toolchain
|
on:
|
||||||
|
push:
|
||||||
env:
|
tags:
|
||||||
PROJECT_NAME: dust
|
- 'v*'
|
||||||
PROJECT_DESC: "du + rust = dust"
|
pull_request:
|
||||||
PROJECT_AUTH: "bootandy"
|
|
||||||
RUST_MIN_SRV: "1.31.0"
|
|
||||||
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
style:
|
build-musl-deb:
|
||||||
name: Style
|
runs-on: ubuntu-latest
|
||||||
runs-on: ${{ matrix.job.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
job:
|
|
||||||
- { os: ubuntu-latest }
|
|
||||||
- { os: macos-latest }
|
|
||||||
- { os: windows-latest }
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v4
|
||||||
- name: Initialize workflow variables
|
|
||||||
id: vars
|
- name: Install musl tools
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
# 'windows-latest' `cargo fmt` is bugged for this project (see reasons @ GH:rust-lang/rustfmt #3324, #3590, #3688 ; waiting for repair)
|
sudo apt-get update
|
||||||
JOB_DO_FORMAT_TESTING="true"
|
sudo apt-get install -y musl-tools
|
||||||
case ${{ matrix.job.os }} in windows-latest) unset JOB_DO_FORMAT_TESTING ;; esac;
|
|
||||||
echo set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING:-<empty>/false}
|
- name: Install Rust with musl target
|
||||||
echo ::set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING}
|
|
||||||
# target-specific options
|
|
||||||
# * CARGO_FEATURES_OPTION
|
|
||||||
CARGO_FEATURES_OPTION='' ;
|
|
||||||
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
|
|
||||||
echo set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION}
|
|
||||||
echo ::set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION}
|
|
||||||
- name: Install `rust` toolchain
|
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
|
target: x86_64-unknown-linux-musl
|
||||||
override: true
|
override: true
|
||||||
profile: minimal # minimal component installation (ie, no documentation)
|
|
||||||
components: rustfmt, clippy
|
|
||||||
- name: Install wget for Windows
|
|
||||||
if: matrix.job.os == 'windows-latest'
|
|
||||||
run: choco install wget --no-progress
|
|
||||||
- name: typos-action
|
|
||||||
uses: crate-ci/typos@v1.28.4
|
|
||||||
- name: "`fmt` testing"
|
|
||||||
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: fmt
|
|
||||||
args: --all -- --check
|
|
||||||
- name: "`clippy` testing"
|
|
||||||
if: success() || failure() # run regardless of prior step ("`fmt` testing") success/failure
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: clippy
|
|
||||||
args: ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -- -D warnings
|
|
||||||
|
|
||||||
min_version:
|
- name: Build with musl
|
||||||
name: MinSRV # Minimum supported rust version
|
run: cargo build --release --target x86_64-unknown-linux-musl
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Install `rust` toolchain (v${{ env.RUST_MIN_SRV }})
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: ${{ env.RUST_MIN_SRV }}
|
|
||||||
profile: minimal # minimal component installation (ie, no documentation)
|
|
||||||
- name: Test
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: test
|
|
||||||
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ${{ matrix.job.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
job:
|
|
||||||
# { os, target, cargo-options, features, use-cross, toolchain }
|
|
||||||
- {
|
|
||||||
os: ubuntu-latest,
|
|
||||||
target: aarch64-unknown-linux-gnu,
|
|
||||||
use-cross: use-cross,
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
os: ubuntu-latest,
|
|
||||||
target: aarch64-unknown-linux-musl,
|
|
||||||
use-cross: use-cross,
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
os: ubuntu-latest,
|
|
||||||
target: arm-unknown-linux-gnueabihf,
|
|
||||||
use-cross: use-cross,
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
os: ubuntu-latest,
|
|
||||||
target: arm-unknown-linux-musleabi,
|
|
||||||
use-cross: use-cross,
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
os: ubuntu-latest,
|
|
||||||
target: i686-unknown-linux-gnu,
|
|
||||||
use-cross: use-cross,
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
os: ubuntu-latest,
|
|
||||||
target: i686-unknown-linux-musl,
|
|
||||||
use-cross: use-cross,
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
os: ubuntu-latest,
|
|
||||||
target: x86_64-unknown-linux-gnu,
|
|
||||||
use-cross: use-cross,
|
|
||||||
}
|
|
||||||
- {
|
|
||||||
os: ubuntu-latest,
|
|
||||||
target: x86_64-unknown-linux-musl,
|
|
||||||
use-cross: use-cross,
|
|
||||||
}
|
|
||||||
- { os: macos-latest, target: x86_64-apple-darwin }
|
|
||||||
- { os: windows-latest, target: i686-pc-windows-gnu }
|
|
||||||
- { os: windows-latest, target: i686-pc-windows-msvc }
|
|
||||||
- { os: windows-latest, target: x86_64-pc-windows-gnu } ## !maint: [rivy; 2020-01-21] may break due to rust bug; follow possible solution from GH:rust-lang/rust#47048 (refs: GH:rust-lang/rust#47048 , GH:rust-lang/rust#53454 , GH:bike-barn/hermit#172 )
|
|
||||||
- { os: windows-latest, target: x86_64-pc-windows-msvc }
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Install any prerequisites
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
case ${{ matrix.job.target }} in
|
|
||||||
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
|
|
||||||
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install binutils-aarch64-linux-gnu ;;
|
|
||||||
esac
|
|
||||||
- name: Initialize workflow variables
|
|
||||||
id: vars
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
# toolchain
|
|
||||||
TOOLCHAIN="stable" ## default to "stable" toolchain
|
|
||||||
# * specify alternate TOOLCHAIN for *-pc-windows-gnu targets; gnu targets on Windows are broken for the standard *-pc-windows-msvc toolchain (refs: <https://github.com/rust-lang/rust/issues/47048>, <https://github.com/rust-lang/rust/issues/53454>, <https://github.com/rust-lang/cargo/issues/6754>)
|
|
||||||
case ${{ matrix.job.target }} in *-pc-windows-gnu) TOOLCHAIN="stable-${{ matrix.job.target }}" ;; esac;
|
|
||||||
# * use requested TOOLCHAIN if specified
|
|
||||||
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
|
|
||||||
echo set-output name=TOOLCHAIN::${TOOLCHAIN}
|
|
||||||
echo ::set-output name=TOOLCHAIN::${TOOLCHAIN}
|
|
||||||
# staging directory
|
|
||||||
STAGING='_staging'
|
|
||||||
echo set-output name=STAGING::${STAGING}
|
|
||||||
echo ::set-output name=STAGING::${STAGING}
|
|
||||||
# determine EXE suffix
|
|
||||||
EXE_suffix="" ; case ${{ matrix.job.target }} in *-pc-windows-*) EXE_suffix=".exe" ;; esac;
|
|
||||||
echo set-output name=EXE_suffix::${EXE_suffix}
|
|
||||||
echo ::set-output name=EXE_suffix::${EXE_suffix}
|
|
||||||
# parse commit reference info
|
|
||||||
REF_NAME=${GITHUB_REF#refs/*/}
|
|
||||||
unset REF_BRANCH ; case ${GITHUB_REF} in refs/heads/*) REF_BRANCH=${GITHUB_REF#refs/heads/} ;; esac;
|
|
||||||
unset REF_TAG ; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/} ;; esac;
|
|
||||||
REF_SHAS=${GITHUB_SHA:0:8}
|
|
||||||
echo set-output name=REF_NAME::${REF_NAME}
|
|
||||||
echo set-output name=REF_BRANCH::${REF_BRANCH}
|
|
||||||
echo set-output name=REF_TAG::${REF_TAG}
|
|
||||||
echo set-output name=REF_SHAS::${REF_SHAS}
|
|
||||||
echo ::set-output name=REF_NAME::${REF_NAME}
|
|
||||||
echo ::set-output name=REF_BRANCH::${REF_BRANCH}
|
|
||||||
echo ::set-output name=REF_TAG::${REF_TAG}
|
|
||||||
echo ::set-output name=REF_SHAS::${REF_SHAS}
|
|
||||||
# parse target
|
|
||||||
unset TARGET_ARCH ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; aarch-*) TARGET_ARCH=aarch64 ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac;
|
|
||||||
echo set-output name=TARGET_ARCH::${TARGET_ARCH}
|
|
||||||
echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
|
|
||||||
unset TARGET_OS ; case ${{ matrix.job.target }} in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
|
|
||||||
echo set-output name=TARGET_OS::${TARGET_OS}
|
|
||||||
echo ::set-output name=TARGET_OS::${TARGET_OS}
|
|
||||||
# package name
|
|
||||||
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
|
|
||||||
PKG_BASENAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.job.target }}
|
|
||||||
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
|
|
||||||
echo set-output name=PKG_suffix::${PKG_suffix}
|
|
||||||
echo set-output name=PKG_BASENAME::${PKG_BASENAME}
|
|
||||||
echo set-output name=PKG_NAME::${PKG_NAME}
|
|
||||||
echo ::set-output name=PKG_suffix::${PKG_suffix}
|
|
||||||
echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
|
|
||||||
echo ::set-output name=PKG_NAME::${PKG_NAME}
|
|
||||||
# deployable tag? (ie, leading "vM" or "M"; M == version number)
|
|
||||||
unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
|
|
||||||
echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
|
|
||||||
echo ::set-output name=DEPLOY::${DEPLOY}
|
|
||||||
# target-specific options
|
|
||||||
# * CARGO_FEATURES_OPTION
|
|
||||||
CARGO_FEATURES_OPTION='' ;
|
|
||||||
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
|
|
||||||
echo set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION}
|
|
||||||
echo ::set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION}
|
|
||||||
# * CARGO_USE_CROSS (truthy)
|
|
||||||
CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac;
|
|
||||||
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
|
|
||||||
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
|
|
||||||
# # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host)
|
|
||||||
JOB_DO_TESTING="true"
|
|
||||||
case ${{ matrix.job.target }} in arm-*|aarch64-*) unset JOB_DO_TESTING ;; esac;
|
|
||||||
echo set-output name=JOB_DO_TESTING::${JOB_DO_TESTING:-<empty>/false}
|
|
||||||
echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING}
|
|
||||||
# # * test only binary for arm-type targets
|
|
||||||
unset CARGO_TEST_OPTIONS
|
|
||||||
unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-*|aarch64-*) CARGO_TEST_OPTIONS="--bin ${PROJECT_NAME}" ;; esac;
|
|
||||||
echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
|
||||||
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
|
||||||
# * strip executable?
|
|
||||||
STRIP="strip" ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;; aarch64-unknown-linux-musl) STRIP="" ;; armv7-unknown-linux-musleabi) STRIP="" ;; arm-unknown-linux-musleabi) STRIP="" ;; esac;
|
|
||||||
|
|
||||||
|
|
||||||
echo set-output name=STRIP::${STRIP}
|
|
||||||
echo ::set-output name=STRIP::${STRIP}
|
|
||||||
- name: Create all needed build/work directories
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir -p '${{ steps.vars.outputs.STAGING }}'
|
|
||||||
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}'
|
|
||||||
- name: rust toolchain ~ install
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: ${{ steps.vars.outputs.TOOLCHAIN }}
|
|
||||||
target: ${{ matrix.job.target }}
|
|
||||||
override: true
|
|
||||||
profile: minimal # minimal component installation (ie, no documentation)
|
|
||||||
- name: Info
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
gcc --version || true
|
|
||||||
rustup -V
|
|
||||||
rustup toolchain list
|
|
||||||
rustup default
|
|
||||||
cargo -V
|
|
||||||
rustc -V
|
|
||||||
- name: Build
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
|
||||||
command: build
|
|
||||||
args: --release --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
|
|
||||||
- name: Install cargo-deb
|
- name: Install cargo-deb
|
||||||
uses: actions-rs/cargo@v1
|
run: cargo install cargo-deb
|
||||||
with:
|
|
||||||
command: install
|
|
||||||
args: cargo-deb
|
|
||||||
if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl'
|
|
||||||
- name: Build deb
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: deb
|
|
||||||
args: --no-build --target=${{ matrix.job.target }}
|
|
||||||
if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl'
|
|
||||||
- name: Test
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
|
||||||
command: test
|
|
||||||
args: --target=${{ matrix.job.target }} ${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
|
|
||||||
- name: Archive executable artifacts
|
|
||||||
uses: actions/upload-artifact@master
|
|
||||||
with:
|
|
||||||
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}
|
|
||||||
path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
|
|
||||||
- name: Archive deb artifacts
|
|
||||||
uses: actions/upload-artifact@master
|
|
||||||
with:
|
|
||||||
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}.deb
|
|
||||||
path: target/${{ matrix.job.target }}/debian
|
|
||||||
if: matrix.job.target == 'i686-unknown-linux-musl' || matrix.job.target == 'x86_64-unknown-linux-musl'
|
|
||||||
- name: Package
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
# binary
|
|
||||||
cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
|
|
||||||
# `strip` binary (if needed)
|
|
||||||
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' ; fi
|
|
||||||
# README and LICENSE
|
|
||||||
cp README.md '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
|
|
||||||
cp LICENSE '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
|
|
||||||
# base compressed package
|
|
||||||
pushd '${{ steps.vars.outputs.STAGING }}/' >/dev/null
|
|
||||||
case ${{ matrix.job.target }} in
|
|
||||||
*-pc-windows-*) 7z -y a '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* | tail -2 ;;
|
|
||||||
*) tar czf '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* ;;
|
|
||||||
esac;
|
|
||||||
popd >/dev/null
|
|
||||||
- name: Publish
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: steps.vars.outputs.DEPLOY
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
|
|
||||||
target/${{ matrix.job.target }}/debian/*.deb
|
|
||||||
|
|
||||||
|
- name: Create .deb package
|
||||||
|
run: |
|
||||||
|
cargo deb --target x86_64-unknown-linux-musl --no-build
|
||||||
|
|
||||||
|
- name: Upload .deb artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: musl-deb-package
|
||||||
|
path: target/x86_64-unknown-linux-musl/debian/*.deb
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
files: target/x86_64-unknown-linux-musl/debian/*.deb
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
## fix! [rivy; 2020-22-01] `cargo tarpaulin` is unable to test this repo at the moment; alternate recipe or another testing framework?
|
|
||||||
# coverage:
|
|
||||||
# name: Code Coverage
|
|
||||||
# runs-on: ${{ matrix.job.os }}
|
|
||||||
# strategy:
|
|
||||||
# fail-fast: true
|
|
||||||
# matrix:
|
|
||||||
# # job: [ { os: ubuntu-latest }, { os: macos-latest }, { os: windows-latest } ]
|
|
||||||
# job: [ { os: ubuntu-latest } ] ## cargo-tarpaulin is currently only available on linux
|
|
||||||
# steps:
|
|
||||||
# - uses: actions/checkout@v1
|
|
||||||
# # - name: Reattach HEAD ## may be needed for accurate code coverage info
|
|
||||||
# # run: git checkout ${{ github.head_ref }}
|
|
||||||
# - name: Initialize workflow variables
|
|
||||||
# id: vars
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# # staging directory
|
|
||||||
# STAGING='_staging'
|
|
||||||
# echo set-output name=STAGING::${STAGING}
|
|
||||||
# echo ::set-output name=STAGING::${STAGING}
|
|
||||||
# # check for CODECOV_TOKEN availability (work-around for inaccessible 'secrets' object for 'if'; see <https://github.community/t5/GitHub-Actions/jobs-lt-job-id-gt-if-does-not-work-with-env-secrets/m-p/38549>)
|
|
||||||
# unset HAS_CODECOV_TOKEN
|
|
||||||
# if [ -n $CODECOV_TOKEN ]; then HAS_CODECOV_TOKEN='true' ; fi
|
|
||||||
# echo set-output name=HAS_CODECOV_TOKEN::${HAS_CODECOV_TOKEN}
|
|
||||||
# echo ::set-output name=HAS_CODECOV_TOKEN::${HAS_CODECOV_TOKEN}
|
|
||||||
# env:
|
|
||||||
# CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
|
|
||||||
# - name: Create all needed build/work directories
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# mkdir -p '${{ steps.vars.outputs.STAGING }}/work'
|
|
||||||
# - name: Install required packages
|
|
||||||
# run: |
|
|
||||||
# sudo apt-get -y install libssl-dev
|
|
||||||
# pushd '${{ steps.vars.outputs.STAGING }}/work' >/dev/null
|
|
||||||
# wget --no-verbose https://github.com/xd009642/tarpaulin/releases/download/0.9.3/cargo-tarpaulin-0.9.3-travis.tar.gz
|
|
||||||
# tar xf cargo-tarpaulin-0.9.3-travis.tar.gz
|
|
||||||
# cp cargo-tarpaulin "$(dirname -- "$(which cargo)")"/
|
|
||||||
# popd >/dev/null
|
|
||||||
# - name: Generate coverage
|
|
||||||
# run: |
|
|
||||||
# cargo tarpaulin --out Xml
|
|
||||||
# - name: Upload coverage results (CodeCov.io)
|
|
||||||
# # CODECOV_TOKEN (aka, "Repository Upload Token" for REPO from CodeCov.io) ## set via REPO/Settings/Secrets
|
|
||||||
# # if: secrets.CODECOV_TOKEN (not supported {yet?}; see <https://github.community/t5/GitHub-Actions/jobs-lt-job-id-gt-if-does-not-work-with-env-secrets/m-p/38549>)
|
|
||||||
# if: steps.vars.outputs.HAS_CODECOV_TOKEN
|
|
||||||
# run: |
|
|
||||||
# # CodeCov.io
|
|
||||||
# cargo tarpaulin --out Xml
|
|
||||||
# bash <(curl -s https://codecov.io/bash)
|
|
||||||
# env:
|
|
||||||
# CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
|
|
||||||
|
|||||||
Generated
+281
-358
File diff suppressed because it is too large
Load Diff
+7
-8
@@ -27,11 +27,11 @@ lto = true
|
|||||||
strip = true
|
strip = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ansi_term = "0.12"
|
clap = { version = "4", features = ["derive"] }
|
||||||
clap = { version = "4.4", features = ["derive"] }
|
lscolors = "0.21"
|
||||||
lscolors = "0.13"
|
nu-ansi-term = "0.50"
|
||||||
terminal_size = "0.2"
|
terminal_size = "0.4"
|
||||||
unicode-width = "0.1"
|
unicode-width = "0.2"
|
||||||
rayon = "1"
|
rayon = "1"
|
||||||
thousands = "0.2"
|
thousands = "0.2"
|
||||||
stfu8 = "0.2"
|
stfu8 = "0.2"
|
||||||
@@ -39,9 +39,8 @@ regex = "1"
|
|||||||
config-file = "0.2"
|
config-file = "0.2"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
directories = "4"
|
sysinfo = "0.37"
|
||||||
sysinfo = "0.27"
|
ctrlc = "3"
|
||||||
ctrlc = "3.4"
|
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
|
||||||
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||||
|
|||||||
@@ -13,6 +13,17 @@ Because I want an easy way to see where my disk is being used.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
Study the above picture.
|
||||||
|
|
||||||
|
* We see `target` has 1.8G
|
||||||
|
* `target/debug` is the same size as `target` - so we know nearly all the disk usage of the 1.5G is in this folder
|
||||||
|
* `target/debug/deps` this is 1.2G - Note the bar jumps down to 70% to indicate that most disk usage is here but not all.
|
||||||
|
* `target/debug/deps/dust-e78c9f87a17f24f3` - This is the largest file in this folder, but it is only 46M - Note the bar jumps down to 3% to indicate the file is small.
|
||||||
|
|
||||||
|
From here we can conclude:
|
||||||
|
* `target/debug/deps` takes the majority of the space in `target` and that `target/debug/deps` has a large number of relatively small files.
|
||||||
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
#### Cargo <a href="https://repology.org/project/du-dust/versions"><img src="https://repology.org/badge/vertical-allrepos/du-dust.svg" alt="Packaging status" align="right"></a>
|
#### Cargo <a href="https://repology.org/project/du-dust/versions"><img src="https://repology.org/badge/vertical-allrepos/du-dust.svg" alt="Packaging status" align="right"></a>
|
||||||
@@ -69,6 +80,8 @@ Dust will list a slightly-less-than-the-terminal-height number of the biggest su
|
|||||||
|
|
||||||
The different colors on the bars: These represent the combined tree hierarchy & disk usage. The shades of grey are used to indicate which parent folder a subfolder belongs to. For instance, look at the above screenshot. `.steam` is a folder taking 44% of the space. From the `.steam` bar is a light grey line that goes up. All these folders are inside `.steam` so if you delete `.steam` all that stuff will be gone too.
|
The different colors on the bars: These represent the combined tree hierarchy & disk usage. The shades of grey are used to indicate which parent folder a subfolder belongs to. For instance, look at the above screenshot. `.steam` is a folder taking 44% of the space. From the `.steam` bar is a light grey line that goes up. All these folders are inside `.steam` so if you delete `.steam` all that stuff will be gone too.
|
||||||
|
|
||||||
|
If you are new to the tool I recommend to try tweaking the `-n` parameter. `dust -n 10`, `dust -n 50`.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -125,4 +138,14 @@ reverse=true
|
|||||||
- [dirstat-rs](https://github.com/scullionw/dirstat-rs)
|
- [dirstat-rs](https://github.com/scullionw/dirstat-rs)
|
||||||
- `du -d 1 -h | sort -h`
|
- `du -d 1 -h | sort -h`
|
||||||
|
|
||||||
Note: Apparent-size is calculated slightly differently in dust to gdu. In dust each hard link is counted as using file_length space. In gdu only the first entry is counted.
|
## Why to use Dust over the Alternatives
|
||||||
|
|
||||||
|
Dust simply Does The Right Thing when handling lots of small files & directories. Dust keeps the output simple by only showing large entries.
|
||||||
|
|
||||||
|
Tools like ncdu & baobab, give you a view of directory sizes but you have no idea where the largest files are. For example directory A could have a size larger than directory B, but in fact the largest file is in B and not A. Finding this out via these other tools is not trivial whereas Dust will show the large file clearly in the tree hierarchy
|
||||||
|
|
||||||
|
Dust will not count hard links multiple times (unless you want to `-s`).
|
||||||
|
|
||||||
|
Typing `dust -n 90` will show you your 90 largest entries. `-n` is not quite like `head -n` or `tail -n`, dust is intelligent and chooses the largest entries
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -20,8 +20,8 @@ _dust() {
|
|||||||
'-T+[Number of threads to use]:THREADS:_default' \
|
'-T+[Number of threads to use]:THREADS:_default' \
|
||||||
'--threads=[Number of threads to use]:THREADS:_default' \
|
'--threads=[Number of threads to use]:THREADS:_default' \
|
||||||
'--config=[Specify a config file to use]:FILE:_files' \
|
'--config=[Specify a config file to use]:FILE:_files' \
|
||||||
'-n+[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER:_default' \
|
'-n+[Display the '\''n'\'' largest entries. (Default is terminal_height)]:NUMBER:_default' \
|
||||||
'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER:_default' \
|
'--number-of-lines=[Display the '\''n'\'' largest entries. (Default is terminal_height)]:NUMBER:_default' \
|
||||||
'*-X+[Exclude any file or directory with this path]:PATH:_files' \
|
'*-X+[Exclude any file or directory with this path]:PATH:_files' \
|
||||||
'*--ignore-directory=[Exclude any file or directory with this path]:PATH:_files' \
|
'*--ignore-directory=[Exclude any file or directory with this path]:PATH:_files' \
|
||||||
'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
|
'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
|||||||
[CompletionResult]::new('-T', '-T ', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
[CompletionResult]::new('-T', '-T ', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
||||||
[CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
[CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Number of threads to use')
|
||||||
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'Specify a config file to use')
|
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'Specify a config file to use')
|
||||||
[CompletionResult]::new('-n', '-n', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
[CompletionResult]::new('-n', '-n', [CompletionResultType]::ParameterName, 'Display the ''n'' largest entries. (Default is terminal_height)')
|
||||||
[CompletionResult]::new('--number-of-lines', '--number-of-lines', [CompletionResultType]::ParameterName, 'Number of lines of output to show. (Default is terminal_height - 10)')
|
[CompletionResult]::new('--number-of-lines', '--number-of-lines', [CompletionResultType]::ParameterName, 'Display the ''n'' largest entries. (Default is terminal_height)')
|
||||||
[CompletionResult]::new('-X', '-X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
[CompletionResult]::new('-X', '-X ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
||||||
[CompletionResult]::new('--ignore-directory', '--ignore-directory', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
[CompletionResult]::new('--ignore-directory', '--ignore-directory', [CompletionResultType]::ParameterName, 'Exclude any file or directory with this path')
|
||||||
[CompletionResult]::new('-I', '-I ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter')
|
[CompletionResult]::new('-I', '-I ', [CompletionResultType]::ParameterName, 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter')
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ set edit:completion:arg-completer[dust] = {|@words|
|
|||||||
cand -T 'Number of threads to use'
|
cand -T 'Number of threads to use'
|
||||||
cand --threads 'Number of threads to use'
|
cand --threads 'Number of threads to use'
|
||||||
cand --config 'Specify a config file to use'
|
cand --config 'Specify a config file to use'
|
||||||
cand -n 'Number of lines of output to show. (Default is terminal_height - 10)'
|
cand -n 'Display the ''n'' largest entries. (Default is terminal_height)'
|
||||||
cand --number-of-lines 'Number of lines of output to show. (Default is terminal_height - 10)'
|
cand --number-of-lines 'Display the ''n'' largest entries. (Default is terminal_height)'
|
||||||
cand -X 'Exclude any file or directory with this path'
|
cand -X 'Exclude any file or directory with this path'
|
||||||
cand --ignore-directory 'Exclude any file or directory with this path'
|
cand --ignore-directory 'Exclude any file or directory with this path'
|
||||||
cand -I 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter'
|
cand -I 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
complete -c dust -s d -l depth -d 'Depth to show' -r
|
complete -c dust -s d -l depth -d 'Depth to show' -r
|
||||||
complete -c dust -s T -l threads -d 'Number of threads to use' -r
|
complete -c dust -s T -l threads -d 'Number of threads to use' -r
|
||||||
complete -c dust -l config -d 'Specify a config file to use' -r -F
|
complete -c dust -l config -d 'Specify a config file to use' -r -F
|
||||||
complete -c dust -s n -l number-of-lines -d 'Number of lines of output to show. (Default is terminal_height - 10)' -r
|
complete -c dust -s n -l number-of-lines -d 'Display the \'n\' largest entries. (Default is terminal_height)' -r
|
||||||
complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this path' -r -F
|
complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this path' -r -F
|
||||||
complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r -F
|
complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r -F
|
||||||
complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
|
complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ Number of threads to use
|
|||||||
Specify a config file to use
|
Specify a config file to use
|
||||||
.TP
|
.TP
|
||||||
\fB\-n\fR, \fB\-\-number\-of\-lines\fR \fI<NUMBER>\fR
|
\fB\-n\fR, \fB\-\-number\-of\-lines\fR \fI<NUMBER>\fR
|
||||||
Number of lines of output to show. (Default is terminal_height \- 10)
|
Display the \*(Aqn\*(Aq largest entries. (Default is terminal_height)
|
||||||
.TP
|
.TP
|
||||||
\fB\-p\fR, \fB\-\-full\-paths\fR
|
\fB\-p\fR, \fB\-\-full\-paths\fR
|
||||||
Subdirectories will not have their path shortened
|
Subdirectories will not have their path shortened
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 107 KiB |
+1
-1
@@ -21,7 +21,7 @@ pub struct Cli {
|
|||||||
#[arg(long, value_name("FILE"), value_hint(ValueHint::FilePath))]
|
#[arg(long, value_name("FILE"), value_hint(ValueHint::FilePath))]
|
||||||
pub config: Option<String>,
|
pub config: Option<String>,
|
||||||
|
|
||||||
/// Number of lines of output to show. (Default is terminal_height - 10)
|
/// Display the 'n' largest entries. (Default is terminal_height)
|
||||||
#[arg(short, long, value_name("NUMBER"))]
|
#[arg(short, long, value_name("NUMBER"))]
|
||||||
pub number_of_lines: Option<usize>,
|
pub number_of_lines: Option<usize>,
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -244,7 +244,7 @@ fn convert_min_size(input: &str) -> Option<usize> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_config_locations(base: &Path) -> Vec<PathBuf> {
|
fn get_config_locations(base: PathBuf) -> Vec<PathBuf> {
|
||||||
vec![
|
vec![
|
||||||
base.join(".dust.toml"),
|
base.join(".dust.toml"),
|
||||||
base.join(".config").join("dust").join("config.toml"),
|
base.join(".config").join("dust").join("config.toml"),
|
||||||
@@ -267,8 +267,8 @@ pub fn get_config(conf_path: Option<&String>) -> Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if let Some(home) = directories::BaseDirs::new() {
|
if let Some(home) = std::env::home_dir() {
|
||||||
for path in get_config_locations(home.home_dir()) {
|
for path in get_config_locations(home) {
|
||||||
if path.exists()
|
if path.exists()
|
||||||
&& let Ok(config) = Config::from_config_file(&path)
|
&& let Ok(config) = Config::from_config_file(&path)
|
||||||
{
|
{
|
||||||
|
|||||||
+12
-2
@@ -1,8 +1,8 @@
|
|||||||
use crate::display_node::DisplayNode;
|
use crate::display_node::DisplayNode;
|
||||||
use crate::node::FileTime;
|
use crate::node::FileTime;
|
||||||
|
|
||||||
use ansi_term::Colour::Red;
|
|
||||||
use lscolors::{LsColors, Style};
|
use lscolors::{LsColors, Style};
|
||||||
|
use nu_ansi_term::Color::Red;
|
||||||
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ fn get_pretty_name(
|
|||||||
.ls_colors
|
.ls_colors
|
||||||
.style_for_path_with_metadata(&node.name, meta_result.as_ref().ok());
|
.style_for_path_with_metadata(&node.name, meta_result.as_ref().ok());
|
||||||
let ansi_style = directory_color
|
let ansi_style = directory_color
|
||||||
.map(Style::to_ansi_term_style)
|
.map(Style::to_nu_ansi_term_style)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let out = ansi_style.paint(name_and_padding);
|
let out = ansi_style.paint(name_and_padding);
|
||||||
format!("{out}")
|
format!("{out}")
|
||||||
@@ -439,6 +439,9 @@ pub fn get_number_format(output_str: &str) -> Option<(u64, char)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn human_readable_number(size: u64, output_str: &str) -> String {
|
pub fn human_readable_number(size: u64, output_str: &str) -> String {
|
||||||
|
if output_str == "count" {
|
||||||
|
return size.to_string();
|
||||||
|
};
|
||||||
match get_number_format(output_str) {
|
match get_number_format(output_str) {
|
||||||
Some((x, u)) => {
|
Some((x, u)) => {
|
||||||
format!("{}{}", (size / x), u)
|
format!("{}{}", (size / x), u)
|
||||||
@@ -539,6 +542,13 @@ mod tests {
|
|||||||
assert_eq!(s, "short 3 4.0K 100%");
|
assert_eq!(s, "short 3 4.0K 100%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_machine_readable_filecount() {
|
||||||
|
assert_eq!(human_readable_number(1, "count"), "1");
|
||||||
|
assert_eq!(human_readable_number(1000, "count"), "1000");
|
||||||
|
assert_eq!(human_readable_number(1024, "count"), "1024");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_human_readable_number() {
|
fn test_human_readable_number() {
|
||||||
assert_eq!(human_readable_number(1, ""), "1B");
|
assert_eq!(human_readable_number(1, ""), "1B");
|
||||||
|
|||||||
+10
-6
@@ -29,7 +29,7 @@ use std::panic;
|
|||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::System;
|
||||||
use utils::canonicalize_absolute_path;
|
use utils::canonicalize_absolute_path;
|
||||||
|
|
||||||
use self::display::draw_it;
|
use self::display::draw_it;
|
||||||
@@ -69,7 +69,7 @@ fn should_init_color(no_color: bool, force_color: bool) -> bool {
|
|||||||
{
|
{
|
||||||
// Required for windows 10
|
// Required for windows 10
|
||||||
// Fails to resolve for windows 8 so disable color
|
// Fails to resolve for windows 8 so disable color
|
||||||
match ansi_term::enable_ansi_support() {
|
match nu_ansi_term::enable_ansi_support() {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
eprintln!("This version of Windows does not support ANSI colors");
|
eprintln!("This version of Windows does not support ANSI colors");
|
||||||
@@ -319,7 +319,11 @@ fn print_output(
|
|||||||
|
|
||||||
if config.get_output_json(&options) {
|
if config.get_output_json(&options) {
|
||||||
OUTPUT_TYPE.with(|wrapped| {
|
OUTPUT_TYPE.with(|wrapped| {
|
||||||
wrapped.replace(output_format);
|
if by_filecount {
|
||||||
|
wrapped.replace("count".to_string());
|
||||||
|
} else {
|
||||||
|
wrapped.replace(output_format);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
println!("{}", serde_json::to_string(&tree).unwrap());
|
println!("{}", serde_json::to_string(&tree).unwrap());
|
||||||
} else {
|
} else {
|
||||||
@@ -436,10 +440,10 @@ fn init_rayon(stack: &Option<usize>, threads: &Option<usize>) -> rayon::ThreadPo
|
|||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let large_stack = usize::pow(1024, 3);
|
let large_stack = usize::pow(1024, 3);
|
||||||
let mut s = System::new();
|
let mut sys = System::new_all();
|
||||||
s.refresh_memory();
|
sys.refresh_memory();
|
||||||
// Larger stack size if possible to handle cases with lots of nested directories
|
// Larger stack size if possible to handle cases with lots of nested directories
|
||||||
let available = s.available_memory();
|
let available = sys.available_memory();
|
||||||
if available > (large_stack * threads.unwrap_or(1)).try_into().unwrap() {
|
if available > (large_stack * threads.unwrap_or(1)).try_into().unwrap() {
|
||||||
Some(large_stack)
|
Some(large_stack)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::Command;
|
use assert_cmd::{Command, cargo_bin_cmd};
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::process::Output;
|
use std::process::Output;
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
@@ -61,9 +61,11 @@ fn initialize() {
|
|||||||
|
|
||||||
fn run_cmd<T: AsRef<OsStr>>(command_args: &[T]) -> Output {
|
fn run_cmd<T: AsRef<OsStr>>(command_args: &[T]) -> Output {
|
||||||
initialize();
|
initialize();
|
||||||
let mut to_run = &mut Command::cargo_bin("dust").unwrap();
|
let mut to_run = cargo_bin_cmd!("dust");
|
||||||
|
// Hide progress bar
|
||||||
|
to_run.arg("-P");
|
||||||
for p in command_args {
|
for p in command_args {
|
||||||
to_run = to_run.arg(p);
|
to_run.arg(p);
|
||||||
}
|
}
|
||||||
to_run.unwrap()
|
to_run.unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-10
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::Command;
|
use assert_cmd::cargo_bin_cmd;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
@@ -9,17 +9,16 @@ use std::str;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
fn build_command<T: AsRef<OsStr>>(command_args: Vec<T>) -> String {
|
fn build_command<T: AsRef<OsStr>>(command_args: Vec<T>) -> String {
|
||||||
let mut cmd = &mut Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
|
|
||||||
// Hide progress bar
|
// Hide progress bar
|
||||||
cmd = cmd.arg("-P");
|
cmd.arg("-P");
|
||||||
|
|
||||||
for p in command_args {
|
for p in command_args {
|
||||||
cmd = cmd.arg(p);
|
cmd.arg(p);
|
||||||
}
|
}
|
||||||
let finished = &cmd.unwrap();
|
let finished = &cmd.unwrap();
|
||||||
let stderr = str::from_utf8(&finished.stderr).unwrap();
|
assert_eq!(str::from_utf8(&finished.stderr).unwrap(), "");
|
||||||
assert_eq!(stderr, "");
|
|
||||||
|
|
||||||
str::from_utf8(&finished.stdout).unwrap().into()
|
str::from_utf8(&finished.stdout).unwrap().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ pub fn test_files0_from_flag_file() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_files_from_flag_stdin() {
|
pub fn test_files_from_flag_stdin() {
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
cmd.arg("-P").arg("--files-from").arg("-");
|
cmd.arg("-P").arg("--files-from").arg("-");
|
||||||
let input = b"tests/test_dir_files_from/a_file\ntests/test_dir_files_from/hello_file\n";
|
let input = b"tests/test_dir_files_from/a_file\ntests/test_dir_files_from/hello_file\n";
|
||||||
cmd.write_stdin(input.as_ref());
|
cmd.write_stdin(input.as_ref());
|
||||||
@@ -140,7 +139,7 @@ pub fn test_files_from_flag_stdin() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_files0_from_flag_stdin() {
|
pub fn test_files0_from_flag_stdin() {
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
cmd.arg("-P").arg("--files0-from").arg("-");
|
cmd.arg("-P").arg("--files0-from").arg("-");
|
||||||
let input = b"tests/test_dir_files_from/a_file\0tests/test_dir_files_from/hello_file\0";
|
let input = b"tests/test_dir_files_from/a_file\0tests/test_dir_files_from/hello_file\0";
|
||||||
cmd.write_stdin(input.as_ref());
|
cmd.write_stdin(input.as_ref());
|
||||||
@@ -154,7 +153,7 @@ pub fn test_files0_from_flag_stdin() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_with_bad_param() {
|
pub fn test_with_bad_param() {
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
cmd.arg("-P").arg("bad_place");
|
cmd.arg("-P").arg("bad_place");
|
||||||
let output_error = cmd.unwrap_err();
|
let output_error = cmd.unwrap_err();
|
||||||
let result = output_error.as_output().unwrap();
|
let result = output_error.as_output().unwrap();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use assert_cmd::Command;
|
use assert_cmd::{Command, cargo_bin_cmd};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -44,7 +44,7 @@ pub fn test_soft_sym_link() {
|
|||||||
let b = format!(" ┌── {}", file_path_s);
|
let b = format!(" ┌── {}", file_path_s);
|
||||||
let a = format!("─┴ {}", dir_s);
|
let a = format!("─┴ {}", dir_s);
|
||||||
|
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
// Mac test runners create long filenames in tmp directories
|
// Mac test runners create long filenames in tmp directories
|
||||||
let output = cmd
|
let output = cmd
|
||||||
.args(["-p", "-c", "-s", "-w", "999", dir_s])
|
.args(["-p", "-c", "-s", "-w", "999", dir_s])
|
||||||
@@ -72,7 +72,7 @@ pub fn test_hard_sym_link() {
|
|||||||
let file_output = format!(" ┌── {}", file_path_s);
|
let file_output = format!(" ┌── {}", file_path_s);
|
||||||
let dirs_output = format!("─┴ {}", dir_s);
|
let dirs_output = format!("─┴ {}", dir_s);
|
||||||
|
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
// Mac test runners create long filenames in tmp directories
|
// Mac test runners create long filenames in tmp directories
|
||||||
let output = cmd.args(["-p", "-c", "-w", "999", dir_s]).unwrap().stdout;
|
let output = cmd.args(["-p", "-c", "-w", "999", dir_s]).unwrap().stdout;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ pub fn test_hard_sym_link_no_dup_multi_arg() {
|
|||||||
let link_name = dir_link.path().join("the_link");
|
let link_name = dir_link.path().join("the_link");
|
||||||
let link_name_s = link_it(link_name, file_path_s, false);
|
let link_name_s = link_it(link_name, file_path_s, false);
|
||||||
|
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
|
|
||||||
// Mac test runners create long filenames in tmp directories
|
// Mac test runners create long filenames in tmp directories
|
||||||
let output = cmd
|
let output = cmd
|
||||||
@@ -123,7 +123,7 @@ pub fn test_recursive_sym_link() {
|
|||||||
let a = format!("─┬ {}", dir_s);
|
let a = format!("─┬ {}", dir_s);
|
||||||
let b = format!(" └── {}", link_name_s);
|
let b = format!(" └── {}", link_name_s);
|
||||||
|
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = cargo_bin_cmd!("dust");
|
||||||
let output = cmd
|
let output = cmd
|
||||||
.arg("-p")
|
.arg("-p")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
|
|||||||
Reference in New Issue
Block a user