packer/packer_test/plugin_tests
Lucas Bajolet 3c8a51bdbf packer_test: split BuildPackerPlugin in build/get
The interface for building a plugin through the test suite was
confusing, as it would build the plugin and return its path, cache the
path for the version built, and return the path regardless if something
was built or not.

While in the current state this is harmless as builds are idempotent,
since the state of the plugin package/module does not change, this will
in the future as we introduce customisation techniques on the plugin's
directory and files, making this double-use potentially dangerous.

Furthermore, the current behaviour is unclear, as the function hides
that caching mechanism, which could come as a surprise for users
attempting to build a plugin for the duration of a test, while the built
plugin is linked to the test suite being run, and not the unit test
being evaluated.

Therefore this commit changes the sequence in which plugins are built
and used. Now the `CompilePlugin` function builds a plugin, and does not
return its path anymore, instead terminating the tests immediately if
they fail.
In normal test usage, a new `GetPluginPath` function is introduced,
which looks-up the path in the suite's cache, failing immediately if
invoked before the plugin is built.

With this change, it is heavily advised to build plugins when
initialising the suite, then in the tests, the GetPluginPath function
should be used to get a plugin's path for interacting with packer
commands.
2024-09-11 16:08:51 -04:00
..
templates packer_test: make packer test suite modular 2024-08-13 14:52:43 -04:00
init_test.go packer_test: split BuildPackerPlugin in build/get 2024-09-11 16:08:51 -04:00
install_test.go packer_test: split BuildPackerPlugin in build/get 2024-09-11 16:08:51 -04:00
loading_test.go packer_test: split BuildPackerPlugin in build/get 2024-09-11 16:08:51 -04:00
plugins_remove_test.go packer_test: add convenience func for invert grep 2024-09-11 16:08:51 -04:00
sample_config.json packer_test: make packer test suite modular 2024-08-13 14:52:43 -04:00
suite_test.go packer_test: rename init function for base suite 2024-09-11 16:08:51 -04:00