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

Remove break for constructing test-level metadata #2694

Closed
wants to merge 5 commits into from
Closed
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: 2 additions & 6 deletions shared/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,8 @@ func constructMetadataResponse(productSpecs ProductSpecs, includeTestLevel bool,
for _, result := range link.Results {
//TODO(kyleju): Concatenate test path on WPT Metadata repository instead of here.
fullTestName := GetWPTTestPath(folderPath, result.TestPath)

if link.Product.BrowserName == "" {
if includeTestLevel {
addResponseLink(fullTestName, link, result, res)
}
break
if link.Product.BrowserName == "" && includeTestLevel {
addResponseLink(fullTestName, link, result, res)
}

// Find any matching product for this link result (there can be at most one).
Expand Down
29 changes: 20 additions & 9 deletions shared/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ links:
label: labelB
results:
- test: d.html
- test: e.html
`)
yaml.Unmarshal(metadataInBytes, &metadata)
acutalInBytes, _ := yaml.Marshal(metadata)
Expand Down Expand Up @@ -63,6 +64,7 @@ links:
- label: labelA
results:
- test: c.html
- test: e.html
`)

metadatamap := parseMetadata(metadataByteMap, NewNilLogger())
Expand All @@ -85,6 +87,7 @@ links:
assert.Equal(t, TestStatusFail, *(metadatamap[path].Links[1].Results[0].Status))
assert.Equal(t, "labelA", metadatamap[path].Links[2].Label)
assert.Equal(t, "c.html", metadatamap[path].Links[2].Results[0].TestPath)
assert.Equal(t, "e.html", metadatamap[path].Links[2].Results[1].TestPath)
}

func TestConstructMetadataResponse_OneLink(t *testing.T) {
Expand Down Expand Up @@ -123,24 +126,30 @@ func TestConstructMetadataResponse_OneLink(t *testing.T) {
},
MetadataLink{
Label: labelB,
Results: []MetadataTestResult{{
TestPath: "a.html",
}},
Results: []MetadataTestResult{
{
TestPath: "a.html",
},
{
TestPath: "e.html",
},
},
},
},
},
}

MetadataResults := constructMetadataResponse(productSpecs, true, metadataMap)

assert.Equal(t, 1, len(MetadataResults))
assert.Equal(t, 2, len(MetadataResults))
assert.Equal(t, 4, len(MetadataResults["/foo/bar/a.html"]))
assert.Equal(t, "https://external.com/item", MetadataResults["/foo/bar/a.html"][0].URL)
assert.True(t, ParseProductSpecUnsafe("chrome").MatchesProductSpec(MetadataResults["/foo/bar/a.html"][0].Product))
assert.Equal(t, "https://bug.com/item", MetadataResults["/foo/bar/a.html"][1].URL)
assert.True(t, ParseProductSpecUnsafe("firefox").MatchesProductSpec(MetadataResults["/foo/bar/a.html"][1].Product))
assert.Equal(t, label, MetadataResults["/foo/bar/a.html"][2].Label)
assert.Equal(t, labelB, MetadataResults["/foo/bar/a.html"][3].Label)
assert.Equal(t, labelB, MetadataResults["/foo/bar/e.html"][0].Label)

// Remove test-level metadata.
MetadataResults = constructMetadataResponse(productSpecs, false, metadataMap)
Expand Down Expand Up @@ -276,27 +285,29 @@ func TestConstructMetadataResponse_TestIssueMetadata(t *testing.T) {
ParseProductSpecUnsafe("Chrome"),
ParseProductSpecUnsafe("Safari"),
}
label := "labelA"
metadataMap := map[string]Metadata{
"foo/bar": Metadata{
Links: []MetadataLink{
MetadataLink{
Product: ProductSpec{},
URL: "https://bug.com/item",
Label: label,
Results: []MetadataTestResult{{
TestPath: "a.html",
}},
},
{
TestPath: "e.html",
},
},
},
},
},
}

MetadataResults := constructMetadataResponse(productSpecs, true, metadataMap)
assert.Equal(t, 1, len(MetadataResults))
assert.Equal(t, 2, len(MetadataResults))
assert.Equal(t, 1, len(MetadataResults["/foo/bar/a.html"]))
assert.Equal(t, "https://bug.com/item", MetadataResults["/foo/bar/a.html"][0].URL)
assert.Equal(t, label, MetadataResults["/foo/bar/a.html"][0].Label)
assert.Equal(t, "https://bug.com/item", MetadataResults["/foo/bar/e.html"][0].URL)

MetadataResults = constructMetadataResponse(productSpecs, false, metadataMap)
assert.Equal(t, 0, len(MetadataResults))
Expand Down