Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the rimraf dependency in favor of the built-in Node.js fs.rmSync in the test folder #17938

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 6 additions & 9 deletions test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
/* eslint-disable no-var */

import { copySubtreeSync, ensureDirSync, removeDirSync } from "./testutils.mjs";
import { copySubtreeSync, ensureDirSync } from "./testutils.mjs";
import {
downloadManifestFiles,
verifyManifestFiles,
Expand All @@ -25,14 +25,11 @@ import os from "os";
import path from "path";
import puppeteer from "puppeteer";
import readline from "readline";
import rimraf from "rimraf";
import { translateFont } from "./font/ttxdriver.mjs";
import url from "url";
import { WebServer } from "./webserver.mjs";
import yargs from "yargs";

const rimrafSync = rimraf.sync;

function parseOptions() {
const parsedArgs = yargs(process.argv)
.usage("Usage: $0")
Expand Down Expand Up @@ -213,7 +210,7 @@ function updateRefImages() {
console.log(" Updating ref/ ... ");
copySubtreeSync(refsTmpDir, refsDir);
if (removeTmp) {
removeDirSync(refsTmpDir);
fs.rmSync(refsTmpDir, { recursive: true, force: true });
}
console.log("done");
}
Expand Down Expand Up @@ -324,7 +321,7 @@ async function startRefTest(masterMode, showRefImages) {
fs.unlinkSync(eqLog);
}
if (fs.existsSync(testResultDir)) {
removeDirSync(testResultDir);
fs.rmSync(testResultDir, { recursive: true, force: true });
}

startTime = Date.now();
Expand Down Expand Up @@ -358,7 +355,7 @@ async function startRefTest(masterMode, showRefImages) {
function checkRefsTmp() {
if (masterMode && fs.existsSync(refsTmpDir)) {
if (options.noPrompts) {
removeDirSync(refsTmpDir);
fs.rmSync(refsTmpDir, { recursive: true, force: true });
setup();
return;
}
Expand All @@ -370,7 +367,7 @@ async function startRefTest(masterMode, showRefImages) {
"SHOULD THIS SCRIPT REMOVE tmp/? THINK CAREFULLY [yn] ",
function (answer) {
if (answer.toLowerCase() === "y") {
removeDirSync(refsTmpDir);
fs.rmSync(refsTmpDir, { recursive: true, force: true });
}
setup();
reader.close();
Expand Down Expand Up @@ -1038,7 +1035,7 @@ async function closeSession(browser) {
});
if (allClosed) {
if (tempDir) {
rimrafSync(tempDir);
fs.rmSync(tempDir, { recursive: true, force: true });
}
onAllSessionsClosed?.();
}
Expand Down
12 changes: 1 addition & 11 deletions test/testutils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@

import fs from "fs";
import path from "path";
import rimraf from "rimraf";

const rimrafSync = rimraf.sync;

function removeDirSync(dir) {
fs.readdirSync(dir); // Will throw if dir is not a directory
rimrafSync(dir, {
disableGlob: true,
});
}

function copySubtreeSync(src, dest) {
const files = fs.readdirSync(src);
Expand Down Expand Up @@ -63,4 +53,4 @@ function ensureDirSync(dir) {
}
}

export { copySubtreeSync, ensureDirSync, removeDirSync };
export { copySubtreeSync, ensureDirSync };