Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
aix: improve readability of os version
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
  • Loading branch information
richardlau committed Feb 10, 2017
commit d80c5909fc3b584f64dc0d2f5d4d42226c2a605f
5 changes: 5 additions & 0 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,13 @@ static void PrintVersionInformation(std::ostream& out) {
// Print operating system and machine information (Unix/OSX)
struct utsname os_info;
if (uname(&os_info) == 0) {
#if defined(_AIX)
out << "\nOS version: " << os_info.sysname << " " << os_info.version << "."
<< os_info.release << "\n";
#else
out << "\nOS version: " << os_info.sysname << " " << os_info.release << " "
<< os_info.version << "\n";
#endif
#if defined(__GLIBC__)
out << "(glibc: "<< __GLIBC__ << "." << __GLIBC_MINOR__ << ")\n";
#endif
Expand Down
27 changes: 27 additions & 0 deletions test/test-os-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

// Testcase for validating reported OS version

const common = require('./common.js');
const nodereport = require('../');
const os = require('os');
const tap = require('tap');

const os_map = {
'aix': 'AIX',
'darwin': 'Darwin',
'linux': 'Linux',
'win32': 'Windows',
};
const os_name = os_map[os.platform()];
const report_str = nodereport.getReport();
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

// 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
Copy Markdown
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
Copy Markdown
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.

tap.match(version_str, new RegExp('OS version: ' + os_name + ' .*' + os.release()), 'Checking OS version');
}