view scripts/test/find.test @ 1271:c214de62b18b draft

Teach cpio to set uid/gid and timestamp. (Timestamp has year 2100 problem.) Note that directory timestamps are still sometimes wrong because creating things in a directory can update the timestamp. Also, cp -r has logic to ensure we can write to a directory that doesn't have write permission, cpio does not. This is fixable, but not what existing cpio does.
author Rob Landley <rob@landley.net>
date Tue, 29 Apr 2014 06:03:17 -0500
parents 4edd1cb3f700
children
line wrap: on
line source

#!/bin/bash

[ -f testing.sh ] && . testing.sh

mkdir dir
cd dir
touch file
mkfifo fifo
ln -s fifo link
cd ..

#testing "name" "command" "result" "infile" "stdin"

# Testing operators

testing "find -type l -a -type d -o -type p" \
	"find dir -type l -a -type d -o -type p" "dir/fifo\n" "" ""
testing "find -type l -type d -o -type p" "find dir -type l -type d -o -type p" \
	"dir/fifo\n" "" ""
testing "find -type l -o -type d -a -type p" \
	"find dir -type l -o -type d -a -type p" "dir/link\n" "" ""
testing "find -type l -o -type d -type p" "find dir -type l -o -type d -type p" \
	"dir/link\n" "" ""
testing "find -type l ( -type d -o -type l )" \
	"find dir -type l \( -type d -o -type l \)" "dir/link\n" "" ""
testing "find extra parantheses" \
	"find dir \( \( -type l \) \( -type d -o \( \( -type l \) \) \) \)" \
	"dir/link\n" "" ""
testing "find ( -type p -o -type d ) -type p" \
	"find dir \( -type p -o -type d \) -type p" "dir/fifo\n" "" ""
testing "find -type l -o -type d -type p -o -type f" \
	"find dir -type l -o -type d -type p -o -type f | sort" \
	"dir/file\ndir/link\n" "" ""

# Testing short-circuit evaluations

testing "find -type f -a -print" \
	"find dir -type f -a -print" "dir/file\n" "" ""
testing "find -print -o -print" \
	"find dir -type f -a \( -print -o -print \)" "dir/file\n" "" ""

rm -rf dir