Description[recipe_engine] Fix a couple path-related bugs.
Previously if a recipe never ended up importing the 'recipe_engine/path' module,
attempts to use any Path object would crash. The resason for this is that the
path module and the engine are convolutedly interconnected by the to_string_fn
in config_types. The to_string_fn essentially must have a reference to the
PathApi object, and so the set_tostring_fn is called from PathApi's __init__
method. If the recipe never ends up loading this module transitively, but then
acquires a Path object (e.g. via api.resource()), attempting to stringify the
Path will crash the recipe. This poor api boundary needs to be fixed, but the
refactor looked pretty severe when I attempted it, so we paper over the crash
for now by essentially always loading the path module when creating the api for
the recipe. If the path module is already in the recipe's DEPS, the additional
load is a no-op. This extra module does not get attached to the recipe's api
object, so for the recipe to actually utilize the PathApi module, it still has
to import it via DEPS.
Also fix the appearance of simulated resource paths to be more in line with
the existing RECIPE_MODULE notation:
RECIPE[repo_name/recipe_name].resources/ becomes
RECIPE[repo_name::recipe_name].resources/
And
RECIPE[repo_name/../recipe_modules/module_name/example].resource/ becomes
RECIPE[repo_name::module_name:example].resources/
Lastly, add a small optimization to Path.join when the arguments are
empty.
R=martiniss@chromium.org, phajdan.jr@chromium.org
BUG=
Review-Url: https://codereview.chromium.org/2669033007
Committed: https://github.com/luci/recipes-py/commit/37a1da981d744246d14a2c2e6fac554703ea4b1b
Patch Set 1 #Patch Set 2 : Improve comment #
Total comments: 4
Patch Set 3 : Make unittests take dependency on recipe_engine #
Total comments: 2
Patch Set 4 : Fix remainder of presubmit tests #
Total comments: 2
Messages
Total messages: 17 (5 generated)
|