Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
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
628 changes: 1 addition & 627 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"@changesets/cli": "^2.25.2",
"husky": "^8.0.2",
"lint-staged": "^13.0.4",
"prettier": "^2.8.0",
"tape": "^5.6.1"
"prettier": "^2.8.0"
},
"volta": {
"node": "18.12.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/v8-deopt-generate-log/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"src"
],
"scripts": {
"test": "node test/index.test.js"
"test": "node --test test"
},
"dependencies": {
"chrome-launcher": "^0.15.1",
Expand Down
78 changes: 51 additions & 27 deletions packages/v8-deopt-generate-log/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import assert from "assert";
import * as path from "path";
import { readFile } from "fs/promises";
import { pathToFileURL, fileURLToPath } from "url";
import test from "tape";
import test from "node:test";
import { generateV8Log } from "../src/index.js";

// @ts-ignore
Expand Down Expand Up @@ -48,122 +49,145 @@ async function runGenerateV8Log(
}

/**
* @param {import('tape').Test} t
* @param {string} content
* @param {string[]} srcFiles
*/
function verifySrcFiles(t, content, srcFiles) {
function verifySrcFiles(content, srcFiles) {
for (let srcFile of srcFiles) {
srcFile = srcFile.replace(/\\/g, "\\\\");
t.equal(content.includes(srcFile), true, `Content contains ${srcFile}`);
assert.equal(
content.includes(srcFile),
true,
`Content contains ${srcFile}`
);
}

traceMapMatches.forEach((matcher) => {
t.equal(matcher.test(content), false, "Content does not match " + matcher);
assert.equal(
matcher.test(content),
false,
"Content does not match " + matcher
);
});
}

test("generateV8Log(simple/adders.js)", async (t) => {
test("generateV8Log(simple/adders.js)", async () => {
const srcFilePath = repoRoot("examples/simple/adders.js");
const logContent = await runGenerateV8Log(srcFilePath);

verifySrcFiles(t, logContent, [srcFilePath]);
verifySrcFiles(logContent, [srcFilePath]);
});

test("generateV8Log(simple/adders.js) relative path", async (t) => {
test("generateV8Log(simple/adders.js) relative path", async () => {
const fullPath = repoRoot("examples/simple/adders.js");
const srcFilePath = path.relative(process.cwd(), fullPath);
const logContent = await runGenerateV8Log(srcFilePath);

verifySrcFiles(t, logContent, [fullPath]);
verifySrcFiles(logContent, [fullPath]);
});

test("generateV8Log(two-modules/adders.js)", async (t) => {
test("generateV8Log(two-modules/adders.js)", async () => {
const srcFilePath = repoRoot("examples/two-modules/adders.js");
const logContent = await runGenerateV8Log(srcFilePath);

verifySrcFiles(t, logContent, [
verifySrcFiles(logContent, [
srcFilePath,
repoRoot("examples/two-modules/objects.js"),
]);
});

test("generateV8Log(html-inline/adders.html)", async (t) => {
test("generateV8Log(html-inline/adders.html)", async () => {
const srcFilePath = repoRoot("examples/html-inline/adders.html");
const logContent = await runGenerateV8Log(srcFilePath);

verifySrcFiles(t, logContent, [pathToFileURL(srcFilePath).toString()]);
verifySrcFiles(logContent, [pathToFileURL(srcFilePath).toString()]);
});

test("generateV8Log(html-external/index.html)", async (t) => {
test("generateV8Log(html-external/index.html)", async () => {
const srcFilePath = repoRoot("examples/html-external/index.html");
const logContent = await runGenerateV8Log(srcFilePath);

verifySrcFiles(t, logContent, [
verifySrcFiles(logContent, [
pathToFileURL(repoRoot("examples/html-external/adders.js")).toString(),
pathToFileURL(repoRoot("examples/html-external/objects.js")).toString(),
]);
});

test("generateV8Log(GitHub Pages html-inline/adders.html)", async (t) => {
test("generateV8Log(GitHub Pages html-inline/adders.html)", async () => {
const srcFilePath = getGHPageUrl("html-inline/adders.html");
const logContent = await runGenerateV8Log(srcFilePath);

verifySrcFiles(t, logContent, [srcFilePath]);
verifySrcFiles(logContent, [srcFilePath]);
});

test("generateV8Log(GitHub Pages html-external/index.html)", async (t) => {
test("generateV8Log(GitHub Pages html-external/index.html)", async () => {
const srcFilePath = getGHPageUrl("html-external/index.html");
const logContent = await runGenerateV8Log(srcFilePath);

verifySrcFiles(t, logContent, [
verifySrcFiles(logContent, [
getGHPageUrl("html-external/adders.js"),
getGHPageUrl("html-external/objects.js"),
]);
});

test("generateV8Log(simple/adders.js, traceMaps: true)", async (t) => {
test("generateV8Log(simple/adders.js, traceMaps: true)", async () => {
const fullPath = repoRoot("examples/simple/adders.js");
const srcFilePath = path.relative(process.cwd(), fullPath);
const logContent = await runGenerateV8Log(srcFilePath, ".traceMaps", {
traceMaps: true,
});

traceMapMatches.forEach((matcher) => {
t.equal(matcher.test(logContent), true, "Content does match " + matcher);
assert.equal(
matcher.test(logContent),
true,
"Content does match " + matcher
);
});
});

test("generateV8Log(two-modules/adders.js, traceMaps: true)", async (t) => {
test("generateV8Log(two-modules/adders.js, traceMaps: true)", async () => {
const fullPath = repoRoot("examples/two-modules/adders.js");
const srcFilePath = path.relative(process.cwd(), fullPath);
const logContent = await runGenerateV8Log(srcFilePath, ".traceMaps", {
traceMaps: true,
});

traceMapMatches.forEach((matcher) => {
t.equal(matcher.test(logContent), true, "Content does match " + matcher);
assert.equal(
matcher.test(logContent),
true,
"Content does match " + matcher
);
});
});

test("generateV8Log(html-inline/adders.html, traceMaps: true)", async (t) => {
test("generateV8Log(html-inline/adders.html, traceMaps: true)", async () => {
const srcFilePath = repoRoot("examples/html-inline/adders.html");
const logContent = await runGenerateV8Log(srcFilePath, ".traceMaps", {
traceMaps: true,
});

traceMapMatches.forEach((matcher) => {
t.equal(matcher.test(logContent), true, "Content does match " + matcher);
assert.equal(
matcher.test(logContent),
true,
"Content does match " + matcher
);
});
});

test("generateV8Log(html-external/index.html, traceMaps: true)", async (t) => {
test("generateV8Log(html-external/index.html, traceMaps: true)", async () => {
const srcFilePath = repoRoot("examples/html-external/index.html");
const logContent = await runGenerateV8Log(srcFilePath, ".traceMaps", {
traceMaps: true,
});

traceMapMatches.forEach((matcher) => {
t.equal(matcher.test(logContent), true, "Content does match " + matcher);
assert.equal(
matcher.test(logContent),
true,
"Content does match " + matcher
);
});
});
2 changes: 1 addition & 1 deletion packages/v8-deopt-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"src"
],
"scripts": {
"test": "node test/index.test.js",
"test": "node --test test/index.test.js",
"deopts": "v8-deopt-viewer -i test/deopt-results/out-of-memory.v8.log -o test/deopt-results --open"
},
"devDependencies": {
Expand Down
63 changes: 32 additions & 31 deletions packages/v8-deopt-parser/test/groupBy.test.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,66 @@
import test from "tape";
import assert from "node:assert";
import test from "node:test";
import { groupByFile } from "../src/index.js";
import { runParser, repoRoot, repoFileURL } from "./helpers.js";

test("groupByFile(adders.v8.log)", async (t) => {
const rawData = await runParser(t, "adders.v8.log");
test("groupByFile(adders.v8.log)", async () => {
const rawData = await runParser("adders.v8.log");
const result = groupByFile(rawData);

const files = Object.keys(result.files);
t.equal(files.length, 1, "Number of files");
assert.equal(files.length, 1, "Number of files");

const fileData = result.files[files[0]];
t.equal(fileData.codes.length, 16, "number of codes");
t.equal(fileData.deopts.length, 7, "number of deopts");
t.equal(fileData.ics.length, 33, "number of ics");
assert.equal(fileData.codes.length, 16, "number of codes");
assert.equal(fileData.deopts.length, 7, "number of deopts");
assert.equal(fileData.ics.length, 33, "number of ics");
});

test("groupByFile(two-modules.v8.log)", async (t) => {
const rawData = await runParser(t, "two-modules.v8.log");
test("groupByFile(two-modules.v8.log)", async () => {
const rawData = await runParser("two-modules.v8.log");
const result = groupByFile(rawData);

const files = Object.keys(result.files);
t.equal(files.length, 2, "Number of files");
assert.equal(files.length, 2, "Number of files");

let fileData = result.files[repoRoot("examples/two-modules/adders.js")];
t.equal(fileData.codes.length, 8, "File 1: number of codes");
t.equal(fileData.deopts.length, 7, "File 1: number of deopts");
t.equal(fileData.ics.length, 8, "File 1: number of ics");
assert.equal(fileData.codes.length, 8, "File 1: number of codes");
assert.equal(fileData.deopts.length, 7, "File 1: number of deopts");
assert.equal(fileData.ics.length, 8, "File 1: number of ics");

fileData = result.files[repoRoot("examples/two-modules/objects.js")];
t.equal(fileData.codes.length, 8, "File 2: number of codes");
t.equal(fileData.deopts.length, 0, "File 2: number of deopts");
t.equal(fileData.ics.length, 25, "File 2: number of ics");
assert.equal(fileData.codes.length, 8, "File 2: number of codes");
assert.equal(fileData.deopts.length, 0, "File 2: number of deopts");
assert.equal(fileData.ics.length, 25, "File 2: number of ics");
});

test("groupByFile(html-inline.v8.log)", async (t) => {
const rawData = await runParser(t, "html-inline.v8.log");
test("groupByFile(html-inline.v8.log)", async () => {
const rawData = await runParser("html-inline.v8.log");
const result = groupByFile(rawData);

const files = Object.keys(result.files);
t.equal(files.length, 1, "Number of files");
assert.equal(files.length, 1, "Number of files");

const fileData = result.files[files[0]];
t.equal(fileData.codes.length, 15, "number of codes");
t.equal(fileData.deopts.length, 6, "number of deopts");
t.equal(fileData.ics.length, 33, "number of ics");
assert.equal(fileData.codes.length, 15, "number of codes");
assert.equal(fileData.deopts.length, 6, "number of deopts");
assert.equal(fileData.ics.length, 33, "number of ics");
});

test("groupByFile(html-external.v8.log)", async (t) => {
const rawData = await runParser(t, "html-external.v8.log");
test("groupByFile(html-external.v8.log)", async () => {
const rawData = await runParser("html-external.v8.log");
const result = groupByFile(rawData);

const files = Object.keys(result.files);
t.equal(files.length, 2, "Number of files");
assert.equal(files.length, 2, "Number of files");

let fileData = result.files[repoFileURL("examples/html-external/adders.js")];
t.equal(fileData.codes.length, 7, "File 1: number of codes");
t.equal(fileData.deopts.length, 6, "File 1: number of deopts");
t.equal(fileData.ics.length, 8, "File 1: number of ics");
assert.equal(fileData.codes.length, 7, "File 1: number of codes");
assert.equal(fileData.deopts.length, 6, "File 1: number of deopts");
assert.equal(fileData.ics.length, 8, "File 1: number of ics");

fileData = result.files[repoFileURL("examples/html-external/objects.js")];
t.equal(fileData.codes.length, 9, "File 2: number of codes");
t.equal(fileData.deopts.length, 0, "File 2: number of deopts");
t.equal(fileData.ics.length, 25, "File 2: number of ics");
assert.equal(fileData.codes.length, 9, "File 2: number of codes");
assert.equal(fileData.deopts.length, 0, "File 2: number of deopts");
assert.equal(fileData.ics.length, 25, "File 2: number of ics");
});
11 changes: 5 additions & 6 deletions packages/v8-deopt-parser/test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assert from "node:assert";
import { fileURLToPath, pathToFileURL } from "url";
import * as path from "path";
import { createReadStream, createWriteStream } from "fs";
Expand Down Expand Up @@ -124,11 +125,10 @@ export async function readLogFile(logFilename, logPath) {
}

/**
* @param {import('tape').Test} t
* @param {string} logFileName
* @param {import('../').Options} [options]
*/
export async function runParser(t, logFileName, options) {
export async function runParser(logFileName, options) {
const logPath = pkgRoot("test", "logs", logFileName);

const logContents = await readLogFile(logFileName, logPath);
Expand All @@ -149,7 +149,7 @@ export async function runParser(t, logFileName, options) {
console.error = origConsoleError;
}

t.equal(errorArgs.length, 0, "No console.error calls");
assert.equal(errorArgs.length, 0, "No console.error calls");

return result;
}
Expand Down Expand Up @@ -186,12 +186,11 @@ export async function writeSnapshot(logFileName, result) {
}

/**
* @param {import('tape').Test} t
* @param {string} message
* @param {Array<import('../').Entry>} entries
* @param {import('../').Entry} expectedEntry
*/
export function validateEntry(t, message, entries, expectedEntry) {
export function validateEntry(message, entries, expectedEntry) {
const { functionName, file, line, column } = expectedEntry;
const matches = entries.filter((entry) => {
return (
Expand All @@ -208,7 +207,7 @@ export function validateEntry(t, message, entries, expectedEntry) {
);
}

t.deepEqual(matches[0], expectedEntry, message);
assert.deepEqual(matches[0], expectedEntry, message);
}

export function decompress(inputPath) {
Expand Down
Loading