Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

aix: improve readability of os version #57

Closed
wants to merge 2 commits into from

Conversation

richardlau
Copy link
Member

uname on AIX reports, e.g. 6.1 as version == 6, release == 1.
The code was previously printing this as:

OS version: AIX 1 6

Fix so that on AIX this is now:

OS version: AIX 6.1

nodejs/node#10245 fixed a similar area in Node.js.

Copy link

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A test would be good though.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the addition of a test.

@richardlau
Copy link
Member Author

I'll add a test, just need to think of a sensible thing to check (maybe for AIX that it conforms the regex /AIX\ \d+\.\d+/). Can't rely on Node.js to get the expected string (nodejs/node#10245 hasn't landed in v4 or v6 yet).

@hhellyer
Copy link
Contributor

Do we actually want to change so we pretty print AIX version info? At the moment the output format is similar to the format from uname -a:

$ uname -a
AIX dal-pax 1 6 00F460A94C00

I agree AIX's output format is odd but is it better to be consistent with that as it is what the user will see when they check the version string on their box?
We don't pretty print the version output on Linux:
OS version: Linux 4.8.0-22-generic #24-Ubuntu SMP Sat Oct 8 09:15:00 UTC 2016
or Mac:
OS version: Darwin 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64
they both look like the uname -a output.

@richardlau
Copy link
Member Author

I agree AIX's output format is odd but is it better to be consistent with that as it is what the user will see when they check the version string on their box?

https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.cmds4/oslevel.htm

-bash-4.3$ oslevel
6.1.0.0

uname on AIX reports, e.g. 6.1 as version == 6, release == 1.
The code was previously printing this as:
  OS version: AIX 1 6
Fix so that on AIX this is now:
  OS version: AIX 6.1
@richardlau
Copy link
Member Author

Rebased onto master to pick up changes from #48, which changed src/node_report.cc to use C++ streams. Also used the new getReport() API in the testcase 😄. PTAL.

} else if (common.isAIX() && !os.release().includes('.')) {
// For Node.js prior to os.release() fix for AIX: https://github.com/nodejs/node/pull/10245
tap.match(version_str, new RegExp('OS version: ' + os_name + ' \\d+.' + os.release()), 'Checking OS version');
} else if (!common.isWindows()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this just be else since you already check 'if (common.isWindows()) {' ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can. Fixed.

const version_str = report_str.match(/OS version: .*(?:\r*\n)/);
if (common.isWindows()) {
tap.match(version_str, new RegExp('OS version: ' + os_name), 'Checking OS version');
} else if (common.isAIX() && !os.release().includes('.')) {
Copy link
Member

@gibfahn gibfahn Feb 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think .includes() is there in Node v4.

But obviously we can check by running CI with Node v4.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a node v4.0.0 repl that seems to work:

$ node-v4.0.0-darwin-x64/bin/node
> os.release().includes('.')
true

It should be fine on v4.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you're right. I think it's Array.includes() that isn't there in v4, string.includes() is.

@richardlau
Copy link
Member Author

richardlau commented Feb 14, 2017

Node v4 CI: https://ci.nodejs.org/view/post-mortem/job/nodereport-continuous-integration/53/
edit: Will contain failures (see #58)

@richardlau
Copy link
Member Author

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

rnchamberlain pushed a commit that referenced this pull request Feb 17, 2017
uname on AIX reports, e.g. 6.1 as version == 6, release == 1.
The code was previously printing this as:
  OS version: AIX 1 6
Fix so that on AIX this is now:
  OS version: AIX 6.1

PR-URL: #57
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gibson Fahnestock <gib@uk.ibm.com>
Reviewed-By: Howard Hellyer <hhellyer@uk.ibm.com>
@rnchamberlain
Copy link
Contributor

Landed as 76fa628

@rnchamberlain
Copy link
Contributor

@richardlau I realised after landing this that your testcase test/test-os-version.js is a bit of a departure from our previous test strategy. We were adding the report validation checks into common.js, so that the report content gets checked for all scenarios (i.e. whenever a report is generated). Your new test runs an individual report to check the os version line, so does not give as much coverage?

@richardlau
Copy link
Member Author

@rnchamberlain #63

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants