Skip to content

Commit 902f22a

Browse files
committed
fix(sea): F3b fixup — skip-gate native-binary check + createRequire
Same skip-gate fix as F2/F4 (DA round 1 H1): - `before()` verifies `native/sea/index.linux-x64-gnu.node` exists, skips with a clear "run yarn build:native" message if absent. - `loadBinding()` uses `createRequire(import.meta.url)` so the require works under both CJS and the ESM-reparse path mocha 11+ may use (MODULE_TYPELESS_PACKAGE_JSON reparse-as-ESM). Pre-emptive fix even though F3b wasn't on the DA fixup batch list — the same defect pattern would have been flagged on the next round. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
1 parent db238ff commit 902f22a

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

tests/e2e/sea/async-execute-e2e.test.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@
4040

4141
import { expect } from 'chai';
4242
import { tableFromIPC } from 'apache-arrow';
43+
import * as fs from 'fs';
44+
import * as path from 'path';
45+
import { createRequire } from 'module';
46+
47+
// `createRequire(import.meta.url)` so the require works under both
48+
// CJS and the ESM-reparse path mocha 11+ may use
49+
// (MODULE_TYPELESS_PACKAGE_JSON reparse-as-ESM).
50+
// eslint-disable-next-line @typescript-eslint/naming-convention
51+
const requireFromHere = createRequire(import.meta.url);
4352

4453
interface NativeBinding {
4554
openSession(opts: {
@@ -82,18 +91,34 @@ describe('SEA async execute — submit / status / awaitResult / cancel', functio
8291
if (!hostName || !httpPath || !token) {
8392
// eslint-disable-next-line no-invalid-this
8493
this.skip();
94+
return;
95+
}
96+
// Verify the native artifact exists before any test calls
97+
// loadBinding(). Skip-with-message if absent. DA round-1 H1 fixup
98+
// (skip-gate must not crash MODULE_NOT_FOUND when build:native not
99+
// run).
100+
const nodeArtifact = path.resolve(
101+
process.cwd(),
102+
'native/sea/index.linux-x64-gnu.node',
103+
);
104+
if (!fs.existsSync(nodeArtifact)) {
105+
// eslint-disable-next-line no-console
106+
console.warn(
107+
`[sea async-execute e2e] skipping: native binary not built. ` +
108+
`Run \`yarn build:native\` first.`,
109+
);
110+
// eslint-disable-next-line no-invalid-this
111+
this.skip();
85112
}
86113
});
87114

88115
/**
89116
* Lazy-load the native binding so the test file is requirable in
90117
* environments where the `.node` artifact isn't built yet — the
91-
* `before()` gate will skip the suite before we touch the binding.
92-
* Loading at `require`-time would crash test discovery.
118+
* `before()` gate skips the suite before we touch the binding.
93119
*/
94120
function loadBinding(): NativeBinding {
95-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
96-
return require('../../../native/sea/index.js') as NativeBinding;
121+
return requireFromHere('../../../native/sea/index.js') as NativeBinding;
97122
}
98123

99124
it('submit returns immediately with a statement_id; awaitResult drains', async () => {

0 commit comments

Comments
 (0)