diff --git a/tests/file b/tests/file index 92022671..c23da453 100755 --- a/tests/file +++ b/tests/file @@ -8,6 +8,12 @@ function test_file test_equal "./src/file.run $1" "$2" } +function test_chmod +{ + touch $2 + chmod $1 $2 +} + ### @@ -50,8 +56,7 @@ rm $DATA_DIR/* # Test opening for read test_file "-D -o R file.txt" "ERROR: File does not exist" -touch $DATA_DIR/file.txt -chmod -r $DATA_DIR/file.txt +test_chmod -r $DATA_DIR/file.txt test_file "-D -o R file.txt" "ERROR: File could not be opened for reading" rm -r $DATA_DIR @@ -63,8 +68,7 @@ test_file "-D -o W file.txt" "ERROR: Could not make directory" rm $DATA_DIR mkdir -p $DATA_DIR -touch $DATA_DIR/file.txt -chmod -w $DATA_DIR/file.txt +test_chmod -w $DATA_DIR/file.txt test_file "-D -o W file.txt" "ERROR: Could not open file for writing" rm -rf $DATA_DIR