west/tests
Martí Bolívar a95f530751 configuration: convert a RuntimeError to a MalformedConfig
Commit c757d6650f
("configuration: add Configuration class") was part of a general
re-work of how configuration file handling went.

As part of this change, an internal _whence() method was added, which
returns a list of configuration file paths on the file system for a
given ConfigFile enumerator. _whence() is currently erroring out with
a RuntimeError() when a local configuration file is requested, but not
found.

This breaks error handling in some cases.

For example, consider a flow like this:

  # This command fails for some reason, leaving a .west
  # directory but no .west/config
  $ west init

  # This command bombs out with RuntimeError: a topdir is
  # found, so main.py tries to create a Manifest, which asks
  # for the 'manifest.path' configuration option from the
  # local file, which ... boom
  $ west list

It would be better to raise MalformedConfig from here instead. This
lets higher layers handle this error better. In the above case,
we now get this instead:

  $ west list
  FATAL ERROR: can't load west manifest
    local configuration file not found

This is clearly better. There are probably still some other error
handling edge cases that aren't being handled properly as a result of
this change, but I'd be curious to know how many of them this fixes.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-05-16 07:43:48 -07:00
..
manifests tests: fix invalid_duplicate_name.yaml 2022-03-25 14:02:32 -07:00
conftest.py tests: adjust create_repo() to keep working on OLDER git 2021-08-05 12:17:33 -07:00
test_commands.py commands: fix git version detection on macOS 2021-05-03 14:37:10 -07:00
test_config.py configuration: fix WEST_CONFIG_LOCAL precedence 2021-05-26 06:25:40 -07:00
test_help.py tests: test_help: python implementation detail tweak 2022-03-18 10:59:14 -07:00
test_main.py tests: ensure we're run via tox 2021-02-10 09:06:29 -08:00
test_manifest.py configuration: convert a RuntimeError to a MalformedConfig 2022-05-16 07:43:48 -07:00
test_project.py treewide: overhaul manifest path handling 2022-03-25 14:02:32 -07:00