From 96a80fc4c807c2fa4d38bdbd4cc2f854bb19e743 Mon Sep 17 00:00:00 2001 From: Belden Lyman Date: Wed, 4 Dec 2024 17:44:08 -0800 Subject: [PATCH] Add test case for proper csv escaping I generated the _test.go.{csv,json} files by using a version of ginkgo built from the next commit. If tests are run on this sha, they are expected to fail; the next commit fixes them. --- .../outline/_testdata/csv_proper_escaping_test.go | 14 ++++++++++++++ .../_testdata/csv_proper_escaping_test.go.csv | 6 ++++++ .../_testdata/csv_proper_escaping_test.go.json | 1 + ginkgo/outline/_testdata/position_test.go.csv | 4 ++-- ginkgo/outline/outline_test.go | 1 + 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 ginkgo/outline/_testdata/csv_proper_escaping_test.go create mode 100644 ginkgo/outline/_testdata/csv_proper_escaping_test.go.csv create mode 100644 ginkgo/outline/_testdata/csv_proper_escaping_test.go.json diff --git a/ginkgo/outline/_testdata/csv_proper_escaping_test.go b/ginkgo/outline/_testdata/csv_proper_escaping_test.go new file mode 100644 index 0000000000..2a22022a2b --- /dev/null +++ b/ginkgo/outline/_testdata/csv_proper_escaping_test.go @@ -0,0 +1,14 @@ +package example_test + +import ( + . "github.com/onsi/ginkgo/v2" +) + +var _ = Describe("Abnormal\"Fixture", func() { + When("four random words: flown, authenticating, semiweekly, and overproduction", func() { + It("has a dangling double-quote here: \"", func() { + By("step 1") + By("step 2") + }) + }) +}) diff --git a/ginkgo/outline/_testdata/csv_proper_escaping_test.go.csv b/ginkgo/outline/_testdata/csv_proper_escaping_test.go.csv new file mode 100644 index 0000000000..7eb7154ff1 --- /dev/null +++ b/ginkgo/outline/_testdata/csv_proper_escaping_test.go.csv @@ -0,0 +1,6 @@ +Name,Text,Start,End,Spec,Focused,Pending,Labels +Describe,"Abnormal""Fixture",73,300,false,false,false, +When,"four random words: flown, authenticating, semiweekly, and overproduction",113,297,false,false,false, +It,"has a dangling double-quote here: """,205,293,true,false,false, +By,step 1,260,272,false,false,false, +By,step 2,276,288,false,false,false, diff --git a/ginkgo/outline/_testdata/csv_proper_escaping_test.go.json b/ginkgo/outline/_testdata/csv_proper_escaping_test.go.json new file mode 100644 index 0000000000..b4f0e124ba --- /dev/null +++ b/ginkgo/outline/_testdata/csv_proper_escaping_test.go.json @@ -0,0 +1 @@ +[{"name":"Describe","text":"Abnormal\"Fixture","start":73,"end":300,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"When","text":"four random words: flown, authenticating, semiweekly, and overproduction","start":113,"end":297,"spec":false,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"It","text":"has a dangling double-quote here: \"","start":205,"end":293,"spec":true,"focused":false,"pending":false,"labels":[],"nodes":[{"name":"By","text":"step 1","start":260,"end":272,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]},{"name":"By","text":"step 2","start":276,"end":288,"spec":false,"focused":false,"pending":false,"labels":null,"nodes":[]}]}]}]}] diff --git a/ginkgo/outline/_testdata/position_test.go.csv b/ginkgo/outline/_testdata/position_test.go.csv index 1255bbefa6..af267c0a99 100644 --- a/ginkgo/outline/_testdata/position_test.go.csv +++ b/ginkgo/outline/_testdata/position_test.go.csv @@ -1,3 +1,3 @@ Name,Text,Start,End,Spec,Focused,Pending,Labels -Describe,104,240,104,240,false,false,false,"" -It,209,236,209,236,true,false,false,"" +Describe,"104,240",104,240,false,false,false, +It,"209,236",209,236,true,false,false, diff --git a/ginkgo/outline/outline_test.go b/ginkgo/outline/outline_test.go index 1163c4bdd9..5ef816fcb8 100644 --- a/ginkgo/outline/outline_test.go +++ b/ginkgo/outline/outline_test.go @@ -65,6 +65,7 @@ var _ = DescribeTable("Validate outline from file with", Entry("core dsl import", "dsl_core_test.go", "dsl_core_test.go.json", "dsl_core_test.go.csv"), Entry("labels decorator on containers and specs", "labels_test.go", "labels_test.go.json", "labels_test.go.csv"), Entry("pending decorator on containers and specs", "pending_decorator_test.go", "pending_decorator_test.go.json", "pending_decorator_test.go.csv"), + Entry("proper csv escaping of all fields", "csv_proper_escaping_test.go", "csv_proper_escaping_test.go.json", "csv_proper_escaping_test.go.csv"), ) var _ = Describe("Validate position", func() {