diff options
author | Tom Whipple <tw@tomwhipple.com> | 2006-07-27 23:00:15 +0000 |
---|---|---|
committer | Tom Whipple <tw@tomwhipple.com> | 2006-07-27 23:00:15 +0000 |
commit | 95d8c3fafd23d8b269a4aac1ef96376c571b64e1 (patch) | |
tree | 923019a2d173e6b5c69bd4ecddcdca3202841e01 | |
parent | ab4ec36f5064fe8e3d496722d7ddde1d43369873 (diff) |
fix various tests
15 files changed, 44 insertions, 42 deletions
diff --git a/portland/xdg-utils/tests/Makefile.in b/portland/xdg-utils/tests/Makefile.in index 484e8aa..84a0db2 100644 --- a/portland/xdg-utils/tests/Makefile.in +++ b/portland/xdg-utils/tests/Makefile.in @@ -36,9 +36,11 @@ clean: tests-clean tests-userclean: rm -rf tmp/xdgt* find ${HOME} -name 'xdgtestdata*' | xargs rm -f + find ${HOME} -name 'x-xdgt*.xml' | xargs rm -f tests-clean: tests-userclean - find `echo "${XDG_DATA_DIRS}:${XDG_CONFIG_DIRS}" | sed -e 's/:/ /g'` -name 'xdgtestdata*' | xargs rm -f + find `echo "${XDG_DATA_DIRS}:${XDG_CONFIG_DIRS}" | sed -e 's/:/ /g'` -name 'xdgtestdata*' | xargs rm -f + find `echo "${XDG_DATA_DIRS}:${XDG_CONFIG_DIRS}" | sed -e 's|:|/mime |g'` -name 'x-xdgt*.xml' | xargs rm -f install: diff --git a/portland/xdg-utils/tests/include/testassertions.sh b/portland/xdg-utils/tests/include/testassertions.sh index d064faa..2b37326 100644 --- a/portland/xdg-utils/tests/include/testassertions.sh +++ b/portland/xdg-utils/tests/include/testassertions.sh @@ -13,9 +13,11 @@ assert_exit() # execute command (saving output) and check exit code rm -f out.stdout out.stderr # $1 is command, $2 is expected exit code (0 or "N" for non-zero) - ( "$@" > out.stdout 2> out.stderr ) + ( "$@" > out.stdout 2> out.stderr ) CODE="$?" + LASTCOMMAND="$*" + if [ -z "$EXPECT" ]; then EXPECT=0; fi @@ -119,7 +121,7 @@ assert_nostdout() # check that nothing went to stdout { if [ -s out.stdout ] then - test_infoline "Unexpected output written to stdout, as shown below:" + test_infoline "Unexpected output from '$LASTCOMMAND' written to stdout, as shown below:" infofile out.stdout stdout: test_fail fi @@ -128,10 +130,10 @@ assert_nostdout() # check that nothing went to stdout assert_nostderr() # check that nothing went to stderr { if [ ! -z "$XDG_UTILS_DEBUG_LEVEL" ] ; then - test_infoline "not checking STDERR because XDG_UTILS_DEBUG_LEVEL=$XDG_UTILS_DEBUG_LEVEL" + test_infoline "not checking STDERR from '$LASTCOMMAND' because XDG_UTILS_DEBUG_LEVEL=$XDG_UTILS_DEBUG_LEVEL" test_infoline out.stderr stderr: elif [ -s out.stderr ] ; then - test_infoline "Unexpected output written to stderr, as shown below:" + test_infoline "Unexpected output from '$LASTCOMMAND' written to stderr, as shown below:" infofile out.stderr stderr: test_fail fi @@ -146,7 +148,7 @@ assert_stderr() # check that stderr matches expected error "") if [ ! -s out.stderr ] then - test_infoline "Expected output to stderr, but none written" + test_infoline "Expected output from '$LASTCOMMAND' to stderr, but none written" test_fail fi ;; @@ -172,7 +174,7 @@ assert_stderr() # check that stderr matches expected error exec 0<&4 3<&- 4<&- if [ "$OK" = N ] then - test_infoline "Incorrect output written to stderr, as shown below" + test_infoline "Incorrect output from '$LASTCOMMAND' written to stderr, as shown below" infofile "$expfile" "expected stderr:" infofile out.stderr "received stderr:" test_fail @@ -190,7 +192,7 @@ assert_stdout() # check that stderr matches expected error "") if [ ! -s out.stdout ] then - test_infoline "Expected output to stdout, but none written" + test_infoline "Expected output from '$LASTCOMMAND' to stdout, but none written" test_fail fi ;; @@ -223,7 +225,7 @@ assert_stdout() # check that stderr matches expected error exec 0<&4 3<&- 4<&- if [ "$OK" = N ] then - test_infoline "Incorrect output written to stdout, as shown below" + test_infoline "Incorrect output from '$LASTCOMMAND' written to stdout, as shown below" infofile "$expfile" "expected stdout:" infofile out.stdout "received stdout:" test_fail diff --git a/portland/xdg-utils/tests/xdg-mime/t.01-query_text_plain b/portland/xdg-utils/tests/xdg-mime/t.01-query_text_plain index f676c36..80b962f 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.01-query_text_plain +++ b/portland/xdg-utils/tests/xdg-mime/t.01-query_text_plain @@ -1,7 +1,6 @@ #!/bin/bash . "$XDG_TEST_DIR/include/testassertions.sh" - . "$XDG_TEST_DIR/include/testcontrol.sh" test_query_text_plain() { @@ -14,9 +13,7 @@ test_purpose "Verify that the basic query (text/plain) is working." ## Check dependencies test_init -set_no_display - -assert_exit 0 test -z "$DISPLAY" +require_notroot echo 'This is some text.' > $INPUT_FILE assert_file "$INPUT_FILE" diff --git a/portland/xdg-utils/tests/xdg-mime/t.02-query_missing_file b/portland/xdg-utils/tests/xdg-mime/t.02-query_missing_file index 1ed04b4..08045d5 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.02-query_missing_file +++ b/portland/xdg-utils/tests/xdg-mime/t.02-query_missing_file @@ -13,7 +13,8 @@ test_purpose "Verify that the correct error is generated when the mime file is m ## Check dependencies test_init -set_no_display +# query requires a desktop environment +require_notroot assert_nofile "$INPUT_FILE" ## Main test diff --git a/portland/xdg-utils/tests/xdg-mime/t.03-system_as_nonroot b/portland/xdg-utils/tests/xdg-mime/t.03-system_as_nonroot index 7da7ec9..f1bccec 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.03-system_as_nonroot +++ b/portland/xdg-utils/tests/xdg-mime/t.03-system_as_nonroot @@ -2,7 +2,6 @@ ## Include utility functions. . "$XDG_TEST_DIR/include/testassertions.sh" - . "$XDG_TEST_DIR/include/testcontrol.sh" ## Test function @@ -17,8 +16,6 @@ test_init require_notroot -set_no_display - use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID" assert_file "$INPUT_FILE" diff --git a/portland/xdg-utils/tests/xdg-mime/t.10-user_mime_install b/portland/xdg-utils/tests/xdg-mime/t.10-user_mime_install index 840f4c1..95590ee 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.10-user_mime_install +++ b/portland/xdg-utils/tests/xdg-mime/t.10-user_mime_install @@ -2,7 +2,6 @@ ## Include utility functions. . "$XDG_TEST_DIR/include/testassertions.sh" - . "$XDG_TEST_DIR/include/testcontrol.sh" ## Test function @@ -15,7 +14,8 @@ test_purpose "Verify that new mime types get installed into the user space corre # Dependencies section test_init -set_no_display +require_notroot + use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID" assert_file "$INPUT_FILE" @@ -38,6 +38,8 @@ assert_exit 0 xdg-mime install --user "$INPUT_FILE" assert_nostdout assert_nostderr +sleep 1 + assert_exit 0 xdg-mime query filetype testfile.xdgtest assert_stdout testmime.expected assert_nostderr diff --git a/portland/xdg-utils/tests/xdg-mime/t.11-user_mime_uninstall b/portland/xdg-utils/tests/xdg-mime/t.11-user_mime_uninstall index 0bc59e7..7641ff3 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.11-user_mime_uninstall +++ b/portland/xdg-utils/tests/xdg-mime/t.11-user_mime_uninstall @@ -2,7 +2,6 @@ ## Include utility functions. . "$XDG_TEST_DIR/include/testassertions.sh" - . "$XDG_TEST_DIR/include/testcontrol.sh" ## Test function @@ -17,7 +16,8 @@ test_purpose "Verify that mime types get removed from the user space correctly." # Dependencies section test_init -set_no_display +require_notroot + use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID" assert_file "$INPUT_FILE" diff --git a/portland/xdg-utils/tests/xdg-mime/t.12-user_install_missing_file b/portland/xdg-utils/tests/xdg-mime/t.12-user_install_missing_file index 280b421..d009ece 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.12-user_install_missing_file +++ b/portland/xdg-utils/tests/xdg-mime/t.12-user_install_missing_file @@ -1,7 +1,6 @@ #!/bin/bash . "$XDG_TEST_DIR/include/testassertions.sh" - . "$XDG_TEST_DIR/include/testcontrol.sh" test_user_install_missing_file() { @@ -13,7 +12,7 @@ test_purpose "Verify that the correct error is generated when the mime file is m ## Check dependencies test_init -set_no_display +require_notroot assert_nofile "$INPUT_FILE" ## Main test diff --git a/portland/xdg-utils/tests/xdg-mime/t.13-notexist_mime_uninstall b/portland/xdg-utils/tests/xdg-mime/t.13-notexist_mime_uninstall index 672574e..81bc5e4 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.13-notexist_mime_uninstall +++ b/portland/xdg-utils/tests/xdg-mime/t.13-notexist_mime_uninstall @@ -16,7 +16,7 @@ test_start "$FUNCNAME: uninstall mime type that is not present" # Dependencies section test_init -set_no_display +require_notroot use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID" diff --git a/portland/xdg-utils/tests/xdg-mime/t.20-system_mime_install b/portland/xdg-utils/tests/xdg-mime/t.20-system_mime_install index df0bc52..591dc46 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.20-system_mime_install +++ b/portland/xdg-utils/tests/xdg-mime/t.20-system_mime_install @@ -35,12 +35,12 @@ assert_exit 0 xdg-mime install --system "$INPUT_FILE" assert_nostdout assert_nostderr -assert_exit 0 xdg-mime query filetype testfile.xdgtest -assert_stdout testmime.expected -assert_nostderr +# TODO: query requires a running desktop +#assert_exit 0 xdg-mime query filetype testfile.xdgtest +#assert_stdout testmime.expected +#assert_nostderr -# TODO: this is a cleanup step -xdg-mime uninstall --system "$INPUT_FILE" +xdg-mime uninstall --system "$INPUT_FILE" >/dev/null 2>&1 test_result } diff --git a/portland/xdg-utils/tests/xdg-mime/t.21-system_mime_uninstall b/portland/xdg-utils/tests/xdg-mime/t.21-system_mime_uninstall index fc8e6d9..0bbf6dd 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.21-system_mime_uninstall +++ b/portland/xdg-utils/tests/xdg-mime/t.21-system_mime_uninstall @@ -28,8 +28,10 @@ assert_file testfile.xdgtest # Install & verify mime type is installed assert_exit 0 xdg-mime install --system "$INPUT_FILE" -assert_exit 0 xdg-mime query filetype $QUERY_FILE -assert_stdout testmime.expected + +# TODO: query requires a running desktop environment +#assert_exit 0 xdg-mime query filetype $QUERY_FILE +#assert_stdout testmime.expected # Test steps section test_procedure @@ -39,8 +41,8 @@ assert_nostdout assert_nostderr ## Verify uninstall -assert_exit 0 xdg-mime query filetype $QUERY_FILE -assert_stdout "$XDG_TEST_DIR/xdg-mime/data/textplain.expected" +#assert_exit 0 xdg-mime query filetype $QUERY_FILE +#assert_stdout "$XDG_TEST_DIR/xdg-mime/data/textplain.expected" test_result } diff --git a/portland/xdg-utils/tests/xdg-mime/t.23-double_mime_install b/portland/xdg-utils/tests/xdg-mime/t.23-double_mime_install index ea17595..4543965 100755 --- a/portland/xdg-utils/tests/xdg-mime/t.23-double_mime_install +++ b/portland/xdg-utils/tests/xdg-mime/t.23-double_mime_install @@ -2,7 +2,6 @@ ## Include utility functions. . "$XDG_TEST_DIR/include/testassertions.sh" - . "$XDG_TEST_DIR/include/testcontrol.sh" ## Test function @@ -15,7 +14,8 @@ test_start "$FUNCNAME: verify installing an existing mime type is OK" # Dependencies section test_init -set_no_display +require_notroot + use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID" assert_file "$INPUT_FILE" @@ -41,7 +41,7 @@ assert_stdout testmime.expected assert_nostderr # this is a cleanup step -xdg-mime uninstall --user "$INPUT_FILE" +xdg-mime uninstall --user "$INPUT_FILE" >/dev/null 2>&1 test_result } diff --git a/portland/xdg-utils/tests/xdg-screensaver/t.02-screensave_suspend_basic b/portland/xdg-utils/tests/xdg-screensaver/t.02-screensave_suspend_basic index c608715..5515da6 100755 --- a/portland/xdg-utils/tests/xdg-screensaver/t.02-screensave_suspend_basic +++ b/portland/xdg-utils/tests/xdg-screensaver/t.02-screensave_suspend_basic @@ -19,6 +19,7 @@ assert_exit 0 test ! -z "$WINDOWID" echo "disabled" >out.after test_procedure +set -x assert_exit 0 xdg-screensaver suspend "$WINDOWID" assert_nostdout @@ -27,6 +28,7 @@ assert_nostderr assert_exit 0 xdg-screensaver status assert_stdout out.after +sleep 1 # cleanup xdg-screensaver resume "$WINDOWID" >/dev/null 2>&1 diff --git a/portland/xdg-utils/tests/xdg-su/t.su_badpass b/portland/xdg-utils/tests/xdg-su/t.su_badpass index ef98e1f..e99aae8 100755 --- a/portland/xdg-utils/tests/xdg-su/t.su_badpass +++ b/portland/xdg-utils/tests/xdg-su/t.su_badpass @@ -18,7 +18,7 @@ assert_display test_procedure -assert_interactive "Please DO NOT enter the correct password when prompted. (Repeat as necessary)" +assert_interactive "Please make sure there no open password prompt windows.\n\tDO NOT enter the correct password when prompted. (Repeat as necessary)" assert_exit 4 xdg-su -c whoami assert_nostdout diff --git a/portland/xdg-utils/tests/xdg-su/t.su_basic b/portland/xdg-utils/tests/xdg-su/t.su_basic index 6d41626..50212d4 100755 --- a/portland/xdg-utils/tests/xdg-su/t.su_basic +++ b/portland/xdg-utils/tests/xdg-su/t.su_basic @@ -20,14 +20,12 @@ echo "root" >out.expected test_procedure -assert_interactive "Please enter the admin password when prompted." +assert_interactive "Please make sure there no open password prompt windows.\n\tEnter the admin password when prompted." -assert_exit 0 xdg-su -c 'whoami >out.who' -assert_nostdout +assert_exit 0 xdg-su -c 'whoami' +assert_stdout out.expected assert_nostderr -assert_file out.who out.expected - assert_interactive "Were you prompted for the admin password?" y test_result |