Changeset 1220 for trunk


Ignore:
Timestamp:
Oct 13, 2010, 6:10:52 AM (11 years ago)
Author:
Peter Johansson
Message:

closes #480. Quote files with 'file' (same style as subversion). Add a test to check output of some failures and use variable GREP rather than hardcoding grep.

Location:
trunk
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/Parameter.cc

    r1119 r1220  
    9797      check_existence(root_.value());
    9898      check_readable(root_.value());
     99      check_is_dir(root_.value());
    99100      chdir(root_.value());
    100101      root_.value(pwd());
     
    116117      if (S_ISDIR(nodestat.st_mode)) {
    117118        std::stringstream ss;
    118         ss << cmd_.program_name() << ": `" << config_file_.value()
     119        ss << cmd_.program_name() << ": '" << config_file_.value()
    119120           << "' is a directory";
    120121        throw yat::utility::cmd_error(ss.str());
     
    130131      return;
    131132    std::stringstream ss;
    132     ss << cmd_.program_name() << ": cannot stat `" << path << "': "
     133    ss << cmd_.program_name() << ": cannot stat '" << path << "': "
    133134       << strerror(errno);
    134135    throw yat::utility::cmd_error(ss.str());
     
    136137
    137138 
     139  void Parameter::check_is_dir(std::string path) const
     140  {
     141    if (node_exist(path)) {
     142      struct stat buf;
     143      stat(path.c_str(), &buf);
     144      if (S_ISDIR(buf.st_mode))
     145        return;
     146    }
     147    std::stringstream ss;
     148    ss << cmd_.program_name() << ": '" << path << "': "
     149       << strerror(errno);
     150    throw yat::utility::cmd_error(ss.str());
     151  }
     152
     153 
    138154  void Parameter::check_readable(std::string path) const
    139155  {
     
    141157      return;
    142158    std::stringstream ss;
    143     ss << cmd_.program_name() << ": cannot open `" << path << "': "
     159    ss << cmd_.program_name() << ": cannot open '" << path << "': "
    144160       << strerror(errno);
    145161    throw yat::utility::cmd_error(ss.str());
  • trunk/bin/svndigestParameter.cc

    r1186 r1220  
    8585    std::string save_wd = pwd();
    8686
    87     // check root but not if -g option given
    8887    if (!generate_config()) {
    8988      // check target (only if we write report)
     
    9190        check_existence(target_.value());
    9291        check_readable(target_.value());
     92        check_is_dir(target_.value());
    9393        std::string base_root = file_name(root());
    9494        std::string path = concatenate_path(target_.value(),base_root);
    9595        if (access_rights(target_.value(), "w")) {
    9696          std::stringstream ss;
    97           ss << "svndigest: cannot create directory `" << path
     97          ss << "svndigest: cannot create directory '" << path
    9898             << "': " << strerror(errno);
    9999          throw yat::utility::cmd_error(ss.str());
     
    101101        if (node_exist(path) && !force()) {
    102102          std::stringstream ss;
    103           ss << "svndigest: cannot create directory `" << path << "' "
     103          ss << "svndigest: cannot create directory '" << path << "' "
    104104             << strerror(EEXIST);
    105105          throw yat::utility::cmd_error(ss.str());
  • trunk/lib/File.cc

    r1197 r1220  
    205205  {
    206206    if (verbose)
    207       std::cout << "Parsing " << path_ << std::endl;
     207      std::cout << "Parsing '" << path_ << "'" << std::endl;
    208208    stats_.reset();
    209209    std::string cache_dir = directory_name(path()) + std::string(".svndigest/");
     
    343343      return;
    344344    if (verbose)
    345       std::cout << "Updating copyright in " << path_ << std::endl;
     345      std::cout << "Updating copyright in '" << path_ << "'" << std::endl;
    346346    update_copyright(new_block, start_line, end_line);
    347347  }
  • trunk/lib/Node.cc

    r1186 r1220  
    203203      return;
    204204    if (verbose)
    205       std::cout << "Printing output for " << path_ << std::endl;
     205      std::cout << "Printing output for '" << path_ << "'" << std::endl;
    206206    const SVNlog& log = this->log();
    207207    typedef std::map<std::string, Stats*>::const_iterator iter;
  • trunk/test/Makefile.am

    r1187 r1220  
    3939distributed_TESTS += config3_test.sh
    4040distributed_TESTS += copyright2_test.sh
     41distributed_TESTS += error_test.sh
    4142distributed_TESTS += repo_status_test.sh
    4243distributed_TESTS += repo_test.sh
  • trunk/test/cmd_format_test.sh

    r1092 r1220  
    2727SVNDIGEST_run 1 -f --format=banana
    2828test -s stderr || exit_fail
    29 grep 'invalid argument.*banana.*format' stderr || exit_fail
     29$GREP 'invalid argument.*banana.*format' stderr || exit_fail
    3030
    3131SVNDIGEST_run 0 -g --format=svg --anchor-format=svg
    32 grep 'format = svg' stdout || exit_fail
    33 grep 'anchor_format = svg' stdout || exit_fail
     32$GREP 'format = svg' stdout || exit_fail
     33$GREP 'anchor_format = svg' stdout || exit_fail
    3434
    3535exit_success;
  • trunk/test/config2_test.sh

    r1092 r1220  
    3636
    3737SVNDIGEST_run 1 -g --config-file tmp_config
    38 grep 'unknown format.* apple' stderr || exit_fail
     38$GREP 'unknown format.* apple' stderr || exit_fail
    3939
    4040exit_success
  • trunk/test/config3_test.sh

    r1092 r1220  
    2828SVNDIGEST_run 0 -g --config-file /dev/null
    2929SVNDIGEST_run 1 -g --config-file .
    30 grep 'is a directory' stderr || exit_fail
     30$GREP 'is a directory' stderr || exit_fail
    3131
    3232exit_success
  • trunk/test/init.sh.in

    r1153 r1220  
    5454test -z "$srcdir" && srcdir="@srcdir@";
    5555test -z "$SVN" && SVN=svn;
     56test -z "$GREP" && GREP=@GREP@;
    5657
    5758# some helpful derived variables
  • trunk/test/svncopyright_test.sh

    r1092 r1220  
    3131done
    3232
    33 $SVNCOPYRIGHT --version | head -n 1 | grep svncopyright || exit_fail
     33$SVNCOPYRIGHT --version | head -n 1 | $GREP svncopyright || exit_fail
    3434
    3535exit_success
Note: See TracChangeset for help on using the changeset viewer.