GeezerVison is showing github.com — test: reuse ffi.suffix instead of reimplementing it · nodejs/node@b9e596f
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/ffi/ffi-test-common.js +3-6Lines changed: 3 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,18 +6,15 @@ const path = require('node:path'); |
6 | 6 |
|
7 | 7 | common.skipIfFFIMissing(); |
8 | 8 |
|
| 9 | +const { suffix } = require('node:ffi'); |
| 10 | + |
9 | 11 | const fixtureBuildDir = path.join( |
10 | 12 | __dirname, |
11 | 13 | 'fixture_library', |
12 | 14 | 'build', |
13 | 15 | common.buildType, |
14 | 16 | ); |
15 | | -const libraryPath = path.join( |
16 | | - fixtureBuildDir, |
17 | | - process.platform === 'win32' ? 'ffi_test_library.dll' : |
18 | | - process.platform === 'darwin' ? 'ffi_test_library.dylib' : |
19 | | - 'ffi_test_library.so', |
20 | | -); |
| 17 | +const libraryPath = path.join(fixtureBuildDir, `ffi_test_library.${suffix}`); |
21 | 18 |
|
22 | 19 | function ensureFixtureLibrary() { |
23 | 20 | if (!fs.existsSync(libraryPath)) { |
|
Collapse file
Copy file name to clipboardExpand all lines: test/ffi/test-ffi-module.js +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -154,6 +154,14 @@ test('ffi exports expected API surface', () => { |
154 | 154 | assert.strictEqual(typeof ffi.types, 'object'); |
155 | 155 | }); |
156 | 156 |
|
| 157 | +test('ffi.suffix matches the current platform', () => { |
| 158 | + const ffi = require('node:ffi'); |
| 159 | + const expected = process.platform === 'win32' ? 'dll' : |
| 160 | + process.platform === 'darwin' ? 'dylib' : 'so'; |
| 161 | + |
| 162 | + assert.strictEqual(ffi.suffix, expected); |
| 163 | +}); |
| 164 | + |
157 | 165 | test('ffi.types exports canonical type constants', () => { |
158 | 166 | const ffi = require('node:ffi'); |
159 | 167 | const expected = { |
|