From 36b0b81636943bca83ff38ece54fd1c5a26ba86b Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 15 Sep 2023 11:57:01 +0200 Subject: [PATCH 1/4] fix: escape names that might collide with other operations --- tooling/test/test.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tooling/test/test.go b/tooling/test/test.go index f9a470843..787f1a2eb 100644 --- a/tooling/test/test.go +++ b/tooling/test/test.go @@ -3,6 +3,8 @@ package test import ( "context" "net/http" + "net/url" + "strings" "testing" "time" @@ -68,8 +70,10 @@ func run(t *testing.T, tests SugarTests) { timeout, cancel := context.WithTimeout(context.Background(), 2*time.Minute) defer cancel() + name := safeName(test.Name) + if len(test.Requests) > 0 { - t.Run(test.Name, func(t *testing.T) { + t.Run(name, func(t *testing.T) { tooling.LogSpecs(t, test.AllSpecs()...) responses := make([]*http.Response, 0, len(test.Requests)) @@ -82,7 +86,7 @@ func run(t *testing.T, tests SugarTests) { validateResponses(t, test.Responses, responses) }) } else { - t.Run(test.Name, func(t *testing.T) { + t.Run(name, func(t *testing.T) { tooling.LogSpecs(t, test.AllSpecs()...) _, res, localReport := runRequest(timeout, t, test, test.Request) validateResponse(t, test.Response, res, localReport) @@ -90,3 +94,16 @@ func run(t *testing.T, tests SugarTests) { } } } + +func safeName(s string) string { + // Split the string by spaces + parts := strings.Split(s, " ") + + // Escape each part + for i, part := range parts { + parts[i] = url.PathEscape(part) + } + + // Join the parts back together with spaces + return strings.Join(parts, " ") +} From 21d62bf63f118086c2e233207a89173b87fcbfe8 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 15 Sep 2023 14:47:48 +0200 Subject: [PATCH 2/4] fix: test outputs encodings --- munge_aggregates.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/munge_aggregates.js b/munge_aggregates.js index 26cbc52f4..50e4dd8af 100644 --- a/munge_aggregates.js +++ b/munge_aggregates.js @@ -107,7 +107,7 @@ const main = async () => { for (const row of testsRows) { const { versions, full_name, name, parent_test_full_name } = row; - const slug = slugify(full_name); + const slug = slugifyTestName(full_name); if (!groups[parent_test_full_name]) { groups[parent_test_full_name] = {}; @@ -285,7 +285,7 @@ const main = async () => { const testResults = {}; for (const row of rows) { - testResults[row.full_name] = { ...row, slug: slugify(row.full_name) }; + testResults[row.full_name] = { ...row, slug: slugifyTestName(row.full_name) }; } outputJSON(`data/testresults/${id}/${version}.json`, testResults); } @@ -310,8 +310,9 @@ const main = async () => { const testsTaxonomy = {}; for (const row of testsTaxonomyRows) { - const { full_name, name, test_run_implementation_id, test_run_version } = row; - const slug = slugify(full_name); + const { full_name, test_run_implementation_id, test_run_version } = row; + const slug = slugifyTestName(full_name); + const name = decodeURIComponent(row.name); if (!testsTaxonomy[full_name]) { testsTaxonomy[full_name] = { @@ -349,6 +350,7 @@ const main = async () => { test_run_implementation_id AS implementation_id, test_run_version AS version, full_name, + name, outcome FROM TestResult ORDER BY test_run_implementation_id, test_run_version, full_name @@ -358,7 +360,8 @@ const main = async () => { const resultsTaxonomy = {}; for (const row of resultsTaxonomyRows) { const { implementation_id, version, full_name, outcome } = row; - const slug = slugify(full_name); + const slug = slugifyTestName(full_name); + const name = decodeURIComponent(row.name); if (!resultsTaxonomy[implementation_id]) { resultsTaxonomy[implementation_id] = {}; @@ -371,6 +374,7 @@ const main = async () => { if (!resultsTaxonomy[implementation_id][version][full_name]) { resultsTaxonomy[implementation_id][version][full_name] = { slug, + name, full_name, outcome, }; @@ -395,7 +399,7 @@ const main = async () => { ...test, implementation_id, version, - title: test.full_name + title: test.name }); } } @@ -418,12 +422,28 @@ const slugify = (str) => { .trim() // trim leading or trailing whitespace .toLowerCase() // convert to lowercase .replace(/\s+/g, '_') // replace spaces with underscore + .replace(/[.,()"/]/g, '-') // remove the characters (, ) and ~ + .replace(/[^a-z0-9 -\/]/g, '-') // remove non-alphanumeric characters .replace(/_+/g, '_') // remove consecutive underscores - .replace(/[\/]/g, "__") - .replace(/[^a-z0-9 -]/g, '-') // remove non-alphanumeric characters .replace(/-+/g, '-') // remove consecutive dashes } +const slugifyTestName = (str) => { + let x = String(str).split('/'); + x = x.map(part => { + // url decode to handle %20, etc + part = decodeURIComponent(part); + return slugify(part.replace(/([a-z])([A-Z])/g, '$1-$2') // Convert CamelCase to kebab-case + ) + }) + return x.join('/'); +} + +const extractTestName = (str) => { + let x = String(str).split('/'); + return decodeURIComponent(x[x.length - 1]); +} + const outputJSON = (p, data) => { const json = JSON.stringify(data, null, 2); const fullPath = `${hugoOutput}/${p}`; From 03ca35225b2505c1a303fcc04c6d761d08ad114a Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 15 Sep 2023 15:41:50 +0200 Subject: [PATCH 3/4] feat: add redirects --- www/content/results/_index.md | 4 ++++ www/content/tests/_index.md | 4 ++++ www/themes/conformance/layouts/partials/head.html | 6 ++++++ 3 files changed, 14 insertions(+) create mode 100644 www/content/results/_index.md create mode 100644 www/content/tests/_index.md diff --git a/www/content/results/_index.md b/www/content/results/_index.md new file mode 100644 index 000000000..3b7340f91 --- /dev/null +++ b/www/content/results/_index.md @@ -0,0 +1,4 @@ +--- +title: Tests +redirectsTo: /current +--- diff --git a/www/content/tests/_index.md b/www/content/tests/_index.md new file mode 100644 index 000000000..3b7340f91 --- /dev/null +++ b/www/content/tests/_index.md @@ -0,0 +1,4 @@ +--- +title: Tests +redirectsTo: /current +--- diff --git a/www/themes/conformance/layouts/partials/head.html b/www/themes/conformance/layouts/partials/head.html index d56ffd290..666c1b3d6 100644 --- a/www/themes/conformance/layouts/partials/head.html +++ b/www/themes/conformance/layouts/partials/head.html @@ -1,2 +1,8 @@ {{ $styles := resources.Get "style.css" }} + +{{ with .Params.RedirectsTo }} + +{{ end }} + +{{ .Params.RedirectsTo }} \ No newline at end of file From abe966b49e478871d841aac764bf5c51cc505233 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 15 Sep 2023 15:53:36 +0200 Subject: [PATCH 4/4] feat: drop dead code --- munge_aggregates.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/munge_aggregates.js b/munge_aggregates.js index 50e4dd8af..117a1000b 100644 --- a/munge_aggregates.js +++ b/munge_aggregates.js @@ -439,11 +439,6 @@ const slugifyTestName = (str) => { return x.join('/'); } -const extractTestName = (str) => { - let x = String(str).split('/'); - return decodeURIComponent(x[x.length - 1]); -} - const outputJSON = (p, data) => { const json = JSON.stringify(data, null, 2); const fullPath = `${hugoOutput}/${p}`;