Skip to content

Commit

Permalink
cli: accommodate new dependency check
Browse files Browse the repository at this point in the history
  • Loading branch information
layday committed Nov 8, 2020
1 parent a7fc96a commit 7af11c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/build/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ def _build_in_current_env(builder, outdir, distributions, skip_dependencies=Fals
if not skip_dependencies:
missing = builder.check_dependencies(dist)
if missing:
_error('Missing dependencies:' + ''.join(['\n\t' + dep for dep in missing]))
_error(
'Unsatisfied dependencies:'
+ ''.join(
[
'\n\t' + (build_dep if build_dep == other_dep else '{}: {}'.format(build_dep, other_dep))
for build_dep, other_dep in missing
]
)
)

builder.build(dist, outdir)

Expand Down
14 changes: 10 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,22 @@ def test_build_no_isolation_check_deps_empty(mocker, test_flit_path):
build_cmd.assert_called_with('sdist', '.')


def test_build_no_isolation_with_check_deps(mocker, test_flit_path):
# check_dependencies = ['something']
@pytest.mark.parametrize(
['unmet_dependencies', 'output'],
[
([('something', 'something')], '\n\tsomething'),
([('something', 'something'), ('something', 'something_else')], '\n\tsomething\n\tsomething: something_else'),
],
)
def test_build_no_isolation_with_check_deps(mocker, test_flit_path, unmet_dependencies, output):
error = mocker.patch('build.__main__._error')
build_cmd = mocker.patch('build.ProjectBuilder.build')
mocker.patch('build.ProjectBuilder.check_dependencies', return_value=['something'])
mocker.patch('build.ProjectBuilder.check_dependencies', return_value=unmet_dependencies)

build.__main__.build_package(test_flit_path, '.', ['sdist'], isolation=False)

build_cmd.assert_called_with('sdist', '.')
error.assert_called_with('Missing dependencies:\n\tsomething')
error.assert_called_with('Unsatisfied dependencies:' + output)


@pytest.mark.isolated
Expand Down

0 comments on commit 7af11c6

Please sign in to comment.