tests/editing.t @ 78a1340b652d

Intercept common IO errors exceptions.

When the task directory doesn't exist or when a file can't be read or written,
t.py fails with a full stacktrace exception. This change allows t.py to fail
more gracefully, printing the exception message, the relevant file, and then
exiting with an errorlevel code of 1.

# Non existant directory issue
/home/dereckson/dev/t ] ./t.py -t /nonexistent Lorem ipsum dolor
No such file or directory - /nonexistent/tasks

# File permission issue
/home/dereckson/dev/t ] mkdir test
/home/dereckson/dev/t ] ./t.py -t test Lorem ipsum dolor
/home/dereckson/dev/t ] chmod 000 test/.tasks.done
/home/dereckson/dev/t ] ./t.py -t test Lorem ipsum dolor
Permission denied - test/.tasks.done
author Dereckson
date Sat, 31 Aug 2013 10:31:43 +0200
parents 6af374f52295
children d76f573934d1
Setup:

  $ alias xt="python $TESTDIR/../t.py --task-dir `pwd` --list test"

Replace a task's text (preserving the ID):

  $ xt Sample.
  $ xt
  a - Sample.
  $ xt -e a New sample.
  $ xt
  a - New sample.
  $ xt 'this | that'
  $ xt
  4 - this | that
  a - New sample.
  $ xt -e 4 'this &| that'
  $ xt
  4 - this &| that
  a - New sample.

Sed-style substitution:

  $ xt -e a 's/New/Testing/'
  $ xt
  4 - this &| that
  a - Testing sample.
  $ xt -e 4 '/this &/this /'
  $ xt
  4 - this | that
  a - Testing sample.