function isSymlinkSupported() {
  if (process.platform !== "win32") {
    return true;
  }

  const target = path.join(
    __dirname,
    "../cli/patterns-symlinks/test-symlink-feature-detect",
  );
  fs.rmSync(target, { force: true, recursive: true });
  fs.mkdirSync(target);
  const symlink = path.join(target, "symlink");
  try {
    fs.symlinkSync(target, symlink);
  } catch {
    return false;
  }
  return fs.lstatSync(symlink).isSymbolicLink();
}
/*"], { status: 1 });

describe("Trailing slash", () => {
  testPatterns("1", ["./"], { status: 1, stderr: "" });
  testPatterns("2", [".//"], { status: 1, stderr: "" });
  testPatterns("3", ["dir1/"], { status: 1, stderr: "" });
  testPatterns("4", ["dir1//"], { status: 1, stderr: "" });
  testPatterns("5", [".//dir2/..//./dir1//"], { status: 1, stderr: "" });
  testPatterns(
    "run in sub dir 1",
    [".."],
    { status: 1, stderr: "" },
    "cli/patterns-dirs/dir2",
  );
  testPatterns(
    "run in sub dir 2",
    ["../"],
    { status: 1, stderr: "" },
    "cli/patterns-dirs/dir2",
  );
  testPatterns(
    "run in sub dir 3",
    ["../dir1"],
    { status: 1, stderr: "" },
    "cli/patterns-dirs/dir2",
  );
  testPatterns(
    "run in sub dir 4",
    ["../dir1/"],
    { status: 1, stderr: "" },
    "cli/patterns-dirs/dir2",
  );
});

describe("Negative patterns", () => {
  testPatterns("1", ["dir1", "!dir1/nested1"]);
  testPatterns("1a", ["dir1", "!dir1/nested1/*"]);
  testPatterns("2", [".", "!dir1/nested1"]);
  testPatterns("3", [".", "!dir1/nested1/an1.js"]);
  testPatterns("4", ["!nonexistent-dir1 !nonexistent-dir2"], { status: 2 });
  testPatterns("with explicit files", ["dir1/a1.js", "dir2/a2.js", "!dir1/*"], {
    status: 2,
  });
});

testPatterns("Exclude yarn.lock when expanding directories", ["."], {
  stdout: expect.not.stringContaining("yarn.lock"),
});

const uppercaseRocksPlugin = path.join(
  projectRoot,
  "tests/config/prettier-plugins/prettier-plugin-uppercase-rocks/index.js",
);
describe("plugins `.`", () => {
  runCliWithoutGitignore("cli/dirs/plugins", [
    ".",
    "-l",
    "--plugin",
    uppercaseRocksPlugin,
  ]).test({
    write: [],
    stderr: "",
    status: 1,
  });
});
describe("plugins `*`", () => {
  runCliWithoutGitignore("cli/dirs/plugins", [
    "*",
    "-l",
    "--plugin",
    uppercaseRocksPlugin,
  ]).test({
    write: [],
    status: 2,
  });
});

if (path.sep === "/") {
  // Don't use snapshots in these tests as they're conditionally executed on non-Windows only.

  const base = path.resolve(__dirname, "../cli/patterns-backslashes");
  const directoryA = path.join(base, "test-a\\");
  const directoryB = path.join(base, String.raw`test-b\?`);

  fs.rmSync(directoryA, { force: true, recursive: true });
  fs.rmSync(directoryB, { force: true, recursive: true });
  for (const directory of [directoryA, directoryB]) {
    fs.mkdirSync(directory);
    fs.writeFileSync(path.join(directory, "test.js"), "x");
  }

  describe("Backslashes in names", () => {
    testPatterns(
      "",
      [String.raw`test-a\/test.js`],
      {
        stdout: String.raw`test-a\/test.js`,
      },
      base,
    );
    testPatterns(
      "",
      ["test-a\\"],
      { stdout: String.raw`test-a\/test.js` },
      base,
    );
    testPatterns(
      "",
      ["test-a