Skip to content

Commit ea71995

Browse files
committed
Merge basic test from @nadavelkabets ament#587
Co-authored-by: R. Kent James <[email protected]> Co-authored-by Nadav Elkabets <[email protected]> Signed-off-by: R Kent James <[email protected]>
1 parent a3c6de0 commit ea71995

File tree

6 files changed

+51
-4
lines changed

6 files changed

+51
-4
lines changed

ament_cmake_python_test/test/COLCON_IGNORE

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
project(ament_python_test_package)
4+
5+
find_package(ament_cmake_core REQUIRED)
6+
7+
find_package(ament_cmake_python REQUIRED)
8+
9+
ament_python_install_package(${PROJECT_NAME})
10+
11+
ament_package()

ament_cmake_python_test/test/ament_python_test_package/ament_python_test_package/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Bar:
2+
def __init__() -> None:
3+
pass
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>ament_python_test_package</name>
5+
<version>0.0.0</version>
6+
<description>Minimal python package to test python cmake install</description>
7+
8+
<maintainer email="[email protected]">Nadav Elkabets</maintainer>
9+
10+
<license>Apache License 2.0</license>
11+
12+
<buildtool_depend>ament_cmake_core</buildtool_depend>
13+
<build_depend>ament_cmake_python</build_depend>
14+
15+
<buildtool_export_depend>ament_cmake_core</buildtool_export_depend>
16+
17+
<export>
18+
<build_type>ament_cmake</build_type>
19+
</export>
20+
</package>

ament_cmake_python_test/test/build_with_colcon.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Test building python packages with colcon
33
"""
44

5+
import filecmp
56
import os
67
from pathlib import Path
78
import shutil
@@ -17,6 +18,7 @@
1718

1819
INSTALL_BASE = 'install_test'
1920
BUILD_BASE = 'build_test'
21+
AMENT_PYTHON_TEST_PACKAGE = "ament_python_test_package"
2022

2123
DEFAULT_OPTIONS = {
2224
'name': 'SET_ME',
@@ -76,7 +78,7 @@
7678
]
7779

7880

79-
def test_from_template():
81+
def not_test_from_template():
8082
print(f"PWD: {PWD}")
8183

8284
# delete any existing package directory
@@ -132,11 +134,22 @@ def test_from_template():
132134
template = Template(Path.read_text(template_dir / 'CMakeLists.txt.jinja'))
133135
Path.write_text(package_dir / 'CMakeLists.txt', template.render(options))
134136

135-
do_build_package(options['name'], options, base_prefix=PWD)
137+
do_build_package(options['name'], options, base_prefix=PWD, source_prefix=PWD / 'packages')
136138
do_test_package(options['name'], options)
137139

138140

139-
def do_build_package(package_name, options=None, base_prefix=SOURCE_DIR / 'test'):
141+
def test_ament_python_test_package() -> None:
142+
do_build_package(AMENT_PYTHON_TEST_PACKAGE, base_prefix=PWD, source_prefix=SOURCE_DIR / 'test')
143+
assert not filecmp.dircmp(
144+
SOURCE_DIR / 'test' / AMENT_PYTHON_TEST_PACKAGE,
145+
PWD / INSTALL_BASE / AMENT_PYTHON_TEST_PACKAGE
146+
).diff_files, "All files in ament_python_test_package should match after install"
147+
148+
149+
def do_build_package(
150+
package_name, options=None,
151+
base_prefix=SOURCE_DIR / 'test',
152+
source_prefix=None):
140153
if options and 'build' in options:
141154
build_options = options['build']
142155
elif options and 'symlink_install' in options and options['symlink_install']:
@@ -146,7 +159,7 @@ def do_build_package(package_name, options=None, base_prefix=SOURCE_DIR / 'test'
146159

147160
print(f"Building package {package_name} with colcon options: {build_options}")
148161
build_command = ['colcon', 'build',
149-
'--base-paths', base_prefix / 'packages' / package_name,
162+
'--base-paths', source_prefix / package_name,
150163
'--build-base', BUILD_BASE,
151164
'--install-base', INSTALL_BASE]
152165
if build_options:

0 commit comments

Comments
 (0)