Trebuchet tests for the creating and deploying of binary deltas =============================================================== The following scenarios test tbdiff-deploy's ability to correctly transform the content of a target directory, to that of a source directory, given an appropriate binary delta created by tbdiff-create. Changing of a file's content ---------------------------- This simple test checks that file content is as expected, if the content of the two text files are different, the test will fail. SCENARIO Changing a regular file's content works GIVEN a directory exists named 'A' AND the directory 'A' contains a regular file named 'foo.txt' with '1' in it AND a directory exists named 'B' AND the directory 'B' contains a regular file named 'foo.txt' with '2' in it WHEN tbdiff-create creates a binary delta named 'AB.tbdiff' from 'A' to 'B' AND tbdiff-deploy applies the delta 'AB.tbdiff' to 'A' THEN the files 'A/foo.txt' and 'B/foo.txt' have the same contents Changing of a file's ownership ------------------------------ Trebuchet also takes into account POSIX metadata such as ownership, these scenarios are written to test that functionality. SCENARIO Changing a regular file's group ownership works GIVEN a directory exists named 'C' AND the directory 'C' contains a regular file named 'bar' AND a directory exists named 'D' AND the directory 'D' contains a regular file named 'bar' AND the file 'D/bar' is owned by the group '893' WHEN tbdiff-create creates a binary delta named 'CD.tbdiff' from 'C' to 'D' AND tbdiff-deploy applies the delta 'CD.tbdiff' to 'C' THEN the file 'C/bar' is owned by the group '893' SCENARIO Changing a named pipe's group ownership works GIVEN a directory exists named 'E' AND the directory 'E' contains the named pipe 'red' AND a directory exists named 'F' AND the directory 'F' contains the named pipe 'red' AND the file 'F/red' is owned by the group '594' WHEN tbdiff-create creates a binary delta named 'EF.tbdiff' from 'E' to 'F' AND tbdiff-deploy applies the delta 'EF.tbdiff' to 'E' THEN the file 'E/red' is owned by the group '594' Changing of a file's permissions -------------------------------- These scenarios test that file permissions are successfully changed after the deployment of a binary delta. SCENARIO Changing a file's permissions works GIVEN a directory exists named 'G' AND the directory 'G' contains a regular file named 'baz' AND a directory exists named 'H' AND the directory 'H' contains a regular file named 'baz' AND the file 'H/baz' has the permissions 'ugo=rw' WHEN tbdiff-create creates a binary delta named 'GH.tbdiff' from 'G' to 'H' AND tbdiff-deploy applies the delta 'GH.tbdiff' to 'G' THEN the file 'G/baz' has the permissions '-rw-rw-rw-' SCENARIO Changing a named pipe's permissions works GIVEN a directory exists named 'I' AND the directory 'I' contains the named pipe 'orange' AND a directory exists named 'J' AND the directory 'J' contains the named pipe 'orange' AND the file 'J/orange' has the permissions 'ug=rw,o=r' WHEN tbdiff-create creates a binary delta named 'IJ.tbdiff' from 'I' to 'J' AND tbdiff-deploy applies the delta 'IJ.tbdiff' to 'I' THEN the file 'I/orange' has the permissions 'prw-rw-r--' Adding and removing of files ---------------------------- The following scenarios check that the deploying of a binary delta successfully removes and creates the appropriate files. SCENARIO Adding and removing of regular files works GIVEN a directory exists named 'K' AND the directory 'K' contains a regular file named 'minus' AND a directory exists named 'L' AND the directory 'L' contains a regular file named 'plus' WHEN tbdiff-create creates a binary delta named 'KL.tbdiff' from 'K' to 'L' AND tbdiff-deploy applies the delta 'KL.tbdiff' to 'K' THEN the file 'K/minus' no longer exists AND the directory 'K' contains a file named 'plus' SCENARIO Adding and removing of named pipes works GIVEN a directory exists named 'M' AND the directory 'M' contains the named pipe 'yellow' AND a directory exists named 'N' AND the directory 'N' contains the named pipe 'green' WHEN tbdiff-create creates a binary delta named 'MN.tbdiff' from 'M' to 'N' AND tbdiff-deploy applies the delta 'MN.tbdiff' to 'M' THEN the file 'M/yellow' no longer exists AND the directory 'M' contains the named pipe 'green' Changing modification time of a file ------------------------------------ In the following scenarios we check that modification times are correctly changed, if modification times are not identical, the test fails. SCENARIO Changing a file's modification time works GIVEN a directory exists named 'O' AND the directory 'O' contains a regular file named 'hurr' with '1' in it AND the file 'O/hurr' has its modification time set to '@793042334' AND a directory exists named 'P' AND the directory 'P' contains a regular file named 'hurr' with '1' in it AND the file 'P/hurr' has its modification time set to '@683074800' WHEN tbdiff-create creates a binary delta named 'OP.tbdiff' from 'O' to 'P' AND tbdiff-deploy applies the delta 'OP.tbdiff' to 'O' THEN the files 'O/hurr' and 'P/hurr' have the same modification time SCENARIO Changing a named pipe's modification time works GIVEN a directory exists named 'Q' AND the directory 'Q' contains the named pipe 'blue' AND the file 'Q/blue' has its modification time set to '@1381758015' AND a directory exists named 'R' AND the directory 'R' contains the named pipe 'blue' AND the file 'R/blue' has its modification time set to '@683074800' WHEN tbdiff-create creates a binary delta named 'QR.tbdiff' from 'Q' to 'R' AND tbdiff-deploy applies the delta 'QR.tbdiff' to 'Q' THEN the files 'Q/blue' and 'R/blue' have the same modification time IMPLEMENTS ========== Implementations for the creating and deploying of binary deltas --------------------------------------------------------------- IMPLEMENTS GIVEN a directory exists named '([^']+)' mkdir "$DATADIR/$MATCH_1" IMPLEMENTS GIVEN the directory '([^']+)' contains a regular file named '([^']+)' with '([^']+)' in it echo "$MATCH_3" > "$DATADIR/$MATCH_1/$MATCH_2" IMPLEMENTS GIVEN the directory '([^']+)' contains a regular file named '([^']+)' touch "$DATADIR/$MATCH_1/$MATCH_2" IMPLEMENTS GIVEN the file '([^']+)' is owned by the group '([^']+)' chgrp "$MATCH_2" "$DATADIR/$MATCH_1" IMPLEMENTS GIVEN the file '([^']+)' has the permissions '([^']+)' chmod "$MATCH_2" "$DATADIR/$MATCH_1" IMPLEMENTS GIVEN the file '([^']+)' has its modification time set to '([^']+)' touch -d "$MATCH_2" "$DATADIR/$MATCH_1" IMPLEMENTS GIVEN the directory '([^']+)' contains the named pipe '([^']+)' mkfifo "$DATADIR/$MATCH_1/$MATCH_2" IMPLEMENTS WHEN tbdiff-create creates a binary delta named '([^']+)' from '([^']+)' to '([^']+)' "$SRCDIR/tbdiff-create/tbdiff-create" "$DATADIR/$MATCH_1" "$DATADIR/$MATCH_2" "$DATADIR/$MATCH_3" IMPLEMENTS WHEN tbdiff-deploy applies the delta '([^']+)' to '([^']+)' cd "$DATADIR/$MATCH_2" "$SRCDIR/tbdiff-deploy/tbdiff-deploy" "$DATADIR/$MATCH_1" IMPLEMENTS THEN the files '([^']+)' and '([^']+)' have the same contents diff "$DATADIR/$MATCH_1" "$DATADIR/$MATCH_2" IMPLEMENTS THEN the file '([^']+)' is owned by the group '([^']+)' test "$(stat -c %g "$DATADIR/$MATCH_1")" = "$MATCH_2" IMPLEMENTS THEN the file '([^']+)' has the permissions '([^']+)' test "$(stat -c %A "$DATADIR/$MATCH_1")" = "$MATCH_2" IMPLEMENTS THEN the file '([^']+)' no longer exists test ! -e "$DATADIR/$MATCH_1" IMPLEMENTS THEN the directory '([^']+)' contains a file named '([^']+)' test -f "$DATADIR/$MATCH_1/$MATCH_2" IMPLEMENTS THEN the files '([^']+)' and '([^']+)' have the same modification time test "$(stat -c %y "$DATADIR/$MATCH_1")" = "$(stat -c %y "$DATADIR/$MATCH_2")" IMPLEMENTS THEN the directory '([^']+)' contains the named pipe '([^']+)' test -p "$DATADIR/$MATCH_1/$MATCH_2"