Skip to content

Commit 3919187

Browse files
build: improve logging in build_addons
1 parent 72a1db7 commit 3919187

File tree

11 files changed

+27
-168
lines changed

11 files changed

+27
-168
lines changed

src/js_native_api.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#endif
2222
#endif
2323

24-
#if defined(NAPI_EXPERIMENTAL) && !defined(NODE_API_EXPERIMENTAL_NO_WARNING)
24+
#if defined(NAPI_EXPERIMENTAL) && \
25+
!defined(NODE_API_EXPERIMENTAL_NO_WARNING) && \
26+
!defined(NODE_WANT_INTERNALS)
2527
#warning "NAPI_EXPERIMENTAL is enabled. Experimental features may be unstable."
2628
#endif
2729

test/addons/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Makefile
66
gyp-mac-tool
77
/*/build
88
/esm/node_modules/*/build
9+
/*/logs

test/js-native-api/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Makefile
55
*.mk
66
gyp-mac-tool
77
/*/build
8+
/*/logs

test/js-native-api/test_warning/binding.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <node_api.h>
22

3-
static napi_value Method(const napi_env env,
4-
const napi_callback_info info) {
3+
static napi_value Method(const napi_env env, const napi_callback_info info) {
54
napi_value result;
65
napi_create_string_utf8(env, "world", NAPI_AUTO_LENGTH, &result);
76
return result;

test/js-native-api/test_warning/binding2.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <node_api.h>
22

3-
static napi_value Method(const napi_env env,
4-
const napi_callback_info info) {
3+
static napi_value Method(const napi_env env, const napi_callback_info info) {
54
napi_value result;
65
napi_create_string_utf8(env, "world", NAPI_AUTO_LENGTH, &result);
76
return result;

test/js-native-api/test_warning/build_logs/build_clang.log

Lines changed: 0 additions & 72 deletions
This file was deleted.

test/js-native-api/test_warning/build_logs/build_gcc.log

Lines changed: 0 additions & 72 deletions
This file was deleted.

test/js-native-api/test_warning/test.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,12 @@ assert.strictEqual(binding2.hello(), 'world');
1414
{
1515
const warningMessage = '#warning "NAPI_EXPERIMENTAL is enabled. Experimental features may be unstable."';
1616

17-
const gccLogFilePath = path.resolve(__dirname, './build_logs/build_gcc.log');
18-
const gccLogContent = fs.readFileSync(gccLogFilePath, 'utf8');
17+
const logFilePath = path.resolve(__dirname, './logs/build.log');
18+
const logContent = fs.readFileSync(logFilePath, 'utf8');
1919

20-
const gccWarningCount = gccLogContent.split(warningMessage).length - 1;
21-
const gccHasWarning = gccLogContent.includes(warningMessage);
20+
const warningCount = logContent.split(warningMessage).length - 1;
21+
const hasWarning = logContent.includes(warningMessage);
2222

23-
assert.strictEqual(gccHasWarning, true, `Expected warning not found: "${warningMessage}"`);
24-
assert.strictEqual(gccWarningCount, 1, `Expected warning to appear exactly once, but found ${gccWarningCount} occurrences.`);
25-
26-
const clangLogFilePath = path.resolve(__dirname, './build_logs/build_clang.log');
27-
const clangLogContent = fs.readFileSync(clangLogFilePath, 'utf8');
28-
29-
const clangWarningCount = clangLogContent.split(warningMessage).length - 1;
30-
const clangHasWarning = clangLogContent.includes(warningMessage);
31-
32-
assert.strictEqual(clangHasWarning, true, `Expected warning not found: "${warningMessage}"`);
33-
assert.strictEqual(clangWarningCount, 1, `Expected warning to appear exactly once, but found ${gccWarningCount} occurrences.`);
23+
assert.strictEqual(hasWarning, true, `Expected warning not found: "${warningMessage}"`);
24+
assert.strictEqual(warningCount, 1, `Expected warning to appear exactly once, but found ${warningCount} occurrences.`);
3425
}

test/node-api/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
build
2+
/*/logs

test/sqlite/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
build
2+
/*/logs

0 commit comments

Comments
 (0)