-
Notifications
You must be signed in to change notification settings - Fork 85
Treat unrecognized ROS_DISTRO as a future distro #1485
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ const DistroId = { | |
| JAZZY: 2405, | ||
| KILTED: 2505, | ||
| ROLLING: 5000, | ||
| FUTURE: 9999, // unrecognized ROS_DISTRO assumed newer than Rolling | ||
| }; | ||
|
|
||
| const DistroNameIdMap = new Map(); | ||
|
|
@@ -50,9 +51,12 @@ const DistroUtils = { | |
| getDistroId: function (distroName) { | ||
| const dname = distroName ? distroName.toLowerCase() : this.getDistroName(); | ||
|
|
||
| return DistroNameIdMap.has(dname) | ||
| ? DistroNameIdMap.get(dname) | ||
| : DistroId.UNKNOWN; | ||
| if (DistroNameIdMap.has(dname)) { | ||
| return DistroNameIdMap.get(dname); | ||
| } | ||
|
|
||
| // Unrecognized but set ROS_DISTRO → assume future distro; unset → unknown | ||
| return dname ? DistroId.FUTURE : DistroId.UNKNOWN; | ||
|
Comment on lines
51
to
+60
|
||
| }, | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,21 +60,26 @@ describe('rclnodejs distro utils', function () { | |
| it('unknown distro', function (done) { | ||
| let backupEnvar = process.env.ROS_DISTRO; | ||
|
|
||
| // test unknown distro | ||
| // test unknown distro — when ROS_DISTRO is set but unrecognized, | ||
| // assume it is a future distro (newer than Rolling) | ||
| process.env.ROS_DISTRO = 'xxx'; | ||
| assert.equal( | ||
| 'xxx', | ||
| DistroUtils.getDistroName(), | ||
| `Failed unknown distro name` | ||
| ); | ||
| let id = DistroUtils.getDistroId(); | ||
| assert.equal(id, DistroUtils.DistroId.UNKNOWN); | ||
| assert.equal(id, DistroUtils.DistroId.FUTURE); | ||
| assert.equal( | ||
| DistroUtils.DistroId.UNKNOWN, | ||
| DistroUtils.DistroId.FUTURE, | ||
| DistroUtils.getDistroId('xxx'), | ||
| "getDistroId('xxx') failed" | ||
| ); | ||
|
|
||
| // test truly unknown — ROS_DISTRO unset | ||
| delete process.env.ROS_DISTRO; | ||
| assert.equal(DistroUtils.getDistroId(), DistroUtils.DistroId.UNKNOWN); | ||
|
|
||
| process.env.ROS_DISTRO = backupEnvar; | ||
| done(); | ||
|
Comment on lines
+79
to
86
|
||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says this branch is for an "Unrecognized but set ROS_DISTRO", but the logic also applies when a caller passes an explicit
distroNameargument that isn’t in the map. Please update the comment (or the logic) so the behavior and documentation stay aligned.