Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Bash version #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tests/data/have1.txt
12 changes: 12 additions & 0 deletions rshasum.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#
# Copyright (C) 2018 Shlomi Fish <[email protected]>
#
# Distributed under the terms of the ISC license.
#

export SUM="${RSHASUM_SUM:-sha256sum}"
tfn="`mktemp`"
find . -type f -follow | (LC_ALL=C sort) | xargs -d '\n' "$SUM" | tee "$tfn"
"$SUM" - < "$tfn"
rm -f "$tfn"
1 change: 1 addition & 0 deletions tests/data/1/0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test string
1 change: 1 addition & 0 deletions tests/data/1/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
toast ::: string
3 changes: 3 additions & 0 deletions tests/data/want1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b ./0.txt
7ea4c2a1c490e653b0ea37bb1a087553380ba642536dabbb2f3b4eb3a2bd6fdf ./2.txt
767cd9df9f4f5b9245d06ab083d6fd09e2a02e9724f8b595a805b7e1980daa22 -
21 changes: 21 additions & 0 deletions tests/test-bash.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 1;
use Test::Differences (qw( eq_or_diff ));
use IO::All qw/ io /;
use Cwd qw/ getcwd /;

{
my $cwd = getcwd();
system(qq%cd tests/data/1/ && "$cwd"/rshasum.bash > ../have1.txt%);

# TEST
eq_or_diff(
io->file("tests/data/have1.txt")->all,
io->file("tests/data/want1.txt")->all,
"rshasum #1",
);
}