Further preparing the testing infrastructure for base image tarballs - #475
Further preparing the testing infrastructure for base image tarballs#475kanavin wants to merge 1 commit into
Conversation
t-8ch
left a comment
There was a problem hiding this comment.
Both changes look good in general.
It would be nice to have users for this new code, to have at least a bit of testing.
So the path changes can go in when there are some unittests for them.
The test fixture I would like to merge together with its users.
|
|
||
| @pytest.fixture | ||
| def project_name(request, build_dir): | ||
| from elbepack.treeutils import etree |
| def project_name(request, build_dir): | ||
| from elbepack.treeutils import etree | ||
| xml = etree(build_dir / 'source.xml') | ||
| return xml.text('project/name') |
There was a problem hiding this comment.
Looking at this again, it could be a regular function called by the interested tests.
They have access to the build directory anyways.
This would make things a bit less magic.
| return self.tar.getmember('.' + self._path) | ||
|
|
||
| def read_bytes(self): | ||
| return self.tar.extractfile('.' + self._path).read() |
There was a problem hiding this comment.
Shouldn't this close the object returned by .extractfile()?
| return self.tar.extractfile('.' + self._path).read() | ||
|
|
||
| def exists(self): | ||
| return ('.' + self._path) in self.tar.getnames() |
There was a problem hiding this comment.
This should reuse self._info() and catch the KeyError.
The current code will read all names.
| ]) | ||
|
|
||
|
|
||
| class TarballPath(Path): |
There was a problem hiding this comment.
A unittest for this would be nice.
This allows looking into root filesystems that are packaged as tarballs (in addition to an implementation that looks into disk images using guestfs), and is useful for testing the content of base images. Note that this is a 'lazy' implementation; I have added only the methods that are actually called by image validation tests. More can be added if/when needed. Also, tarballs do not necessarily have normalized paths (e.g. there can be a './' prefix), so this needs to be accounted for in member lookups and iterations. The test also checks for both options (dir1/ and ./dir2). Signed-off-by: Alexander Kanavin <alex@linutronix.de>
9e5a7a9 to
8caf93e
Compare
|
Alright. This pull request now only adds tarball path implementation and tests for it. |
|
Applied, thanks. Please note: I changed the constructors to match the other patch class in |
Don't forget to run pytest after you tweak :) |
There are two commits here: one is adding a test fixture to pass the project name into tests, so they know what is being tested, another adds a tarball implementation for inspecting the root filesystems. Please see the commit messages for details.