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

in build tests, sort by extension then path #1809

Merged
merged 5 commits into from
Nov 22, 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
8 changes: 6 additions & 2 deletions test/build-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import assert from "node:assert";
import {existsSync, readdirSync, statSync} from "node:fs";
import {mkdir, mkdtemp, open, readFile, rename, rm, unlink, writeFile} from "node:fs/promises";
import os from "node:os";
import {extname} from "node:path/posix";
import {join, normalize, relative} from "node:path/posix";
import {PassThrough} from "node:stream";
import {ascending, difference} from "d3-array";
import {ascending, difference, sort} from "d3-array";
import type {BuildManifest} from "../src/build.js";
import {FileBuildEffects, build} from "../src/build.js";
import {normalizeConfig, readConfig, setCurrentDate} from "../src/config.js";
Expand Down Expand Up @@ -76,7 +77,10 @@ describe("build", () => {
// renumber the hashes so they are sequential. This way we don’t have to
// update the test snapshots whenever Framework’s client code changes. We
// make an exception for minisearch.json because to test the content.
for (const path of findFiles(join(outputDir, "_observablehq"))) {
for (const path of sort(
findFiles(join(outputDir, "_observablehq")),
(a, b) => ascending(extname(a) === ".css", extname(b) === ".css") || ascending(a, b)
)) {
const match = /^((.+)\.[0-9a-f]{8})\.(\w+)$/.exec(path);
if (!match) throw new Error(`no hash found: ${path}`);
const [, key, name, ext] = match;
Expand Down
12 changes: 6 additions & 6 deletions test/output/build/duckdb/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<title>test DuckDB</title>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&amp;display=swap" crossorigin>
<link rel="preload" as="style" href="./_observablehq/theme-air,near-midnight.00000004.css">
<link rel="preload" as="style" href="./_observablehq/stdlib/inputs.00000007.css">
<link rel="preload" as="style" href="./_observablehq/theme-air,near-midnight.00000007.css">
<link rel="preload" as="style" href="./_observablehq/stdlib/inputs.00000006.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&amp;display=swap" crossorigin>
<link rel="stylesheet" type="text/css" href="./_observablehq/theme-air,near-midnight.00000004.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/stdlib/inputs.00000007.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/theme-air,near-midnight.00000007.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/stdlib/inputs.00000006.css">
<link rel="modulepreload" href="./_observablehq/client.00000001.js">
<link rel="modulepreload" href="./_observablehq/runtime.00000002.js">
<link rel="modulepreload" href="./_observablehq/stdlib.00000003.js">
<link rel="modulepreload" href="./_observablehq/stdlib/duckdb.00000005.js">
<link rel="modulepreload" href="./_observablehq/stdlib/inputs.00000006.js">
<link rel="modulepreload" href="./_observablehq/stdlib/duckdb.00000004.js">
<link rel="modulepreload" href="./_observablehq/stdlib/inputs.00000005.js">
<link rel="modulepreload" href="./_npm/@duckdb/[email protected]/cd372fb8.js">
<link rel="modulepreload" href="./_npm/[email protected]/cd372fb8.js">
<link rel="modulepreload" href="./_npm/[email protected]/cd372fb8.js">
Expand Down
2 changes: 1 addition & 1 deletion test/output/build/npm/_import/index.4bdc071f.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import "../_observablehq/stdlib/inputs.00000005.js";
import "../_observablehq/stdlib/inputs.00000004.js";
10 changes: 5 additions & 5 deletions test/output/build/npm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<meta name="generator" content="Observable Framework v1.0.0-test">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&amp;display=swap" crossorigin>
<link rel="preload" as="style" href="./_observablehq/theme-air,near-midnight.00000004.css">
<link rel="preload" as="style" href="./_observablehq/stdlib/inputs.00000006.css">
<link rel="preload" as="style" href="./_observablehq/theme-air,near-midnight.00000006.css">
<link rel="preload" as="style" href="./_observablehq/stdlib/inputs.00000005.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&amp;display=swap" crossorigin>
<link rel="stylesheet" type="text/css" href="./_observablehq/theme-air,near-midnight.00000004.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/stdlib/inputs.00000006.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/theme-air,near-midnight.00000006.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/stdlib/inputs.00000005.css">
<link rel="modulepreload" href="./_observablehq/client.00000001.js">
<link rel="modulepreload" href="./_observablehq/runtime.00000002.js">
<link rel="modulepreload" href="./_observablehq/stdlib.00000003.js">
<link rel="modulepreload" href="./_import/index.4bdc071f.js">
<link rel="modulepreload" href="./_observablehq/stdlib/inputs.00000005.js">
<link rel="modulepreload" href="./_observablehq/stdlib/inputs.00000004.js">
<link rel="modulepreload" href="./_npm/[email protected]/cd372fb8.js">
<link rel="modulepreload" href="./_npm/[email protected]/cd372fb8.js">
<script type="module">
Expand Down
14 changes: 7 additions & 7 deletions test/output/build/sql/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
<meta name="generator" content="Observable Framework v1.0.0-test">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&amp;display=swap" crossorigin>
<link rel="preload" as="style" href="./_observablehq/theme-air,near-midnight.00000004.css">
<link rel="preload" as="style" href="./_observablehq/stdlib/inputs.00000007.css">
<link rel="preload" as="style" href="./_observablehq/theme-air,near-midnight.00000007.css">
<link rel="preload" as="style" href="./_observablehq/stdlib/inputs.00000006.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&amp;display=swap" crossorigin>
<link rel="stylesheet" type="text/css" href="./_observablehq/theme-air,near-midnight.00000004.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/stdlib/inputs.00000007.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/theme-air,near-midnight.00000007.css">
<link rel="stylesheet" type="text/css" href="./_observablehq/stdlib/inputs.00000006.css">
<link rel="modulepreload" href="./_observablehq/client.00000001.js">
<link rel="modulepreload" href="./_observablehq/runtime.00000002.js">
<link rel="modulepreload" href="./_observablehq/stdlib.00000003.js">
<link rel="modulepreload" href="./_observablehq/stdlib/duckdb.00000005.js">
<link rel="modulepreload" href="./_observablehq/stdlib/inputs.00000006.js">
<link rel="modulepreload" href="./_observablehq/stdlib/duckdb.00000004.js">
<link rel="modulepreload" href="./_observablehq/stdlib/inputs.00000005.js">
<link rel="modulepreload" href="./_npm/@duckdb/[email protected]/cd372fb8.js">
<link rel="modulepreload" href="./_npm/[email protected]/cd372fb8.js">
<link rel="modulepreload" href="./_npm/[email protected]/cd372fb8.js">
<script type="module">

import {define} from "./_observablehq/client.00000001.js";
import {registerFile, FileAttachment} from "./_observablehq/stdlib.00000003.js";
import {registerTable} from "./_observablehq/stdlib/duckdb.00000005.js";
import {registerTable} from "./_observablehq/stdlib/duckdb.00000004.js";

registerFile("./table.csv", {"name":"./table.csv","mimeType":"text/csv","path":"./_file/table.b9485148.csv","lastModified":/* ts */1706742000000,"size":12});
registerTable("table", FileAttachment("./table.csv"));
Expand Down