Skip to content

Commit

Permalink
Fix e2etests report generation and update testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed Jan 28, 2023
1 parent 192cb10 commit 654475f
Show file tree
Hide file tree
Showing 22 changed files with 766 additions and 729 deletions.
5 changes: 5 additions & 0 deletions d2compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func (c *compiler) compileMap(obj *d2graph.Object, m *d2ir.Map) {

func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) {
keyword := strings.ToLower(f.Name)
_, isStyleReserved := d2graph.StyleKeywords[keyword]
if isStyleReserved {
c.errorf(f.LastRef().AST(), "%v must be style.%v", f.Name, f.Name)
return
}
_, isReserved := d2graph.SimpleReservedKeywords[keyword]
if isReserved {
c.compileReserved(obj.Attributes, f)
Expand Down
14 changes: 7 additions & 7 deletions d2renderers/d2sketch/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestSketch(t *testing.T) {
}
People discovery: "People discovery \nservice"
admixer: Ad mixer {
fill: "#c1a2f3"
style.fill: "#c1a2f3"
}
onboarding service: "Onboarding \nservice"
Expand Down Expand Up @@ -107,7 +107,7 @@ Android: {
web -> twitter fe
timeline scorer: "Timeline\nScorer" {
fill: "#ffdef1"
style.fill "#ffdef1"
}
home ranker: Home Ranker
Expand All @@ -119,7 +119,7 @@ timeline mixer -> home ranker: {
}
timeline mixer -> timeline service
home mixer: Home mixer {
# fill: "#c1a2f3"
# style.fill "#c1a2f3"
}
container0.graphql -> home mixer: {
style.stroke-dash: 4
Expand All @@ -146,23 +146,23 @@ prediction service2: Prediction Service {
icon: https://cdn-icons-png.flaticon.com/512/6461/6461819.png
}
home scorer: Home Scorer {
fill: "#ffdef1"
style.fill "#ffdef1"
}
manhattan: Manhattan
memcache: Memcache {
icon: https://d1q6f0aelx0por.cloudfront.net/product-logos/de041504-0ddb-43f6-b89e-fe04403cca8d-memcached.png
}
fetch: Fetch {
multiple: true
style.multiple: true
shape: step
}
feature: Feature {
multiple: true
style.multiple: true
shape: step
}
scoring: Scoring {
multiple: true
style.multiple: true
shape: step
}
fetch -> feature
Expand Down
20 changes: 10 additions & 10 deletions d2renderers/d2sketch/testdata/twitter/sketch.exp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions e2etests/report/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"flag"
"fmt"
"io/ioutil"
stdlog "log"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -144,6 +145,13 @@ func main() {
}

path := os.Getenv("REPORT_OUTPUT")
if path == "" {
path = filepath.Join(testDir, "./out/e2e_report.html")
}
err = os.MkdirAll(filepath.Dir(path), 0755)
if err != nil {
stdlog.Fatal(err)
}
f, err := os.Create(path)
if err != nil {
panic(fmt.Errorf("error creating file `%s`. %v", path, err))
Expand Down
6 changes: 3 additions & 3 deletions e2etests/report/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<div class="cases">
{{range .Tests}}
<div class="case">
<h1><a href="../{{.GotSVG}}">{{.Name}}</a></h1>
<h1><a href="../../{{.GotSVG}}">{{.Name}}</a></h1>
{{ if .ExpSVG }}
<h2>Expected</h2>
<img src="../{{.ExpSVG}}" width="100%" />
<img src="../../{{.ExpSVG}}" width="100%" />
<h2>Got</h2>
{{ end }}
<img src="../{{.GotSVG}}" width="100%" />
<img src="../../{{.GotSVG}}" width="100%" />
</div>
{{end}}
</div>
Expand Down
82 changes: 41 additions & 41 deletions e2etests/stable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ callout -> stored_data -> person
diamond -> oval -> circle
hexagon -> cloud
rectangle.multiple: true
square.multiple: true
page.multiple: true
parallelogram.multiple: true
document.multiple: true
cylinder.multiple: true
queue.multiple: true
package.multiple: true
step.multiple: true
callout.multiple: true
stored_data.multiple: true
person.multiple: true
diamond.multiple: true
oval.multiple: true
circle.multiple: true
hexagon.multiple: true
cloud.multiple: true
rectangle.style.multiple: true
square.style.multiple: true
page.style.multiple: true
parallelogram.style.multiple: true
document.style.multiple: true
cylinder.style.multiple: true
queue.style.multiple: true
package.style.multiple: true
step.style.multiple: true
callout.style.multiple: true
stored_data.style.multiple: true
person.style.multiple: true
diamond.style.multiple: true
oval.style.multiple: true
circle.style.multiple: true
hexagon.style.multiple: true
cloud.style.multiple: true
`,
},
{
Expand Down Expand Up @@ -126,23 +126,23 @@ callout -> stored_data -> person
diamond -> oval -> circle
hexagon -> cloud
rectangle.shadow: true
square.shadow: true
page.shadow: true
parallelogram.shadow: true
document.shadow: true
cylinder.shadow: true
queue.shadow: true
package.shadow: true
step.shadow: true
callout.shadow: true
stored_data.shadow: true
person.shadow: true
diamond.shadow: true
oval.shadow: true
circle.shadow: true
hexagon.shadow: true
cloud.shadow: true
rectangle.style.shadow: true
square.style.shadow: true
page.style.shadow: true
parallelogram.style.shadow: true
document.style.shadow: true
cylinder.style.shadow: true
queue.style.shadow: true
package.style.shadow: true
step.style.shadow: true
callout.style.shadow: true
stored_data.style.shadow: true
person.style.shadow: true
diamond.style.shadow: true
oval.style.shadow: true
circle.style.shadow: true
hexagon.style.shadow: true
cloud.style.shadow: true
`,
},
{
Expand All @@ -153,8 +153,8 @@ square: {shape: "square"}
rectangle -> square
rectangle.3d: true
square.3d: true
rectangle.style.3d: true
square.style.3d: true
`,
},
{
Expand Down Expand Up @@ -1109,17 +1109,17 @@ scorer.t -> itemOutcome.t3: setFeedback(missingConcepts)`,
script: `shape: sequence_diagram
scorer: {
stroke: red
stroke-width: 5
style.stroke: red
style.stroke-width: 5
}
scorer.abc: {
fill: yellow
stroke-width: 7
style.fill: yellow
style.stroke-width: 7
}
scorer -> itemResponse.a: {
stroke-width: 10
style.stroke-width: 10
}
itemResponse.a -> item.a.b
item.a.b -> essayRubric.a.b.c
Expand Down
Loading

0 comments on commit 654475f

Please sign in to comment.