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

minor fixes for qmake plugin #2

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion craft_parts/plugins/qmake_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def get_build_commands(self) -> List[str]:
] + options.qmake_parameters

if options.qmake_project_file:
qmake_configure_command.append(str(self._part_info.part_src_dir / options.qmake_project_file))
qmake_configure_command.append(
str(self._part_info.part_src_dir / options.qmake_project_file)
)
else:
qmake_configure_command.append(str(self._part_info.part_src_dir))

Expand Down
50 changes: 22 additions & 28 deletions tests/unit/plugins/test_qmake_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,19 @@ def test_get_build_snaps(self, setup_method_fixture, new_dir):
plugin = setup_method_fixture(new_dir)
assert plugin.get_build_snaps() == set()

def test_get_build_packages_default(self, setup_method_fixture, new_dir):
plugin = setup_method_fixture(new_dir)
assert plugin.get_build_packages() == {
"g++",
"make",
"qt5-qmake",
}

def test_get_build_packages_qt6(self, setup_method_fixture, new_dir):
plugin = setup_method_fixture(new_dir, properties={"qmake_major_version": 6})

assert plugin.get_build_packages() == {
"g++",
"make",
"qmake6",
}
@pytest.mark.parametrize(
("properties", "build_packages"),
[
({}, {"g++", "make", "qt5-qmake"}),
({"qmake-major-version": 5}, {"g++", "make", "qt5-qmake"}),
({"qmake-major-version": 6}, {"g++", "make", "qmake6"}),
],
)
def test_get_build_packages(
self, setup_method_fixture, new_dir, properties, build_packages
):
plugin = setup_method_fixture(new_dir, properties=properties)
assert plugin.get_build_packages() == build_packages

def test_get_build_environment_default(self, setup_method_fixture, new_dir):
plugin = setup_method_fixture(new_dir)
Expand All @@ -76,7 +73,7 @@ def test_get_build_environment_default(self, setup_method_fixture, new_dir):
}

def test_get_build_environment_qt6(self, setup_method_fixture, new_dir):
plugin = setup_method_fixture(new_dir, properties={"qmake_major_version": 6})
plugin = setup_method_fixture(new_dir, properties={"qmake-major-version": 6})

assert plugin.get_build_environment() == {
"QT_SELECT": "qt6",
Expand All @@ -86,29 +83,29 @@ def test_get_build_commands_default(self, setup_method_fixture, new_dir):
plugin = setup_method_fixture(new_dir)

assert plugin.get_build_commands() == [
'qmake QMAKE_CFLAGS+="${CFLAGS:-}" QMAKE_CXXFLAGS+="${CXXFLAGS:-}" QMAKE_LFLAGS+="${LDFLAGS:-}" ',
f'qmake QMAKE_CFLAGS+="${{CFLAGS:-}}" QMAKE_CXXFLAGS+="${{CXXFLAGS:-}}" QMAKE_LFLAGS+="${{LDFLAGS:-}}" {plugin._part_info.part_src_dir}',
f"env -u CFLAGS -u CXXFLAGS make -j{plugin._part_info.parallel_build_count}",
f"make install INSTALL_ROOT={plugin._part_info.part_install_dir}",
]

def test_get_build_commands_qt6(self, setup_method_fixture, new_dir):
plugin = setup_method_fixture(new_dir, properties={"qmake_major_version": 6})
plugin = setup_method_fixture(new_dir, properties={"qmake-major-version": 6})

assert plugin.get_build_commands() == [
'qmake6 QMAKE_CFLAGS+="${CFLAGS:-}" QMAKE_CXXFLAGS+="${CXXFLAGS:-}" QMAKE_LFLAGS+="${LDFLAGS:-}" ',
f'qmake6 QMAKE_CFLAGS+="${{CFLAGS:-}}" QMAKE_CXXFLAGS+="${{CXXFLAGS:-}}" QMAKE_LFLAGS+="${{LDFLAGS:-}}" {plugin._part_info.part_src_dir}',
f"env -u CFLAGS -u CXXFLAGS make -j{plugin._part_info.parallel_build_count}",
f"make install INSTALL_ROOT={plugin._part_info.part_install_dir}",
]

def test_get_build_commands_qmake_project_file(self, setup_method_fixture, new_dir):
plugin = setup_method_fixture(
new_dir, properties={"qmake_project_file": "hello.pro"}
new_dir, properties={"qmake-project-file": "hello.pro"}
)

assert plugin.get_build_commands() == [
'qmake QMAKE_CFLAGS+="${CFLAGS:-}" QMAKE_CXXFLAGS+="${CXXFLAGS:-}" ',
'QMAKE_LFLAGS+="${LDFLAGS:-}" ',
f'{plugin._part_info.part_src_dir}/hello.pro" ',
'qmake QMAKE_CFLAGS+="${CFLAGS:-}" QMAKE_CXXFLAGS+="${CXXFLAGS:-}" '
'QMAKE_LFLAGS+="${LDFLAGS:-}" '
f"{plugin._part_info.part_src_dir}/hello.pro",
f"env -u CFLAGS -u CXXFLAGS make -j{plugin._part_info.parallel_build_count}",
f"make install INSTALL_ROOT={plugin._part_info.part_install_dir}",
]
Expand All @@ -121,10 +118,7 @@ def test_get_build_commands_qmake_parameters(self, setup_method_fixture, new_dir
plugin = setup_method_fixture(new_dir, {"qmake-parameters": qmake_parameters})

assert plugin.get_build_commands() == [
(
'qmake QMAKE_CFLAGS+="${CFLAGS:-}" QMAKE_CXXFLAGS+="${CXXFLAGS:-}" QMAKE_LFLAGS+="${LDFLAGS:-}" ',
f'{"".join(qmake_parameters)}',
),
f'qmake QMAKE_CFLAGS+="${{CFLAGS:-}}" QMAKE_CXXFLAGS+="${{CXXFLAGS:-}}" QMAKE_LFLAGS+="${{LDFLAGS:-}}" QMAKE_LIBDIR+=/foo {plugin._part_info.part_src_dir}',
f"env -u CFLAGS -u CXXFLAGS make -j{plugin._part_info.parallel_build_count}",
f"make install INSTALL_ROOT={plugin._part_info.part_install_dir}",
]
Expand Down
Loading