[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 941a2e7: todo-mode: don't assume an ordering of tests
From: |
Stephen Berman |
Subject: |
Re: master 941a2e7: todo-mode: don't assume an ordering of tests |
Date: |
Wed, 31 May 2017 16:18:52 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
On Tue, 30 May 2017 20:48:56 -0400 Glenn Morris <address@hidden> wrote:
> Stephen Berman wrote:
>
>> Do you have any idea why our results differ?
>
> I have no idea how todo-default-todo-file can get set to the right value
> for you. (Maybe it's because you have files in ~/.emacs.d/todo, and I
> don't?)
Yes, you're right. That's what I overlooked :(.
>> This backtrace means that the variables todo-current-todo-file,
>> todo-global-current-todo-file, and todo-default-todo-file all evaluated
>> to nil. I don't see how that could happen with the test file, and when
>> I start Emacs with -Q, eval the test file, instrument todo-show, run ert
>> on the test todo-test-item-highlighting, and step through todo-show and
>> todo-check-file, I see that todo-default-todo-file gets assigned
>> todo-test-1.todo from the todo-resources directory as its value.
>
> todo-default-todo-file is a variable defined in 'todo-mode.el'
> Its value is nil
> Original value was "todo-test-1"
>
> It is nil because the test file requires todo-mode before it sets
> todo-directory. It mismatches its default because the default changes
> when todo-directory does. (This seems to me like a not great way for a
> defcustom to behave.)
Yes, this is bad, though outside of a test environment, it seems
unlikely that todo-directory will be changed, doesn't it? Or do you see
a general way (i.e. not just for testing) around this problem?
> So another solution that works for me is to not require todo-mode till
> after you set todo-directory. As the FIXME comment in the test file
> indicates, this setting of global variables isn't a good way to behave.
Yes, that's an ugly workaround and putting it before the require seems
even uglier.
> BTW, the test will hang with a "Do you want to convert.." prompt if an
> old todo file exists in ~/.emacs.d. Maybe make a macro that sets HOME to
> a temporary directory with a copy of the input files, and use it in each
> test.
Thanks, that's a good idea.
[...]
>> could you tell me why you used that
>> specific change to avoid the error?
>
> I looked at it very briefly, and thought: "nothing is telling
> todo-test-item-highlighting which source file to use;
> todo-test-get-archive is the only place in the file that seems to set a
> source file; I'll stick that in; now it works.".
It works, but it's rather rather opaque, since that test has nothing to
do with todo archives. In lieu of a solution t theo todo-directory
problem, which would make the first todo-show in the test work, I've
replaced todo-test-get-archive with a function that displays a category
in either todo-mode or todo-archive-mode. This, plus setting HOME,
eliminates the prompts and the tests pass make check. Unless I can
quickly come up with a better fix, I'll commit this as a reasonable
stop-gap.
Thanks for giving first-aid to the tests, and for your feedback.
Steve Berman