Skip to content

Commit

Permalink
fixup! fixup! test: log more information in debugger tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Aug 23, 2022
1 parent f8e6ee4 commit a3f66df
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
26 changes: 26 additions & 0 deletions test/fixtures/snapshot/dns-localhost.js
@@ -0,0 +1,26 @@
'use strict';
const dns = require('dns');

const {
setDeserializeMainFunction
} = require('v8').startupSnapshot;

function query() {
dns.resolve4('nodejs.org', (err, addresses) => {
if (err) throw error;

console.log(`addresses: ${JSON.stringify(addresses)}`);

addresses.forEach((a) => {
dns.reverse(a, (err, hostnames) => {
if (err) throw error;

console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
});
});
});
}

query();

setDeserializeMainFunction(query);
49 changes: 49 additions & 0 deletions test/internet/test-snapshot-dns.js
@@ -0,0 +1,49 @@
'use strict';

// This tests support for the dns module in snapshot.

require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const tmpdir = require('../common/tmpdir');
const fixtures = require('../common/fixtures');
const path = require('path');
const fs = require('fs');

tmpdir.refresh();
const blobPath = path.join(tmpdir.path, 'snapshot.blob');
const entry = fixtures.path('snapshot', 'dns-local.js');
{
const child = spawnSync(process.execPath, [
'--snapshot-blob',
blobPath,
'--build-snapshot',
entry,
], {
cwd: tmpdir.path
});
if (child.status !== 0) {
console.log(child.stderr.toString());
console.log(child.stdout.toString());
assert.strictEqual(child.status, 0);
}
const stats = fs.statSync(path.join(tmpdir.path, 'snapshot.blob'));
assert(stats.isFile());
}

{
const child = spawnSync(process.execPath, [
'--snapshot-blob',
blobPath,
], {
cwd: tmpdir.path,
env: {
...process.env,
}
});

const stdout = child.stdout.toString().trim();
const file = fs.readFileSync(fixtures.path('x1024.txt'), 'utf8');
assert.strictEqual(stdout, file);
assert.strictEqual(child.status, 0);
}
2 changes: 0 additions & 2 deletions test/sequential/test-debugger-exec.js
Expand Up @@ -8,8 +8,6 @@ const startCLI = require('../common/debugger');

const assert = require('assert');

process.env.NODE_DEBUG = 'inspect';

{

const cli = startCLI([fixtures.path('debugger/alive.js')]);
Expand Down

0 comments on commit a3f66df

Please sign in to comment.