Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file_utils: get_tool_path to always return an absolute path #2193

Merged
merged 2 commits into from Aug 7, 2018

Conversation

sergiusens
Copy link
Collaborator

@sergiusens sergiusens commented Aug 3, 2018

Change get_tool_path to always return an absolute path and fail if
the required command cannot be found.

The unit tests have been adapted to not be path dependent and tests
for retrieving environment dependent paths have been added.

LP: #1785320

Signed-off-by: Sergio Schvezov sergio.schvezov@canonical.com

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on bug reports?
  • If this is a new feature. Have you discussed the design on the forum?
  • Have you successfully run ./runtests.sh static?
  • Have you successfully run ./runtests.sh unit?

@sergiusens sergiusens force-pushed the get-tool-path branch 2 times, most recently from 8708b9a to 1372f4a Compare August 4, 2018 12:06
Change get_tool_path to always return an absolute path and fail if
the required command cannot be found.

The unit tests have been adapted to not be path dependent and tests
for retrieving environment dependent paths have been added.

LP: #1785320

Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
@codecov-io
Copy link

codecov-io commented Aug 4, 2018

Codecov Report

Merging #2193 into master will decrease coverage by 0.04%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2193      +/-   ##
==========================================
- Coverage   91.22%   91.17%   -0.05%     
==========================================
  Files         201      201              
  Lines       12909    12912       +3     
  Branches     1913     1913              
==========================================
- Hits        11776    11773       -3     
- Misses        770      772       +2     
- Partials      363      367       +4
Impacted Files Coverage Δ
snapcraft/internal/errors.py 99.54% <100%> (ø) ⬆️
snapcraft/internal/lifecycle/_packer.py 83.01% <100%> (-0.32%) ⬇️
snapcraft/file_utils.py 95.12% <85.71%> (-2.44%) ⬇️
snapcraft/internal/pluginhandler/_runner.py 88.88% <0%> (-0.86%) ⬇️
snapcraft/internal/elf.py 82.84% <0%> (-0.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff266dd...d7cd1b3. Read the comment docs.


fmt = (
"A tool snapcraft depends on could not be found: {command_name!r}.\n"
"Ensure the tool is installed and available, and try again."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a workaround, but in reality, for all the use-cases of this function so far (e.g. xdelta3, mksquashfs, etc.) all of these tools should ALWAYS be found, and if they're not, it's a bug we should know about. Worth adding "please log a bug" to this?

@@ -79,64 +77,6 @@ def test_push_a_snap(self):
)
mock_upload.assert_called_once_with("basic", self.snap_file)

def test_push_a_snap_running_from_snap(self):
Copy link
Contributor

@kyrofa kyrofa Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems useful, is it duplicated somewhere? This comment applies to all the tests being removed, here. There has been a lot of breakage here historically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We clarified this offline: the tests covering get_tool_path here cover most of what is removed here. We need a suite that runs in docker to cover everything, which we can introduce later.

@sergiusens
Copy link
Collaborator Author

That last change enables this -> https://asciinema.org/a/hGSsKKhmPSPA92l8LyVDBAiBg

Copy link
Contributor

@kyrofa kyrofa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thank you!

@sergiusens
Copy link
Collaborator Author

spread 17.10 tests failed, ignoring those.

@sergiusens sergiusens merged commit f62504d into canonical:master Aug 7, 2018
@sergiusens sergiusens deleted the get-tool-path branch August 7, 2018 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants