Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Changes
0.38.0 (*unreleased*)
======================

- fix #362: identify the task when ``config_changed`` cannot JSON-serialize
its configuration, preserving the original error as the exception cause.
- site/docs: landing page is now generated by sphinx (``doc/index.rst`` using ``sphinx-design``),
replacing the hand-written ``doc/index.html`` and its vendored
bootstrap / font-awesome / owl-carousel assets.
Expand Down
7 changes: 6 additions & 1 deletion doit/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ def configure_task(self, task):

def __call__(self, task, values):
"""return True if config values are UNCHANGED"""
self.config_digest = self._calc_digest()
try:
self.config_digest = self._calc_digest()
except TypeError as error:
msg = (f"Task '{task.name}': config_changed could not serialize "
f"configuration: {error}")
raise TypeError(msg) from error
last_success = values.get('_config_changed')
if last_success is None:
return False
Expand Down
15 changes: 15 additions & 0 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import datetime
import json
from pathlib import Path
import operator
import unittest
from sys import executable
Expand Down Expand Up @@ -55,6 +56,20 @@ class NotValid(object): pass
uptodate = tools.config_changed(NotValid())
self.assertRaises(Exception, uptodate, None, None)

def test_unserializable_config_identifies_task(self):
for config in ({'source': Path('input')},
{'nested': {'source': Path('input')}},
{Path('input'): 'value'}):
with self.subTest(config=config):
check = tools.config_changed(config)
current_task = task.Task('build:assets', None, uptodate=[check])
with self.assertRaisesRegex(
TypeError, "build:assets.*config_changed") as raised:
check(current_task, {})
self.assertIsInstance(raised.exception.__cause__, TypeError)
self.assertIn('Path', str(raised.exception.__cause__))
self.assertIsNone(check.config_digest)

def test_string(self):
ua = tools.config_changed('a')
ub = tools.config_changed('b')
Expand Down