Move zstdgrep and zstdless tests to cli-tests (#3057)
* Move zstdgrep and zstdless tests to cli-tests Co-authored-by: Binh Vo <binhvo@fb.com>dev
parent
7e364e8828
commit
936ae8a3a0
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
"$ZSTDLESS_BIN" $@
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "1234" > file
|
||||
zstd file
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
println "+ good path"
|
||||
zstdgrep "1234" file file.zst
|
||||
println "+ bad path"
|
||||
zstdgrep "1234" bad.zst
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1 @@
|
|||
zstd: can't stat bad.zst : No such file or directory -- ignored
|
|
@ -0,0 +1,4 @@
|
|||
+ good path
|
||||
file:1234
|
||||
file.zst:1234
|
||||
+ bad path
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
println "+ good path"
|
||||
zstdless file.zst
|
||||
println "+ pass parameters"
|
||||
zstdless -N file.zst # This parameter does not produce line #s when piped, but still serves to test that the flag went to less and not zstd
|
||||
println "+ bad path"
|
||||
zstdless bad.zst
|
|
@ -0,0 +1,2 @@
|
|||
zstd: can't stat bad.zst : No such file or directory -- ignored
|
||||
bad.zst: No such file or directory
|
|
@ -0,0 +1,5 @@
|
|||
+ good path
|
||||
1234
|
||||
+ pass parameters
|
||||
1234
|
||||
+ bad path
|
|
@ -627,6 +627,7 @@ if __name__ == "__main__":
|
|||
TESTS_DIR = os.path.join(REPO_DIR, "tests")
|
||||
ZSTD_PATH = os.path.join(PROGRAMS_DIR, "zstd")
|
||||
ZSTDGREP_PATH = os.path.join(PROGRAMS_DIR, "zstdgrep")
|
||||
ZSTDLESS_PATH = os.path.join(PROGRAMS_DIR, "zstdless")
|
||||
DATAGEN_PATH = os.path.join(TESTS_DIR, "datagen")
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
|
@ -658,6 +659,11 @@ if __name__ == "__main__":
|
|||
default=ZSTDGREP_PATH,
|
||||
help="Sets the ZSTDGREP_BIN environment variable. Path of the zstdgrep CLI."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--zstdless",
|
||||
default=ZSTDLESS_PATH,
|
||||
help="Sets the ZSTDLESS_BIN environment variable. Path of the zstdless CLI."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--datagen",
|
||||
default=DATAGEN_PATH,
|
||||
|
@ -695,6 +701,7 @@ if __name__ == "__main__":
|
|||
env["ZSTD_SYMLINK_DIR"] = zstd_symlink_dir
|
||||
env["DATAGEN_BIN"] = os.path.abspath(args.datagen)
|
||||
env["ZSTDGREP_BIN"] = os.path.abspath(args.zstdgrep)
|
||||
env["ZSTDLESS_BIN"] = os.path.abspath(args.zstdless)
|
||||
env["COMMON"] = os.path.abspath(os.path.join(args.test_dir, "common"))
|
||||
env["PATH"] = bin_dir + ":" + os.getenv("PATH", "")
|
||||
|
||||
|
|
|
@ -92,8 +92,6 @@ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
|||
PRGDIR="$SCRIPT_DIR/../programs"
|
||||
TESTDIR="$SCRIPT_DIR/../tests"
|
||||
UNAME=$(uname)
|
||||
ZSTDGREP="$PRGDIR/zstdgrep"
|
||||
ZSTDLESS="$PRGDIR/zstdless"
|
||||
|
||||
detectedTerminal=false
|
||||
if [ -t 0 ] && [ -t 1 ]
|
||||
|
@ -326,31 +324,6 @@ if [ "$isWindows" = false ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
println "\n===> zstdgrep tests"
|
||||
ln -sf "$ZSTD_BIN" zstdcat
|
||||
rm -f tmp_grep
|
||||
echo "1234" > tmp_grep
|
||||
zstd -f tmp_grep
|
||||
lines=$(ZCAT=./zstdcat "$ZSTDGREP" 2>&1 "1234" tmp_grep tmp_grep.zst | wc -l)
|
||||
test 2 -eq $lines
|
||||
ZCAT=./zstdcat "$ZSTDGREP" 2>&1 "1234" tmp_grep_bad.zst && die "Should have failed"
|
||||
ZCAT=./zstdcat "$ZSTDGREP" 2>&1 "1234" tmp_grep_bad.zst | grep "No such file or directory" || true
|
||||
rm -f tmp_grep*
|
||||
|
||||
println "\n===> zstdless tests"
|
||||
if [ -n "$(which less)" ]; then
|
||||
ln -sf "$ZSTD_BIN" zstd
|
||||
rm -f tmp_less*
|
||||
echo "1234" > tmp_less
|
||||
zstd -f tmp_less
|
||||
lines=$(ZSTD=./zstd "$ZSTDLESS" 2>&1 tmp_less.zst | wc -l)
|
||||
test 1 -eq $lines
|
||||
ZSTD=./zstd "$ZSTDLESS" -f tmp_less.zst > tmp_less_regenerated
|
||||
$DIFF tmp_less tmp_less_regenerated
|
||||
ZSTD=./zstd "$ZSTDLESS" 2>&1 tmp_less_bad.zst | grep "No such file or directory" || die
|
||||
rm -f tmp_less*
|
||||
fi
|
||||
|
||||
println "\n===> --exclude-compressed flag"
|
||||
rm -rf precompressedFilterTestDir
|
||||
mkdir -p precompressedFilterTestDir
|
||||
|
|
Loading…
Reference in New Issue