mirror of
https://github.com/uutils/diffutils.git
synced 2026-06-29 07:08:33 -04:00
Compare commits
94 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c38fe5f2e5 | |||
| 44565de705 | |||
| 8c8c1db5c6 | |||
| 3e02493701 | |||
| c6e8b46d21 | |||
| 125fc298c5 | |||
| 16673cf466 | |||
| f66ad85757 | |||
| de9bf94d01 | |||
| 940a0e00b6 | |||
| 7ddc6c6c4b | |||
| 8997ac06b8 | |||
| df90e37566 | |||
| f25cad8497 | |||
| a09dcac41d | |||
| 98bf765a98 | |||
| 1e1e968027 | |||
| 4eee9cefa0 | |||
| 67589b9331 | |||
| 83f6d2db7c | |||
| b193ea0c43 | |||
| 5f2ba7a84c | |||
| 15473edcd7 | |||
| 30b6bd2523 | |||
| 590a4b405e | |||
| 418596138e | |||
| eadc8c3dc5 | |||
| 2806ec2029 | |||
| dbd60416e6 | |||
| 392b8fa07b | |||
| 44645e5428 | |||
| 644a794067 | |||
| 19b79efd76 | |||
| 3380bab935 | |||
| a0a05eeba9 | |||
| 611e380266 | |||
| af0dc993b8 | |||
| a680c4f467 | |||
| 0b604f67aa | |||
| cc67cbcc59 | |||
| a95ca0062f | |||
| b59d9be943 | |||
| 3654b82a6d | |||
| 7df02399ba | |||
| 03fe614087 | |||
| 8261d790f4 | |||
| 168dae3aee | |||
| c7d4140fa3 | |||
| dee3bc1d66 | |||
| fce0881e27 | |||
| 45b3072534 | |||
| a3e57c950e | |||
| 1ef6923b7d | |||
| dff98a2969 | |||
| 8105420bb4 | |||
| 5b791e8bf6 | |||
| b31df0b5e8 | |||
| c02273c827 | |||
| 199c7f169c | |||
| 978390c14d | |||
| 87ccc8e4c2 | |||
| 9bc53486df | |||
| 0d7e4d82ae | |||
| 360bff50ed | |||
| 26ee98dfaa | |||
| 009d64acd2 | |||
| b53d4f427c | |||
| 8448fd8068 | |||
| d573c3ae1d | |||
| ca1c4c3618 | |||
| ba1cac3c20 | |||
| 949cccebd4 | |||
| bbdfa1b765 | |||
| 2f1a89173a | |||
| f9553984f4 | |||
| 59920040f6 | |||
| 44c195c0b2 | |||
| fdc69921e6 | |||
| 4ff2d6b182 | |||
| 39e092488b | |||
| dcd3dfd6e0 | |||
| 90bed40046 | |||
| 1575aec22c | |||
| 4f2f869021 | |||
| 3101aa1aff | |||
| 14b062251f | |||
| 0e11811ce1 | |||
| 3de1930bbe | |||
| 889e7bb7cc | |||
| 1910cbfe58 | |||
| c70cc1921c | |||
| 933230e103 | |||
| a316262603 | |||
| 0bf04b4395 |
@@ -30,7 +30,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: install GNU patch on MacOS
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install gpatch
|
||||
run: |
|
||||
brew install gpatch
|
||||
echo "/opt/homebrew/opt/gpatch/libexec/gnubin" >> "$GITHUB_PATH"
|
||||
- name: set up PATH on Windows
|
||||
# Needed to use GNU's patch.exe instead of Strawberry Perl patch
|
||||
if: runner.os == 'Windows'
|
||||
@@ -102,8 +104,6 @@ jobs:
|
||||
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
|
||||
outputs TOOLCHAIN
|
||||
# target-specific options
|
||||
# * CARGO_FEATURES_OPTION
|
||||
CARGO_FEATURES_OPTION='--all -- --check' ; ## default to '--all-features' for code coverage
|
||||
# * CODECOV_FLAGS
|
||||
CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
|
||||
outputs CODECOV_FLAGS
|
||||
@@ -113,13 +113,15 @@ jobs:
|
||||
- run: rustup component add llvm-tools-preview
|
||||
- name: install GNU patch on MacOS
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install gpatch
|
||||
run: |
|
||||
brew install gpatch
|
||||
echo "/opt/homebrew/opt/gpatch/libexec/gnubin" >> "$GITHUB_PATH"
|
||||
- name: set up PATH on Windows
|
||||
# Needed to use GNU's patch.exe instead of Strawberry Perl patch
|
||||
if: runner.os == 'Windows'
|
||||
run: echo "C:\Program Files\Git\usr\bin" >> $env:GITHUB_PATH
|
||||
- name: Test
|
||||
run: cargo test ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-fail-fast
|
||||
run: cargo test --all-features --no-fail-fast
|
||||
env:
|
||||
CARGO_INCREMENTAL: "0"
|
||||
RUSTC_WRAPPER: ""
|
||||
@@ -158,10 +160,10 @@ jobs:
|
||||
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --binary-path "${COVERAGE_REPORT_DIR}" --branch
|
||||
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
|
||||
- name: Upload coverage results (to Codecov.io)
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ${{ steps.coverage.outputs.report }}
|
||||
files: ${{ steps.coverage.outputs.report }}
|
||||
## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
|
||||
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
|
||||
name: codecov-umbrella
|
||||
|
||||
@@ -46,6 +46,7 @@ jobs:
|
||||
- { name: fuzz_ed, should_pass: true }
|
||||
- { name: fuzz_normal, should_pass: true }
|
||||
- { name: fuzz_patch, should_pass: true }
|
||||
- { name: fuzz_side, should_pass: true }
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@nightly
|
||||
@@ -56,7 +57,7 @@ jobs:
|
||||
shared-key: "cargo-fuzz-cache-key"
|
||||
cache-directories: "fuzz/target"
|
||||
- name: Restore Cached Corpus
|
||||
uses: actions/cache/restore@v4
|
||||
uses: actions/cache/restore@v5
|
||||
with:
|
||||
key: corpus-cache-${{ matrix.test-target.name }}
|
||||
path: |
|
||||
@@ -67,7 +68,7 @@ jobs:
|
||||
run: |
|
||||
cargo +nightly fuzz run ${{ matrix.test-target.name }} -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0
|
||||
- name: Save Corpus Cache
|
||||
uses: actions/cache/save@v4
|
||||
uses: actions/cache/save@v5
|
||||
with:
|
||||
key: corpus-cache-${{ matrix.test-target.name }}
|
||||
path: |
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# This file was autogenerated by dist: https://axodotdev.github.io/cargo-dist
|
||||
#
|
||||
# Copyright 2022-2024, axodotdev
|
||||
# SPDX-License-Identifier: MIT or Apache-2.0
|
||||
#
|
||||
# CI that:
|
||||
#
|
||||
# * checks for a Git Tag that looks like a release
|
||||
# * builds artifacts with cargo-dist (archives, installers, hashes)
|
||||
# * builds artifacts with dist (archives, installers, hashes)
|
||||
# * uploads those artifacts to temporary workflow zip
|
||||
# * on success, uploads the artifacts to a GitHub Release
|
||||
#
|
||||
@@ -12,9 +14,8 @@
|
||||
# title/body based on your changelogs.
|
||||
|
||||
name: Release
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
"contents": "write"
|
||||
|
||||
# This task will run whenever you push a git tag that looks like a version
|
||||
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
|
||||
@@ -23,10 +24,10 @@ permissions:
|
||||
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
|
||||
#
|
||||
# If PACKAGE_NAME is specified, then the announcement will be for that
|
||||
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
|
||||
# package (erroring out if it doesn't have the given version or isn't dist-able).
|
||||
#
|
||||
# If PACKAGE_NAME isn't specified, then the announcement will be for all
|
||||
# (cargo-dist-able) packages in the workspace with that version (this mode is
|
||||
# (dist-able) packages in the workspace with that version (this mode is
|
||||
# intended for workspaces with only one dist-able package, or with all dist-able
|
||||
# packages versioned/released in lockstep).
|
||||
#
|
||||
@@ -38,15 +39,15 @@ permissions:
|
||||
# If there's a prerelease-style suffix to the version, then the release(s)
|
||||
# will be marked as a prerelease.
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
tags:
|
||||
- '**[0-9]+.[0-9]+.[0-9]+*'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
|
||||
# Run 'dist plan' (or host) to determine what tasks we need to do
|
||||
plan:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: "ubuntu-22.04"
|
||||
outputs:
|
||||
val: ${{ steps.plan.outputs.manifest }}
|
||||
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
|
||||
@@ -57,12 +58,18 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Install cargo-dist
|
||||
- name: Install dist
|
||||
# we specify bash to get pipefail; it guards against the `curl` command
|
||||
# failing. otherwise `sh` won't catch that `curl` returned non-0
|
||||
shell: bash
|
||||
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh"
|
||||
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.3/cargo-dist-installer.sh | sh"
|
||||
- name: Cache dist
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/dist
|
||||
# sure would be cool if github gave us proper conditionals...
|
||||
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
|
||||
# functionality based on whether this is a pull_request, and whether it's from a fork.
|
||||
@@ -70,8 +77,8 @@ jobs:
|
||||
# but also really annoying to build CI around when it needs secrets to work right.)
|
||||
- id: plan
|
||||
run: |
|
||||
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
|
||||
echo "cargo dist ran successfully"
|
||||
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
cat plan-dist-manifest.json
|
||||
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||
- name: "Upload dist-manifest.json"
|
||||
@@ -89,18 +96,19 @@ jobs:
|
||||
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
# Target platforms/runners are computed by cargo-dist in create-release.
|
||||
# Target platforms/runners are computed by dist in create-release.
|
||||
# Each member of the matrix has the following arguments:
|
||||
#
|
||||
# - runner: the github runner
|
||||
# - dist-args: cli flags to pass to cargo dist
|
||||
# - install-dist: expression to run to install cargo-dist on the runner
|
||||
# - dist-args: cli flags to pass to dist
|
||||
# - install-dist: expression to run to install dist on the runner
|
||||
#
|
||||
# Typically there will be:
|
||||
# - 1 "global" task that builds universal installers
|
||||
# - N "local" tasks that build each platform's binaries and platform-specific installers
|
||||
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
container: ${{ matrix.container && matrix.container.image || null }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
|
||||
@@ -110,12 +118,17 @@ jobs:
|
||||
git config --global core.longpaths true
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- uses: swatinem/rust-cache@v2
|
||||
with:
|
||||
key: ${{ join(matrix.targets, '-') }}
|
||||
- name: Install cargo-dist
|
||||
run: ${{ matrix.install_dist }}
|
||||
- name: Install Rust non-interactively if not already installed
|
||||
if: ${{ matrix.container }}
|
||||
run: |
|
||||
if ! command -v cargo > /dev/null 2>&1; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
fi
|
||||
- name: Install dist
|
||||
run: ${{ matrix.install_dist.run }}
|
||||
# Get the dist-manifest
|
||||
- name: Fetch local artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -129,8 +142,8 @@ jobs:
|
||||
- name: Build artifacts
|
||||
run: |
|
||||
# Actually do builds and make zips and whatnot
|
||||
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
|
||||
echo "cargo dist ran successfully"
|
||||
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
- id: cargo-dist
|
||||
name: Post-build
|
||||
# We force bash here just because github makes it really hard to get values up
|
||||
@@ -140,7 +153,7 @@ jobs:
|
||||
run: |
|
||||
# Parse out what we just built and upload it to scratch storage
|
||||
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
|
||||
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||
@@ -157,17 +170,21 @@ jobs:
|
||||
needs:
|
||||
- plan
|
||||
- build-local-artifacts
|
||||
runs-on: "ubuntu-20.04"
|
||||
runs-on: "ubuntu-22.04"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Install cargo-dist
|
||||
shell: bash
|
||||
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh"
|
||||
- name: Install cached dist
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/
|
||||
- run: chmod +x ~/.cargo/bin/dist
|
||||
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
|
||||
- name: Fetch local artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -178,8 +195,8 @@ jobs:
|
||||
- id: cargo-dist
|
||||
shell: bash
|
||||
run: |
|
||||
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
|
||||
echo "cargo dist ran successfully"
|
||||
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
|
||||
# Parse out what we just built and upload it to scratch storage
|
||||
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||
@@ -200,19 +217,24 @@ jobs:
|
||||
- plan
|
||||
- build-local-artifacts
|
||||
- build-global-artifacts
|
||||
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
|
||||
if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
|
||||
# Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine)
|
||||
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
runs-on: "ubuntu-20.04"
|
||||
runs-on: "ubuntu-22.04"
|
||||
outputs:
|
||||
val: ${{ steps.host.outputs.manifest }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Install cargo-dist
|
||||
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh"
|
||||
- name: Install cached dist
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/
|
||||
- run: chmod +x ~/.cargo/bin/dist
|
||||
# Fetch artifacts from scratch-storage
|
||||
- name: Fetch artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -220,11 +242,10 @@ jobs:
|
||||
pattern: artifacts-*
|
||||
path: target/distrib/
|
||||
merge-multiple: true
|
||||
# This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
|
||||
- id: host
|
||||
shell: bash
|
||||
run: |
|
||||
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
|
||||
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
|
||||
echo "artifacts uploaded and released successfully"
|
||||
cat dist-manifest.json
|
||||
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||
@@ -234,23 +255,7 @@ jobs:
|
||||
# Overwrite the previous copy
|
||||
name: artifacts-dist-manifest
|
||||
path: dist-manifest.json
|
||||
|
||||
# Create a GitHub Release while uploading all files to it
|
||||
announce:
|
||||
needs:
|
||||
- plan
|
||||
- host
|
||||
# use "always() && ..." to allow us to wait for all publish jobs while
|
||||
# still allowing individual publish jobs to skip themselves (for prereleases).
|
||||
# "host" however must run to completion, no skipping allowed!
|
||||
if: ${{ always() && needs.host.result == 'success' }}
|
||||
runs-on: "ubuntu-20.04"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
# Create a GitHub Release while uploading all files to it
|
||||
- name: "Download GitHub Artifacts"
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
@@ -262,10 +267,30 @@ jobs:
|
||||
# Remove the granular manifests
|
||||
rm -f artifacts/*-dist-manifest.json
|
||||
- name: Create GitHub Release
|
||||
uses: ncipollo/release-action@v1
|
||||
env:
|
||||
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
|
||||
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
|
||||
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
|
||||
RELEASE_COMMIT: "${{ github.sha }}"
|
||||
run: |
|
||||
# Write and read notes from a file to avoid quoting breaking things
|
||||
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
|
||||
|
||||
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
|
||||
|
||||
announce:
|
||||
needs:
|
||||
- plan
|
||||
- host
|
||||
# use "always() && ..." to allow us to wait for all publish jobs while
|
||||
# still allowing individual publish jobs to skip themselves (for prereleases).
|
||||
# "host" however must run to completion, no skipping allowed!
|
||||
if: ${{ always() && needs.host.result == 'success' }}
|
||||
runs-on: "ubuntu-22.04"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
tag: ${{ needs.plan.outputs.tag }}
|
||||
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
|
||||
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
|
||||
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
|
||||
artifacts: "artifacts/*"
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
|
||||
Generated
+66
-53
@@ -1,6 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
@@ -11,12 +11,6 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
@@ -34,13 +28,12 @@ checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
|
||||
|
||||
[[package]]
|
||||
name = "assert_cmd"
|
||||
version = "2.0.16"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d"
|
||||
checksum = "bcbb6924530aa9e0432442af08bbcafdad182db80d2e560da42a6d442535bf85"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"bstr",
|
||||
"doc-comment",
|
||||
"libc",
|
||||
"predicates",
|
||||
"predicates-core",
|
||||
@@ -91,16 +84,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.38"
|
||||
version = "0.4.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
|
||||
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-targets",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -123,7 +115,7 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
|
||||
|
||||
[[package]]
|
||||
name = "diffutils"
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"assert_cmd",
|
||||
"chrono",
|
||||
@@ -137,20 +129,14 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "doc-comment"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.8"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -161,13 +147,25 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
|
||||
|
||||
[[package]]
|
||||
name = "float-cmp"
|
||||
version = "0.9.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
|
||||
checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.60"
|
||||
@@ -193,9 +191,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
@@ -208,15 +206,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.159"
|
||||
version = "0.2.178"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
|
||||
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.14"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
@@ -253,9 +251,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "predicates"
|
||||
version = "3.1.2"
|
||||
version = "3.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97"
|
||||
checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"difflib",
|
||||
@@ -311,9 +309,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.0"
|
||||
version = "1.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
|
||||
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -323,9 +321,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.8"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
|
||||
checksum = "722166aa0d7438abbaa4d5cc2c649dac844e8c56d82fb3d33e9c34b5cd268fc6"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -340,15 +338,15 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.37"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
|
||||
checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -393,15 +391,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.13.0"
|
||||
version = "3.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
|
||||
checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -418,9 +416,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.0"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
|
||||
|
||||
[[package]]
|
||||
name = "wait-timeout"
|
||||
@@ -431,6 +429,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.13.3+wasi-0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
|
||||
dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.92"
|
||||
@@ -526,13 +533,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
name = "windows-link"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
@@ -607,6 +611,15 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yansi"
|
||||
version = "1.0.1"
|
||||
|
||||
+10
-15
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "diffutils"
|
||||
version = "0.4.2"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
description = "A CLI app for generating diff files"
|
||||
license = "MIT OR Apache-2.0"
|
||||
@@ -28,20 +28,15 @@ assert_cmd = "2.0.14"
|
||||
predicates = "3.1.0"
|
||||
tempfile = "3.10.1"
|
||||
|
||||
# The profile that 'cargo dist' will build with
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
codegen-units = 1
|
||||
|
||||
[profile.release-fast]
|
||||
inherits = "release"
|
||||
panic = "abort"
|
||||
|
||||
# The profile that 'dist' will build with
|
||||
[profile.dist]
|
||||
inherits = "release"
|
||||
lto = "thin"
|
||||
|
||||
# Config for 'cargo dist'
|
||||
[workspace.metadata.dist]
|
||||
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
|
||||
cargo-dist-version = "0.13.3"
|
||||
# CI backends to support
|
||||
ci = ["github"]
|
||||
# The installers to generate for each app
|
||||
installers = []
|
||||
# Target platforms to build apps for (Rust target-triple syntax)
|
||||
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
|
||||
# Publish jobs to run in CI
|
||||
pr-run-mode = "plan"
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
[workspace]
|
||||
members = ["cargo:."]
|
||||
|
||||
# Config for 'dist'
|
||||
[dist]
|
||||
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
|
||||
cargo-dist-version = "0.30.3"
|
||||
# CI backends to support
|
||||
ci = "github"
|
||||
# The installers to generate for each app
|
||||
installers = []
|
||||
# Target platforms to build apps for (Rust target-triple syntax)
|
||||
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
|
||||
Generated
+447
@@ -0,0 +1,447 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a0aeaff4ff1a90589618835a598e545176939b97874f7abc7851caa0618f203"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "diff"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
|
||||
|
||||
[[package]]
|
||||
name = "diffutils"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"diff",
|
||||
"itoa",
|
||||
"regex",
|
||||
"same-file",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasip2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.178"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
||||
|
||||
[[package]]
|
||||
name = "libfuzzer-sys"
|
||||
version = "0.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5037190e1f70cbeef565bd267599242926f724d3b8a9f510fd7e0b540cfa4404"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.112"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21f182278bf2d2bcb3c88b1b08a37df029d71ce3d3ae26168e3c653b213b99d4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
|
||||
|
||||
[[package]]
|
||||
name = "unified-diff-fuzz"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"diffutils",
|
||||
"libfuzzer-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.1+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
|
||||
dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.62.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-link",
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.60.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.59.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
||||
+5
-1
@@ -47,4 +47,8 @@ path = "fuzz_targets/fuzz_ed.rs"
|
||||
test = false
|
||||
doc = false
|
||||
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_side"
|
||||
path = "fuzz_targets/fuzz_side.rs"
|
||||
test = false
|
||||
doc = false
|
||||
@@ -0,0 +1,42 @@
|
||||
#![no_main]
|
||||
#[macro_use]
|
||||
extern crate libfuzzer_sys;
|
||||
|
||||
use diffutilslib::side_diff;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use diffutilslib::params::Params;
|
||||
|
||||
fuzz_target!(|x: (Vec<u8>, Vec<u8>, /* usize, usize */ bool)| {
|
||||
let (original, new, /* width, tabsize, */ expand) = x;
|
||||
|
||||
// if width == 0 || tabsize == 0 {
|
||||
// return;
|
||||
// }
|
||||
|
||||
let params = Params {
|
||||
// width,
|
||||
// tabsize,
|
||||
expand_tabs: expand,
|
||||
..Default::default()
|
||||
};
|
||||
let mut output_buf = vec![];
|
||||
side_diff::diff(&original, &new, &mut output_buf, ¶ms);
|
||||
File::create("target/fuzz.file.original")
|
||||
.unwrap()
|
||||
.write_all(&original)
|
||||
.unwrap();
|
||||
File::create("target/fuzz.file.new")
|
||||
.unwrap()
|
||||
.write_all(&new)
|
||||
.unwrap();
|
||||
File::create("target/fuzz.file")
|
||||
.unwrap()
|
||||
.write_all(&original)
|
||||
.unwrap();
|
||||
File::create("target/fuzz.diff")
|
||||
.unwrap()
|
||||
.write_all(&output_buf)
|
||||
.unwrap();
|
||||
});
|
||||
+132
-132
@@ -9,7 +9,7 @@ use std::ffi::OsString;
|
||||
use std::io::{BufRead, BufReader, BufWriter, Read, Write};
|
||||
use std::iter::Peekable;
|
||||
use std::process::ExitCode;
|
||||
use std::{fs, io};
|
||||
use std::{cmp, fs, io};
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
use std::os::fd::{AsRawFd, FromRawFd};
|
||||
@@ -35,7 +35,7 @@ pub struct Params {
|
||||
|
||||
#[inline]
|
||||
fn usage_string(executable: &str) -> String {
|
||||
format!("Usage: {} <from> <to>", executable)
|
||||
format!("Usage: {executable} <from> <to>")
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
@@ -75,8 +75,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
Err(e) if *e.kind() == std::num::IntErrorKind::PosOverflow => usize::MAX,
|
||||
Err(_) => {
|
||||
return Err(format!(
|
||||
"{}: invalid --ignore-initial value '{}'",
|
||||
executable_str, skip_desc
|
||||
"{executable_str}: invalid --ignore-initial value '{skip_desc}'"
|
||||
))
|
||||
}
|
||||
};
|
||||
@@ -91,20 +90,29 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
"M" => 1_048_576,
|
||||
"GB" => 1_000_000_000,
|
||||
"G" => 1_073_741_824,
|
||||
"TB" => 1_000_000_000_000,
|
||||
"T" => 1_099_511_627_776,
|
||||
"PB" => 1_000_000_000_000_000,
|
||||
"P" => 1_125_899_906_842_624,
|
||||
"EB" => 1_000_000_000_000_000_000,
|
||||
"E" => 1_152_921_504_606_846_976,
|
||||
// This only generates a warning when compiling for target_pointer_width < 64
|
||||
#[allow(unused_variables)]
|
||||
suffix @ ("TB" | "T" | "PB" | "P" | "EB" | "E") => {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
match suffix {
|
||||
"TB" => 1_000_000_000_000,
|
||||
"T" => 1_099_511_627_776,
|
||||
"PB" => 1_000_000_000_000_000,
|
||||
"P" => 1_125_899_906_842_624,
|
||||
"EB" => 1_000_000_000_000_000_000,
|
||||
"E" => 1_152_921_504_606_846_976,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
#[cfg(not(target_pointer_width = "64"))]
|
||||
usize::MAX
|
||||
}
|
||||
"ZB" => usize::MAX, // 1_000_000_000_000_000_000_000,
|
||||
"Z" => usize::MAX, // 1_180_591_620_717_411_303_424,
|
||||
"YB" => usize::MAX, // 1_000_000_000_000_000_000_000_000,
|
||||
"Y" => usize::MAX, // 1_208_925_819_614_629_174_706_176,
|
||||
_ => {
|
||||
return Err(format!(
|
||||
"{}: invalid --ignore-initial value '{}'",
|
||||
executable_str, skip_desc
|
||||
"{executable_str}: invalid --ignore-initial value '{skip_desc}'"
|
||||
));
|
||||
}
|
||||
};
|
||||
@@ -170,8 +178,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
Err(e) if *e.kind() == std::num::IntErrorKind::PosOverflow => usize::MAX,
|
||||
Err(_) => {
|
||||
return Err(format!(
|
||||
"{}: invalid --bytes value '{}'",
|
||||
executable_str, max_bytes
|
||||
"{executable_str}: invalid --bytes value '{max_bytes}'"
|
||||
))
|
||||
}
|
||||
};
|
||||
@@ -210,7 +217,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
std::process::exit(0);
|
||||
}
|
||||
if param_str.starts_with('-') {
|
||||
return Err(format!("Unknown option: {:?}", param));
|
||||
return Err(format!("Unknown option: {param:?}"));
|
||||
}
|
||||
if from.is_none() {
|
||||
from = Some(param);
|
||||
@@ -236,8 +243,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
|
||||
if params.quiet && params.verbose {
|
||||
return Err(format!(
|
||||
"{}: options -l and -s are incompatible",
|
||||
executable_str
|
||||
"{executable_str}: options -l and -s are incompatible"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -320,10 +326,35 @@ pub fn cmp(params: &Params) -> Result<Cmp, String> {
|
||||
let mut from = prepare_reader(¶ms.from, ¶ms.skip_a, params)?;
|
||||
let mut to = prepare_reader(¶ms.to, ¶ms.skip_b, params)?;
|
||||
|
||||
let mut offset_width = params.max_bytes.unwrap_or(usize::MAX);
|
||||
|
||||
if let (Ok(a_meta), Ok(b_meta)) = (fs::metadata(¶ms.from), fs::metadata(¶ms.to)) {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let (a_size, b_size) = (a_meta.size(), b_meta.size());
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
let (a_size, b_size) = (a_meta.file_size(), b_meta.file_size());
|
||||
|
||||
// If the files have different sizes, we already know they are not identical. If we have not
|
||||
// been asked to show even the first difference, we can quit early.
|
||||
if params.quiet && a_size != b_size {
|
||||
return Ok(Cmp::Different);
|
||||
}
|
||||
|
||||
let smaller = cmp::min(a_size, b_size) as usize;
|
||||
offset_width = cmp::min(smaller, offset_width);
|
||||
}
|
||||
|
||||
let offset_width = 1 + offset_width.checked_ilog10().unwrap_or(1) as usize;
|
||||
|
||||
// Capacity calc: at_byte width + 2 x 3-byte octal numbers + 2 x 4-byte value + 4 spaces
|
||||
let mut output = Vec::<u8>::with_capacity(offset_width + 3 * 2 + 4 * 2 + 4);
|
||||
|
||||
let mut at_byte = 1;
|
||||
let mut at_line = 1;
|
||||
let mut start_of_line = true;
|
||||
let mut verbose_diffs = vec![];
|
||||
let mut stdout = BufWriter::new(io::stdout().lock());
|
||||
let mut compare = Cmp::Equal;
|
||||
loop {
|
||||
// Fill up our buffers.
|
||||
let from_buf = match from.fill_buf() {
|
||||
@@ -360,10 +391,6 @@ pub fn cmp(params: &Params) -> Result<Cmp, String> {
|
||||
¶ms.to.to_string_lossy()
|
||||
};
|
||||
|
||||
if params.verbose {
|
||||
report_verbose_diffs(verbose_diffs, params)?;
|
||||
}
|
||||
|
||||
report_eof(at_byte, at_line, start_of_line, eof_on, params);
|
||||
return Ok(Cmp::Different);
|
||||
}
|
||||
@@ -395,8 +422,24 @@ pub fn cmp(params: &Params) -> Result<Cmp, String> {
|
||||
// first one runs out.
|
||||
for (&from_byte, &to_byte) in from_buf.iter().zip(to_buf.iter()) {
|
||||
if from_byte != to_byte {
|
||||
compare = Cmp::Different;
|
||||
|
||||
if params.verbose {
|
||||
verbose_diffs.push((at_byte, from_byte, to_byte));
|
||||
format_verbose_difference(
|
||||
from_byte,
|
||||
to_byte,
|
||||
at_byte,
|
||||
offset_width,
|
||||
&mut output,
|
||||
params,
|
||||
)?;
|
||||
stdout.write_all(output.as_slice()).map_err(|e| {
|
||||
format!(
|
||||
"{}: error printing output: {e}",
|
||||
params.executable.to_string_lossy()
|
||||
)
|
||||
})?;
|
||||
output.clear();
|
||||
} else {
|
||||
report_difference(from_byte, to_byte, at_byte, at_line, params);
|
||||
return Ok(Cmp::Different);
|
||||
@@ -422,12 +465,7 @@ pub fn cmp(params: &Params) -> Result<Cmp, String> {
|
||||
to.consume(consumed);
|
||||
}
|
||||
|
||||
if params.verbose && !verbose_diffs.is_empty() {
|
||||
report_verbose_diffs(verbose_diffs, params)?;
|
||||
return Ok(Cmp::Different);
|
||||
}
|
||||
|
||||
Ok(Cmp::Equal)
|
||||
Ok(compare)
|
||||
}
|
||||
|
||||
// Exit codes are documented at
|
||||
@@ -450,21 +488,6 @@ pub fn main(opts: Peekable<ArgsOs>) -> ExitCode {
|
||||
return ExitCode::SUCCESS;
|
||||
}
|
||||
|
||||
// If the files have different sizes, we already know they are not identical. If we have not
|
||||
// been asked to show even the first difference, we can quit early.
|
||||
if params.quiet {
|
||||
if let (Ok(a_meta), Ok(b_meta)) = (fs::metadata(¶ms.from), fs::metadata(¶ms.to)) {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
if a_meta.size() != b_meta.size() {
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
if a_meta.file_size() != b_meta.file_size() {
|
||||
return ExitCode::from(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match cmp(¶ms) {
|
||||
Ok(Cmp::Equal) => ExitCode::SUCCESS,
|
||||
Ok(Cmp::Different) => ExitCode::from(1),
|
||||
@@ -533,99 +556,76 @@ fn format_byte(byte: u8) -> String {
|
||||
// This function has been optimized to not use the Rust fmt system, which
|
||||
// leads to a massive speed up when processing large files: cuts the time
|
||||
// for comparing 2 ~36MB completely different files in half on an M1 Max.
|
||||
fn report_verbose_diffs(diffs: Vec<(usize, u8, u8)>, params: &Params) -> Result<(), String> {
|
||||
#[inline]
|
||||
fn format_verbose_difference(
|
||||
from_byte: u8,
|
||||
to_byte: u8,
|
||||
at_byte: usize,
|
||||
offset_width: usize,
|
||||
output: &mut Vec<u8>,
|
||||
params: &Params,
|
||||
) -> Result<(), String> {
|
||||
assert!(!params.quiet);
|
||||
|
||||
let mut stdout = BufWriter::new(io::stdout().lock());
|
||||
if let Some((offset, _, _)) = diffs.last() {
|
||||
// Obtain the width of the first column from the last byte offset.
|
||||
let width = format!("{}", offset).len();
|
||||
let mut at_byte_buf = itoa::Buffer::new();
|
||||
let mut from_oct = [0u8; 3]; // for octal conversions
|
||||
let mut to_oct = [0u8; 3];
|
||||
|
||||
let mut at_byte_buf = itoa::Buffer::new();
|
||||
let mut from_oct = [0u8; 3]; // for octal conversions
|
||||
let mut to_oct = [0u8; 3];
|
||||
if params.print_bytes {
|
||||
// "{:>width$} {:>3o} {:4} {:>3o} {}",
|
||||
let at_byte_str = at_byte_buf.format(at_byte);
|
||||
let at_byte_padding = offset_width.saturating_sub(at_byte_str.len());
|
||||
|
||||
// Capacity calc: at_byte width + 2 x 3-byte octal numbers + 4-byte value + up to 2 byte value + 4 spaces
|
||||
let mut output = Vec::<u8>::with_capacity(width + 3 * 2 + 4 + 2 + 4);
|
||||
|
||||
if params.print_bytes {
|
||||
for (at_byte, from_byte, to_byte) in diffs {
|
||||
output.clear();
|
||||
|
||||
// "{:>width$} {:>3o} {:4} {:>3o} {}",
|
||||
let at_byte_str = at_byte_buf.format(at_byte);
|
||||
let at_byte_padding = width - at_byte_str.len();
|
||||
|
||||
for _ in 0..at_byte_padding {
|
||||
output.push(b' ')
|
||||
}
|
||||
|
||||
output.extend_from_slice(at_byte_str.as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_octal(from_byte, &mut from_oct).as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
let from_byte_str = format_byte(from_byte);
|
||||
let from_byte_padding = 4 - from_byte_str.len();
|
||||
|
||||
output.extend_from_slice(from_byte_str.as_bytes());
|
||||
|
||||
for _ in 0..from_byte_padding {
|
||||
output.push(b' ')
|
||||
}
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_octal(to_byte, &mut to_oct).as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_byte(to_byte).as_bytes());
|
||||
|
||||
output.push(b'\n');
|
||||
|
||||
stdout.write_all(output.as_slice()).map_err(|e| {
|
||||
format!(
|
||||
"{}: error printing output: {e}",
|
||||
params.executable.to_string_lossy()
|
||||
)
|
||||
})?;
|
||||
}
|
||||
} else {
|
||||
for (at_byte, from_byte, to_byte) in diffs {
|
||||
output.clear();
|
||||
|
||||
// "{:>width$} {:>3o} {:>3o}"
|
||||
let at_byte_str = at_byte_buf.format(at_byte);
|
||||
let at_byte_padding = width - at_byte_str.len();
|
||||
|
||||
for _ in 0..at_byte_padding {
|
||||
output.push(b' ')
|
||||
}
|
||||
|
||||
output.extend_from_slice(at_byte_str.as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_octal(from_byte, &mut from_oct).as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_octal(to_byte, &mut to_oct).as_bytes());
|
||||
|
||||
output.push(b'\n');
|
||||
|
||||
stdout.write_all(output.as_slice()).map_err(|e| {
|
||||
format!(
|
||||
"{}: error printing output: {e}",
|
||||
params.executable.to_string_lossy()
|
||||
)
|
||||
})?;
|
||||
}
|
||||
for _ in 0..at_byte_padding {
|
||||
output.push(b' ')
|
||||
}
|
||||
|
||||
output.extend_from_slice(at_byte_str.as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_octal(from_byte, &mut from_oct).as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
let from_byte_str = format_byte(from_byte);
|
||||
let from_byte_padding = 4 - from_byte_str.len();
|
||||
|
||||
output.extend_from_slice(from_byte_str.as_bytes());
|
||||
|
||||
for _ in 0..from_byte_padding {
|
||||
output.push(b' ')
|
||||
}
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_octal(to_byte, &mut to_oct).as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_byte(to_byte).as_bytes());
|
||||
|
||||
output.push(b'\n');
|
||||
} else {
|
||||
// "{:>width$} {:>3o} {:>3o}"
|
||||
let at_byte_str = at_byte_buf.format(at_byte);
|
||||
let at_byte_padding = offset_width - at_byte_str.len();
|
||||
|
||||
for _ in 0..at_byte_padding {
|
||||
output.push(b' ')
|
||||
}
|
||||
|
||||
output.extend_from_slice(at_byte_str.as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_octal(from_byte, &mut from_oct).as_bytes());
|
||||
|
||||
output.push(b' ');
|
||||
|
||||
output.extend_from_slice(format_octal(to_byte, &mut to_oct).as_bytes());
|
||||
|
||||
output.push(b'\n');
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
+6
-2
@@ -5,11 +5,11 @@
|
||||
|
||||
use crate::params::{parse_params, Format};
|
||||
use crate::utils::report_failure_to_read_input_file;
|
||||
use crate::{context_diff, ed_diff, normal_diff, unified_diff};
|
||||
use crate::{context_diff, ed_diff, normal_diff, side_diff, unified_diff};
|
||||
use std::env::ArgsOs;
|
||||
use std::ffi::OsString;
|
||||
use std::fs;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::io::{self, stdout, Read, Write};
|
||||
use std::iter::Peekable;
|
||||
use std::process::{exit, ExitCode};
|
||||
|
||||
@@ -79,6 +79,10 @@ pub fn main(opts: Peekable<ArgsOs>) -> ExitCode {
|
||||
eprintln!("{error}");
|
||||
exit(2);
|
||||
}),
|
||||
Format::SideBySide => {
|
||||
let mut output = stdout().lock();
|
||||
side_diff::diff(&from_content, &to_content, &mut output, ¶ms)
|
||||
}
|
||||
};
|
||||
if params.brief && !result.is_empty() {
|
||||
println!(
|
||||
|
||||
@@ -4,6 +4,7 @@ pub mod ed_diff;
|
||||
pub mod macros;
|
||||
pub mod normal_diff;
|
||||
pub mod params;
|
||||
pub mod side_diff;
|
||||
pub mod unified_diff;
|
||||
pub mod utils;
|
||||
|
||||
@@ -11,4 +12,5 @@ pub mod utils;
|
||||
pub use context_diff::diff as context_diff;
|
||||
pub use ed_diff::diff as ed_diff;
|
||||
pub use normal_diff::diff as normal_diff;
|
||||
pub use side_diff::diff as side_by_side_diff;
|
||||
pub use unified_diff::diff as unified_diff;
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ mod ed_diff;
|
||||
mod macros;
|
||||
mod normal_diff;
|
||||
mod params;
|
||||
mod side_diff;
|
||||
mod unified_diff;
|
||||
mod utils;
|
||||
|
||||
@@ -72,7 +73,7 @@ fn main() -> ExitCode {
|
||||
Some("diff") => diff::main(args),
|
||||
Some("cmp") => cmp::main(args),
|
||||
Some(name) => {
|
||||
eprintln!("{}: utility not supported", name);
|
||||
eprintln!("{name}: utility not supported");
|
||||
ExitCode::from(2)
|
||||
}
|
||||
None => second_arg_error(exe_name),
|
||||
|
||||
+61
-26
@@ -11,6 +11,7 @@ pub enum Format {
|
||||
Unified,
|
||||
Context,
|
||||
Ed,
|
||||
SideBySide,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
@@ -24,6 +25,7 @@ pub struct Params {
|
||||
pub brief: bool,
|
||||
pub expand_tabs: bool,
|
||||
pub tabsize: usize,
|
||||
pub width: usize,
|
||||
}
|
||||
|
||||
impl Default for Params {
|
||||
@@ -38,6 +40,7 @@ impl Default for Params {
|
||||
brief: false,
|
||||
expand_tabs: false,
|
||||
tabsize: 8,
|
||||
width: 130,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +60,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
let mut format = None;
|
||||
let mut context = None;
|
||||
let tabsize_re = Regex::new(r"^--tabsize=(?<num>\d+)$").unwrap();
|
||||
let width_re = Regex::new(r"--width=(?P<long>\d+)$").unwrap();
|
||||
while let Some(param) = opts.next() {
|
||||
let next_param = opts.peek();
|
||||
if param == "--" {
|
||||
@@ -101,6 +105,34 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
format = Some(Format::Ed);
|
||||
continue;
|
||||
}
|
||||
if param == "-y" || param == "--side-by-side" {
|
||||
if format.is_some() && format != Some(Format::SideBySide) {
|
||||
return Err("Conflicting output style option".to_string());
|
||||
}
|
||||
format = Some(Format::SideBySide);
|
||||
continue;
|
||||
}
|
||||
if width_re.is_match(param.to_string_lossy().as_ref()) {
|
||||
let param = param.into_string().unwrap();
|
||||
let width_str: &str = width_re
|
||||
.captures(param.as_str())
|
||||
.unwrap()
|
||||
.name("long")
|
||||
.unwrap()
|
||||
.as_str();
|
||||
|
||||
params.width = match width_str.parse::<usize>() {
|
||||
Ok(num) => {
|
||||
if num == 0 {
|
||||
return Err("invalid width «0»".to_string());
|
||||
}
|
||||
|
||||
num
|
||||
}
|
||||
Err(_) => return Err(format!("invalid width «{width_str}»")),
|
||||
};
|
||||
continue;
|
||||
}
|
||||
if tabsize_re.is_match(param.to_string_lossy().as_ref()) {
|
||||
// Because param matches the regular expression,
|
||||
// it is safe to assume it is valid UTF-8.
|
||||
@@ -112,9 +144,16 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
.unwrap()
|
||||
.as_str();
|
||||
params.tabsize = match tabsize_str.parse::<usize>() {
|
||||
Ok(num) => num,
|
||||
Ok(num) => {
|
||||
if num == 0 {
|
||||
return Err("invalid tabsize «0»".to_string());
|
||||
}
|
||||
|
||||
num
|
||||
}
|
||||
Err(_) => return Err(format!("invalid tabsize «{tabsize_str}»")),
|
||||
};
|
||||
|
||||
continue;
|
||||
}
|
||||
match match_context_diff_params(¶m, next_param, format) {
|
||||
@@ -156,7 +195,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
if param.to_string_lossy().starts_with('-') {
|
||||
return Err(format!("Unknown option: {:?}", param));
|
||||
return Err(format!("Unknown option: {param:?}"));
|
||||
}
|
||||
if from.is_none() {
|
||||
from = Some(param);
|
||||
@@ -240,17 +279,15 @@ fn match_context_diff_params(
|
||||
context_count = Some(numvalue.as_str().parse::<usize>().unwrap());
|
||||
}
|
||||
}
|
||||
if param == "-C" && next_param.is_some() {
|
||||
match next_param.unwrap().to_string_lossy().parse::<usize>() {
|
||||
Ok(context_size) => {
|
||||
context_count = Some(context_size);
|
||||
next_param_consumed = true;
|
||||
}
|
||||
Err(_) => {
|
||||
return Err(format!(
|
||||
"invalid context length '{}'",
|
||||
next_param.unwrap().to_string_lossy()
|
||||
))
|
||||
if param == "-C" {
|
||||
if let Some(p) = next_param {
|
||||
let size_str = p.to_string_lossy();
|
||||
match size_str.parse::<usize>() {
|
||||
Ok(context_size) => {
|
||||
context_count = Some(context_size);
|
||||
next_param_consumed = true;
|
||||
}
|
||||
Err(_) => return Err(format!("invalid context length '{size_str}'")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,17 +323,15 @@ fn match_unified_diff_params(
|
||||
context_count = Some(numvalue.as_str().parse::<usize>().unwrap());
|
||||
}
|
||||
}
|
||||
if param == "-U" && next_param.is_some() {
|
||||
match next_param.unwrap().to_string_lossy().parse::<usize>() {
|
||||
Ok(context_size) => {
|
||||
context_count = Some(context_size);
|
||||
next_param_consumed = true;
|
||||
}
|
||||
Err(_) => {
|
||||
return Err(format!(
|
||||
"invalid context length '{}'",
|
||||
next_param.unwrap().to_string_lossy()
|
||||
))
|
||||
if param == "-U" {
|
||||
if let Some(p) = next_param {
|
||||
let size_str = p.to_string_lossy();
|
||||
match size_str.parse::<usize>() {
|
||||
Ok(context_size) => {
|
||||
context_count = Some(context_size);
|
||||
next_param_consumed = true;
|
||||
}
|
||||
Err(_) => return Err(format!("invalid context length '{size_str}'")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -704,11 +739,11 @@ mod tests {
|
||||
executable: os("diff"),
|
||||
from: os("foo"),
|
||||
to: os("bar"),
|
||||
tabsize: 0,
|
||||
tabsize: 1,
|
||||
..Default::default()
|
||||
}),
|
||||
parse_params(
|
||||
[os("diff"), os("--tabsize=0"), os("foo"), os("bar")]
|
||||
[os("diff"), os("--tabsize=1"), os("foo"), os("bar")]
|
||||
.iter()
|
||||
.cloned()
|
||||
.peekable()
|
||||
|
||||
+1263
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -3,9 +3,8 @@
|
||||
// For the full copyright and license information, please view the LICENSE-*
|
||||
// files that was distributed with this source code.
|
||||
|
||||
use std::{ffi::OsString, io::Write};
|
||||
|
||||
use regex::Regex;
|
||||
use std::{ffi::OsString, io::Write};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
/// Replace tabs by spaces in the input line.
|
||||
|
||||
+73
-55
@@ -3,9 +3,11 @@
|
||||
// For the full copyright and license information, please view the LICENSE-*
|
||||
// files that was distributed with this source code.
|
||||
|
||||
use assert_cmd::cmd::Command;
|
||||
use assert_cmd::cargo::cargo_bin_cmd;
|
||||
use predicates::prelude::*;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::fs::File;
|
||||
#[cfg(not(windows))]
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use tempfile::{tempdir, NamedTempFile};
|
||||
|
||||
@@ -15,14 +17,14 @@ mod common {
|
||||
|
||||
#[test]
|
||||
fn unknown_param() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("patch");
|
||||
cmd.assert()
|
||||
.code(predicate::eq(2))
|
||||
.failure()
|
||||
.stderr(predicate::eq("patch: utility not supported\n"));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.assert()
|
||||
.code(predicate::eq(0))
|
||||
.success()
|
||||
@@ -31,7 +33,7 @@ mod common {
|
||||
));
|
||||
|
||||
for subcmd in ["diff", "cmp"] {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg(subcmd);
|
||||
cmd.arg("--foobar");
|
||||
cmd.assert()
|
||||
@@ -56,7 +58,7 @@ mod common {
|
||||
let error_message = "The system cannot find the file specified.";
|
||||
|
||||
for subcmd in ["diff", "cmp"] {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg(subcmd);
|
||||
cmd.arg(&nopath).arg(file.path());
|
||||
cmd.assert()
|
||||
@@ -67,7 +69,7 @@ mod common {
|
||||
&nopath.as_os_str().to_string_lossy()
|
||||
)));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg(subcmd);
|
||||
cmd.arg(file.path()).arg(&nopath);
|
||||
cmd.assert()
|
||||
@@ -79,7 +81,7 @@ mod common {
|
||||
)));
|
||||
}
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
cmd.arg(&nopath).arg(&nopath);
|
||||
cmd.assert().code(predicate::eq(2)).failure().stderr(
|
||||
@@ -103,7 +105,7 @@ mod diff {
|
||||
fn no_differences() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let file = NamedTempFile::new()?;
|
||||
for option in ["", "-u", "-c", "-e"] {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
if !option.is_empty() {
|
||||
cmd.arg(option);
|
||||
@@ -123,7 +125,7 @@ mod diff {
|
||||
let mut file1 = NamedTempFile::new()?;
|
||||
file1.write_all("foo\n".as_bytes())?;
|
||||
for option in ["", "-u", "-c", "-e"] {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
if !option.is_empty() {
|
||||
cmd.arg(option);
|
||||
@@ -142,7 +144,7 @@ mod diff {
|
||||
let mut file2 = NamedTempFile::new()?;
|
||||
file2.write_all("foo\n".as_bytes())?;
|
||||
for option in ["", "-u", "-c", "-e"] {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
if !option.is_empty() {
|
||||
cmd.arg(option);
|
||||
@@ -167,7 +169,7 @@ mod diff {
|
||||
let mut file2 = NamedTempFile::new()?;
|
||||
file2.write_all("bar\n".as_bytes())?;
|
||||
for option in ["", "-u", "-c", "-e"] {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
if !option.is_empty() {
|
||||
cmd.arg(option);
|
||||
@@ -188,7 +190,7 @@ mod diff {
|
||||
let mut file2 = NamedTempFile::new()?;
|
||||
file2.write_all("bar\n".as_bytes())?;
|
||||
for option in ["", "-u", "-c", "-e"] {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
if !option.is_empty() {
|
||||
cmd.arg(option);
|
||||
@@ -212,7 +214,7 @@ mod diff {
|
||||
file1.write_all("foo".as_bytes())?;
|
||||
let mut file2 = NamedTempFile::new()?;
|
||||
file2.write_all("bar".as_bytes())?;
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
cmd.arg("-e").arg(file1.path()).arg(file2.path());
|
||||
cmd.assert()
|
||||
@@ -229,7 +231,7 @@ mod diff {
|
||||
let mut file2 = NamedTempFile::new()?;
|
||||
file2.write_all("bar\n".as_bytes())?;
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
cmd.arg("-u")
|
||||
.arg(file1.path())
|
||||
@@ -246,7 +248,7 @@ mod diff {
|
||||
)
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
cmd.arg("-u")
|
||||
.arg("-")
|
||||
@@ -263,7 +265,7 @@ mod diff {
|
||||
)
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
cmd.arg("-u").arg("-").arg("-");
|
||||
cmd.assert()
|
||||
@@ -273,7 +275,7 @@ mod diff {
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
cmd.arg("-u")
|
||||
.arg(file1.path())
|
||||
@@ -309,7 +311,7 @@ mod diff {
|
||||
let mut da = File::create(&da_path).unwrap();
|
||||
da.write_all(b"da\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
cmd.arg("-u").arg(&directory).arg(&a_path);
|
||||
cmd.assert().code(predicate::eq(1)).failure();
|
||||
@@ -324,7 +326,7 @@ mod diff {
|
||||
)
|
||||
);
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("diff");
|
||||
cmd.arg("-u").arg(&a_path).arg(&directory);
|
||||
cmd.assert().code(predicate::eq(1)).failure();
|
||||
@@ -348,7 +350,7 @@ mod cmp {
|
||||
|
||||
#[test]
|
||||
fn cmp_incompatible_params() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
cmd.arg("-s");
|
||||
@@ -371,7 +373,7 @@ mod cmp {
|
||||
let mut a = File::create(&a_path).unwrap();
|
||||
a.write_all(b"a\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path);
|
||||
cmd.write_stdin("a\n");
|
||||
@@ -381,7 +383,7 @@ mod cmp {
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::str::is_empty());
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path);
|
||||
@@ -407,7 +409,7 @@ mod cmp {
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
b.write_all(b"a\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path).arg(&b_path);
|
||||
cmd.assert()
|
||||
@@ -430,7 +432,7 @@ mod cmp {
|
||||
let b_path = tmp_dir.path().join("b");
|
||||
let _ = File::create(&b_path).unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path).arg(&b_path);
|
||||
cmd.assert()
|
||||
@@ -454,7 +456,7 @@ mod cmp {
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
b.write_all(b"bcd\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path).arg(&b_path);
|
||||
@@ -463,7 +465,7 @@ mod cmp {
|
||||
.failure()
|
||||
.stdout(predicate::str::ends_with(" differ: char 1, line 1\n"));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-b");
|
||||
@@ -476,7 +478,7 @@ mod cmp {
|
||||
" differ: byte 1, line 1 is 141 a 142 b\n",
|
||||
));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
@@ -487,7 +489,7 @@ mod cmp {
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::eq("1 141 142\n2 142 143\n3 143 144\n"));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
@@ -516,7 +518,7 @@ mod cmp {
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
b.write_all(b"abc\ndef\ng").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path).arg(&b_path);
|
||||
@@ -526,7 +528,7 @@ mod cmp {
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::str::ends_with(" differ: char 8, line 2\n"));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-b");
|
||||
@@ -539,7 +541,7 @@ mod cmp {
|
||||
" differ: byte 8, line 2 is 147 g 12 ^J\n",
|
||||
));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
@@ -551,7 +553,7 @@ mod cmp {
|
||||
.stderr(predicate::str::contains(" EOF on"))
|
||||
.stderr(predicate::str::ends_with(" after byte 8\n"));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-b");
|
||||
@@ -579,7 +581,7 @@ mod cmp {
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
b.write_all(b"abcdefghijkl\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
cmd.arg("-b");
|
||||
@@ -592,7 +594,7 @@ mod cmp {
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::str::is_empty());
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
cmd.arg("-b");
|
||||
@@ -605,7 +607,7 @@ mod cmp {
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::eq("4 40 144 d\n"));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
cmd.arg("-b");
|
||||
@@ -616,7 +618,7 @@ mod cmp {
|
||||
.code(predicate::eq(1))
|
||||
.failure()
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::eq("4 40 144 d\n8 40 150 h\n"));
|
||||
.stdout(predicate::eq(" 4 40 144 d\n 8 40 150 h\n"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -632,7 +634,7 @@ mod cmp {
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
b.write_all(b"###abc\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-i");
|
||||
@@ -645,7 +647,7 @@ mod cmp {
|
||||
.stdout(predicate::str::is_empty());
|
||||
|
||||
// Positional skips should be ignored
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-i");
|
||||
@@ -659,7 +661,7 @@ mod cmp {
|
||||
.stdout(predicate::str::is_empty());
|
||||
|
||||
// Single positional argument should only affect first file.
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path).arg(&b_path);
|
||||
@@ -670,7 +672,7 @@ mod cmp {
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::str::ends_with(" differ: char 1, line 1\n"));
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.env("LC_ALL", "C");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path).arg(&b_path);
|
||||
@@ -691,15 +693,15 @@ mod cmp {
|
||||
|
||||
let a_path = tmp_dir.path().join("a");
|
||||
let mut a = File::create(&a_path).unwrap();
|
||||
write!(a, "{}c\n", "a".repeat(1024)).unwrap();
|
||||
writeln!(a, "{}c", "a".repeat(1024)).unwrap();
|
||||
a.flush().unwrap();
|
||||
|
||||
let b_path = tmp_dir.path().join("b");
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
write!(b, "{}c\n", "b".repeat(1024)).unwrap();
|
||||
writeln!(b, "{}c", "b".repeat(1024)).unwrap();
|
||||
b.flush().unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("--ignore-initial=1K");
|
||||
cmd.arg(&a_path).arg(&b_path);
|
||||
@@ -724,7 +726,7 @@ mod cmp {
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
b.write_all(b"abcdefghijkl\n").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
cmd.arg("-b");
|
||||
@@ -737,7 +739,7 @@ mod cmp {
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::str::is_empty());
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-b");
|
||||
cmd.arg("-i");
|
||||
@@ -770,7 +772,7 @@ mod cmp {
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
b.write_all(&bytes).unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-l");
|
||||
cmd.arg("-b");
|
||||
@@ -815,7 +817,7 @@ mod cmp {
|
||||
|
||||
let dev_null = OpenOptions::new().write(true).open("/dev/null").unwrap();
|
||||
|
||||
let mut child = std::process::Command::new(assert_cmd::cargo::cargo_bin("diffutils"))
|
||||
let mut child = std::process::Command::new(assert_cmd::cargo::cargo_bin!("diffutils"))
|
||||
.arg("cmp")
|
||||
.arg(&a_path)
|
||||
.arg(&b_path)
|
||||
@@ -823,12 +825,27 @@ mod cmp {
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
|
||||
assert_eq!(child.try_wait().unwrap().unwrap().code(), Some(1));
|
||||
// Bound the runtime to a very short time that still allows for some resource
|
||||
// constraint to slow it down while also allowing very fast systems to exit as
|
||||
// early as possible.
|
||||
const MAX_TRIES: u8 = 50;
|
||||
for tries in 0..=MAX_TRIES {
|
||||
if tries == MAX_TRIES {
|
||||
panic!("cmp took too long to run, /dev/null optimization probably not working")
|
||||
}
|
||||
match child.try_wait() {
|
||||
Ok(Some(status)) => {
|
||||
assert_eq!(status.code(), Some(1));
|
||||
break;
|
||||
}
|
||||
Ok(None) => (),
|
||||
Err(e) => panic!("{e:#?}"),
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
}
|
||||
|
||||
// Two stdins should be equal
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg("-");
|
||||
cmd.arg("-");
|
||||
@@ -851,17 +868,18 @@ mod cmp {
|
||||
|
||||
let a_path = tmp_dir.path().join("a");
|
||||
let mut a = File::create(&a_path).unwrap();
|
||||
a.write_all(&bytes).unwrap();
|
||||
a.write_all(bytes).unwrap();
|
||||
a.write_all(b"A").unwrap();
|
||||
|
||||
let b_path = tmp_dir.path().join("b");
|
||||
let mut b = File::create(&b_path).unwrap();
|
||||
b.write_all(&bytes).unwrap();
|
||||
b.write_all(bytes).unwrap();
|
||||
b.write_all(b"B").unwrap();
|
||||
|
||||
let mut cmd = Command::cargo_bin("diffutils")?;
|
||||
let mut cmd = cargo_bin_cmd!("diffutils");
|
||||
cmd.arg("cmp");
|
||||
cmd.arg(&a_path).arg(&b_path);
|
||||
cmd.env("LC_ALL", "en_US");
|
||||
cmd.assert()
|
||||
.code(predicate::eq(1))
|
||||
.failure()
|
||||
|
||||
Reference in New Issue
Block a user