# # add_file "tests/t_unreadable_MT.at" # # patch "ChangeLog" # from [e284e1c44121ff90605022be1b206620fc0c83bb] # to [d0c85321f8c992b22a49584e99ff4a2c8d6068d1] # # patch "app_state.cc" # from [a97a7bf9127e66d1d8e7d0577cad1ed86a0dc42f] # to [99273877068314cdc8d24e06032a022e72e01352] # # patch "tests/README" # from [fdbb3d9f63642092343e0ea58b7ee937f910103a] # to [b784213ac7f9fd2090fdf3209083be4f865a6ce7] # # patch "tests/t_unreadable_MT.at" # from [] # to [f2ab28000f863da0a023415d2b0d13b583f6f6ca] # # patch "testsuite.at" # from [8b6d004d8d564cb6031afc039296db76e33c8c54] # to [00f75eef6202608c3cdfb512a2ef98014dda907a] # # patch "work.cc" # from [f7655d638fff45530c1b309ade1feb2d0a057ee3] # to [982c0c3881f3fd5aed780b115cb777c6c73b023c] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,13 @@ +2005-05-08 Timothy Brownawell + + * app_state.cc: {read,write}_options now print a warning instead of + failing on unreadable/unwritable MT/options . + * tests/t_unreadable_MT.at: add matching test + * testsuite.at: add test + * tests/README: Mention that new tests must be added to testsuite.at + * work.cc: (get_revision_id) Friendlier error message for + unreadable MT/revision . + 2005-05-08 Matthew Gregan * monotone.texi: Right words, wrong order. --- app_state.cc +++ app_state.cc @@ -362,13 +362,19 @@ { local_path o_path; get_options_path(o_path); - - if (file_exists(o_path)) + try { - data dat; - read_data(o_path, dat); - read_options_map(dat, options); + if (file_exists(o_path)) + { + data dat; + read_data(o_path, dat); + read_options_map(dat, options); + } } + catch(std::exception & e) + { + W(F("Failed to read options file %s") % o_path); + } } void @@ -376,8 +382,14 @@ { local_path o_path; get_options_path(o_path); - - data dat; - write_options_map(dat, options); - write_data(o_path, dat); + try + { + data dat; + write_options_map(dat, options); + write_data(o_path, dat); + } + catch(std::exception & e) + { + W(F("Failed to write options file %s") % o_path); + } } --- tests/README +++ tests/README @@ -19,6 +19,7 @@ --------------- - Copy and paste is your friend :) - TODO: need more here... +- Remember to add a line at the end of testsuite.at Template for a test (name t_.at --- tests/t_unreadable_MT.at +++ tests/t_unreadable_MT.at @@ -0,0 +1,13 @@ +# -*- Autoconf -*- + +AT_SETUP([do not fail on unreadable MT/options]) + +MONOTONE_SETUP + +AT_CHECK(chmod a-rwx MT/) + +AT_CHECK(monotone --norc, [0], [ignore], [ignore]) + +AT_CHECK(chmod u+rwx MT/) + +AT_CLEANUP --- testsuite.at +++ testsuite.at @@ -334,55 +334,32 @@ m4_define([MONOTONE3], MONOTONE --db=test3.db) m4_define([NETSYNC_KILL], [ -# kill last seen pid if there is no pid file (needed for cases where -# NETSYNC_KILL{,HARD} is used more than once on a single process. -if test -e monotone_at.pid; then - mt_pid=`cat monotone_at.pid` -fi if test "$OSTYPE" == "msys"; then - # we can't use MingW's kill because it can't target Win32 pids. - pskill=`which pskill` - if test $pskill && test -x $pskill; then - $pskill $mt_pid 2>/dev/null - else - ps | awk -- '{p=$NF;a=1;if(p=="COMMAND")next;pp=split(p,ps,"/");if(ps[[pp]]=="monotone")system("kill " $a);}' - fi + ps |awk -- '{p=$NF;a=1;if(p=="COMMAND")next;pp=split(p,ps,"/");if(ps[[pp]]=="monotone")system("kill " $a);}' + # MinGW has no killall. The weird a=1 thing is to avoid autotest treating $1 as its own parameter else - kill $mt_pid 2>/dev/null + killall monotone 2>/dev/null fi -rm -f monotone_at.pid 2>/dev/null ]) m4_define([NETSYNC_KILLHARD], [ -# kill last seen pid if there is no pid file (needed for cases where -# NETSYNC_KILL{,HARD} is used more than once on a single process. -if test -e monotone_at.pid; then - mt_pid=`cat monotone_at.pid` -fi if test "$OSTYPE" == "msys"; then - # we can't use MingW's kill because it can't target Win32 pids. - pskill=`which pskill` - if test $pskill && test -x $pskill; then - $pskill $mt_pid 2>/dev/null - else - ps | awk -- '{p=$NF;a=1;if(p=="COMMAND")next;pp=split(p,ps,"/");if(ps[[pp]]=="monotone")system("kill -KILL" $a);}' - fi + ps |awk -- '{p=$NF;a=1;if(p=="COMMAND")next;pp=split(p,ps,"/");if(ps[[pp]]=="monotone")system("kill -KILL " $a);}' else - kill -KILL $mt_pid 2>/dev/null + killall -KILL monotone 2>/dev/null fi -rm -f monotone_at.pid 2>/dev/null ]) # run as NETSYNC_SERVE_N_START(2|3, collection name) # note that NETSYNC_SERVE_START is _not_ a special case of this macro. m4_define([NETSYNC_SERVE_N_START], [ NETSYNC_KILLHARD -MONOTONE --db=test$1.db --rcfile=netsync.lua --pid-file=monotone_at.pid serve localhost:$_PORT $2 & +MONOTONE --db=test$1.db --rcfile=netsync.lua serve localhost:$_PORT $2 & sleep 4 ]) # run as NETSYNC_SERVE_START(collection name) m4_define([NETSYNC_SERVE_START], [ NETSYNC_KILLHARD -MONOTONE --rcfile=netsync.lua --pid-file=monotone_at.pid serve localhost:$_PORT $1 & +MONOTONE --rcfile=netsync.lua serve localhost:$_PORT $1 & sleep 4 ]) # run as NETSYNC_SERVE_STOP @@ -634,3 +611,4 @@ m4_include(tests/t_rcfile_stdin.at) m4_include(tests/t_monotone_up.at) m4_include(tests/t_drop_vs_patch_rename.at) +m4_include(tests/t_unreadable_MT.at) --- work.cc +++ work.cc @@ -382,7 +382,14 @@ data c_data; L(F("loading revision id from %s\n") % c_path); - read_data(c_path, c_data); + try + { + read_data(c_path, c_data); + } + catch(std::exception & e) + { + N(false, F("Problem with working directory: %s is unreadable") % c_path); + } c = revision_id(remove_ws(c_data())); }