diff options
author | Tom Whipple <tw@tomwhipple.com> | 2006-07-14 23:43:07 +0000 |
---|---|---|
committer | Tom Whipple <tw@tomwhipple.com> | 2006-07-14 23:43:07 +0000 |
commit | b6d17d849ad0ebbcaedf26bae19bcce2041d73eb (patch) | |
tree | 1b7ed4e9e70814c1b7baa7175db82f9b976e5ccd /tests | |
parent | 48409dde548090b4081c152fe8de1c84f1546c1f (diff) |
preliminary support for unique datafiles
Diffstat (limited to 'tests')
-rw-r--r-- | tests/include/testcontrol.sh | 4 | ||||
-rw-r--r-- | tests/include/testfuncs.sh | 53 | ||||
-rwxr-xr-x | tests/xdg-desktop-icon/t.desktop_icon_install | 9 |
3 files changed, 35 insertions, 31 deletions
diff --git a/tests/include/testcontrol.sh b/tests/include/testcontrol.sh index dead491..ae55d12 100644 --- a/tests/include/testcontrol.sh +++ b/tests/include/testcontrol.sh @@ -98,6 +98,8 @@ while [ "$J" -le "$LENGTH" ] ; do done } +. "$XDG_TEST_DIR/include/tempfile.sh" + test_setup() { get_guid "xdgt" export XDG_TEST_ID="$GUID" @@ -111,8 +113,6 @@ test_cleanup() { cd "$XDG_TEST_DIR" # ALWAYS check what you pass to 'rm -rf' [ -d "$XDG_TEST_TMPDIR" ] && rm -rf "$XDG_TEST_TMPDIR" -# else -# echo "Not removing $XDG_TEST_TMPDIR" fi } diff --git a/tests/include/testfuncs.sh b/tests/include/testfuncs.sh index 73448fd..57b846c 100644 --- a/tests/include/testfuncs.sh +++ b/tests/include/testfuncs.sh @@ -1,27 +1,3 @@ -DELETE_mkworkdir() { - if [ ! -z "$TEST_WORK_DIR" -a -d "$TEST_WORK_DIR" ]; then - return - fi - - NOW=`date '+%-Y-%-m-%-d_%-k-%-M-%-S.%N'` - - if [ -z "$TEMP" ] ; then - TEMP="./tmp-xdg-test" - fi - - DIR="xdgt_$NOW" - while [ -d "$DIR" ] - do - DIR="$DIR" - done - - export TEST_WORK_DIR="$TEMP/$DIR" - mkdir -p "$TEST_WORK_DIR" -} - -. "$XDG_TEST_DIR/include/tempfile.sh" - - verify_test_context() { if [ -z "$TEST_NAME" -a ! "$USING_TET" ]; then echo "A test context must be established with 'test_start <name>'!" @@ -141,3 +117,32 @@ test_result() { exit "$RESULT" } +## TODO: validate input +use_file() { + src="$1" + file=${src##/*/} + varname="$2" + + outfile="xdgtestdata-$XDG_TEST_ID-$file" + eval "$varname=$outfile" + + cp "$src" "$XDG_TEST_TMPDIR/$outfile" +} + +## TODO: validate input +get_unique_name() { + varname="$1" + suffix="$2" + + outfile="xdgtestdata-$XDG_TEST_ID-$file" + eval "$varname=$outfile" +} + +## TODO: validate input +edit_file() { + file="$1" + origstr="$2" + newstr="$3" + + sed -i -e "s/$origstr/$newstr/g" "$file" +} diff --git a/tests/xdg-desktop-icon/t.desktop_icon_install b/tests/xdg-desktop-icon/t.desktop_icon_install index aef3c5e..d5f096a 100755 --- a/tests/xdg-desktop-icon/t.desktop_icon_install +++ b/tests/xdg-desktop-icon/t.desktop_icon_install @@ -14,21 +14,20 @@ test_start "$FUNCNAME: verify a desktop file installed correctly on the desktop" test_init # Generate .desktop file -FILE='desktop_icon_install.desktop' -DIR="$XDG_TEST_DIR/xdg-desktop-icon/data" +use_file "$XDG_TEST_DIR/xdg-desktop-icon/data/desktop_icon_install.desktop" FILE set_no_display - -assert_file "$DIR/$FILE" +assert_file "$XDG_TEST_TMPDIR/$FILE" # Verify the test icon is not installed already. assert_file_not_in_path "$FILE" "$HOME/Desktop" +assert_nofile "$HOME/xdg-test-desktop-icon-install.tmp" # Test steps section test_procedure -assert_exit 0 xdg-desktop-icon install "$DIR/$FILE" +assert_exit 0 xdg-desktop-icon install "$XDG_TEST_TMPDIR/$FILE" assert_nostdout assert_nostderr |