-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
- Loading branch information
Showing
7 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# goal definition | ||
bool bool_value | ||
byte byte_value | ||
char char_value | ||
float32 float32_value | ||
float64 float64_value | ||
int8 int8_value | ||
uint8 uint8_value | ||
int16 int16_value | ||
uint16 uint16_value | ||
int32 int32_value | ||
uint32 uint32_value | ||
int64 int64_value | ||
uint64 uint64_value | ||
string string_value | ||
--- | ||
# result definition | ||
bool ok | ||
--- | ||
# feedback definition | ||
int32[] sequence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// generated from rosidl_adapter/resource/action.idl.em | ||
// with input from test_msgs/action/Test.action | ||
// generated code does not contain a copyright notice | ||
|
||
|
||
module test_msgs { | ||
module action { | ||
@verbatim (language="comment", text= | ||
" goal definition") | ||
struct Test_Goal { | ||
boolean bool_value; | ||
|
||
octet byte_value; | ||
|
||
uint8 char_value; | ||
|
||
float float32_value; | ||
|
||
double float64_value; | ||
|
||
int8 int8_value; | ||
|
||
uint8 uint8_value; | ||
|
||
int16 int16_value; | ||
|
||
uint16 uint16_value; | ||
|
||
int32 int32_value; | ||
|
||
uint32 uint32_value; | ||
|
||
int64 int64_value; | ||
|
||
uint64 uint64_value; | ||
|
||
string string_value; | ||
}; | ||
struct Test_Result { | ||
@verbatim (language="comment", text= | ||
" result definition") | ||
boolean ok; | ||
}; | ||
struct Test_Feedback { | ||
@verbatim (language="comment", text= | ||
" feedback definition") | ||
sequence<int32> sequence; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// generated from rosidl_adapter/resource/msg.idl.em | ||
// with input from test_msgs/msg/Test.msg | ||
// generated code does not contain a copyright notice | ||
|
||
|
||
module test_msgs { | ||
module msg { | ||
struct Test { | ||
boolean bool_value; | ||
|
||
octet byte_value; | ||
|
||
uint8 char_value; | ||
|
||
float float32_value; | ||
|
||
double float64_value; | ||
|
||
int8 int8_value; | ||
|
||
uint8 uint8_value; | ||
|
||
int16 int16_value; | ||
|
||
uint16 uint16_value; | ||
|
||
int32 int32_value; | ||
|
||
uint32 uint32_value; | ||
|
||
int64 int64_value; | ||
|
||
uint64 uint64_value; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
bool bool_value | ||
byte byte_value | ||
char char_value | ||
float32 float32_value | ||
float64 float64_value | ||
int8 int8_value | ||
uint8 uint8_value | ||
int16 int16_value | ||
uint16 uint16_value | ||
int32 int32_value | ||
uint32 uint32_value | ||
int64 int64_value | ||
uint64 uint64_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// generated from rosidl_adapter/resource/srv.idl.em | ||
// with input from test_msgs/srv/Test.srv | ||
// generated code does not contain a copyright notice | ||
|
||
|
||
module test_msgs { | ||
module srv { | ||
struct Test_Request { | ||
boolean bool_value; | ||
|
||
octet byte_value; | ||
|
||
uint8 char_value; | ||
|
||
float float32_value; | ||
|
||
double float64_value; | ||
|
||
int8 int8_value; | ||
|
||
uint8 uint8_value; | ||
|
||
int16 int16_value; | ||
|
||
uint16 uint16_value; | ||
|
||
int32 int32_value; | ||
|
||
uint32 uint32_value; | ||
|
||
int64 int64_value; | ||
|
||
uint64 uint64_value; | ||
|
||
string string_value; | ||
}; | ||
struct Test_Response { | ||
boolean ok; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
bool bool_value | ||
byte byte_value | ||
char char_value | ||
float32 float32_value | ||
float64 float64_value | ||
int8 int8_value | ||
uint8 uint8_value | ||
int16 int16_value | ||
uint16 uint16_value | ||
int32 int32_value | ||
uint32 uint32_value | ||
int64 int64_value | ||
uint64 uint64_value | ||
string string_value | ||
--- | ||
bool ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Copyright 2021 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import filecmp | ||
import pathlib | ||
|
||
from rosidl_cli.command.translate.api import translate | ||
|
||
|
||
DATA_PATH = pathlib.Path(__file__).parent / 'data' | ||
|
||
|
||
def test_translation_extensions(tmp_path, capsys): | ||
# NOTE(hidmic): pytest and empy do not play along, | ||
# the latter expects some proxy will stay in sys.stdout | ||
# and the former insists in overwriting it | ||
|
||
with capsys.disabled(): # so do everything in one run | ||
# Test .msg to .idl translation | ||
idl_files = translate( | ||
package_name='test_msgs', | ||
interface_files=[ | ||
f'{DATA_PATH}:msg/Test.msg'], | ||
output_path=tmp_path, | ||
output_format='idl', | ||
translators=['msg2idl'] | ||
) | ||
|
||
assert len(idl_files) == 1 | ||
idl_file = idl_files[0] | ||
assert idl_file == f'{tmp_path}:msg/Test.idl' | ||
assert filecmp.cmp( | ||
tmp_path / 'msg' / 'Test.idl', | ||
DATA_PATH / 'msg' / 'Test.expected.idl', | ||
shallow=False | ||
) | ||
|
||
# Test .srv to .idl translation | ||
idl_files = translate( | ||
package_name='test_msgs', | ||
interface_files=[ | ||
f'{DATA_PATH}:srv/Test.srv'], | ||
output_path=tmp_path, | ||
output_format='idl', | ||
translators=['srv2idl'] | ||
) | ||
|
||
assert len(idl_files) == 1 | ||
idl_file = idl_files[0] | ||
assert idl_file == f'{tmp_path}:srv/Test.idl' | ||
assert filecmp.cmp( | ||
tmp_path / 'srv' / 'Test.idl', | ||
DATA_PATH / 'srv' / 'Test.expected.idl', | ||
shallow=False | ||
) | ||
|
||
# Test .action to .idl translation | ||
idl_files = translate( | ||
package_name='test_msgs', | ||
interface_files=[ | ||
f'{DATA_PATH}:action/Test.action'], | ||
output_path=tmp_path, | ||
output_format='idl', | ||
translators=['action2idl'] | ||
) | ||
|
||
assert len(idl_files) == 1 | ||
idl_file = idl_files[0] | ||
assert idl_file == f'{tmp_path}:action/Test.idl' | ||
assert filecmp.cmp( | ||
tmp_path / 'action' / 'Test.idl', | ||
DATA_PATH / 'action' / 'Test.expected.idl', | ||
shallow=False | ||
) |