blob: 5ec304c007d3283ab7b3c51e3db15a9b13b523ab [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001// Copyright 2022 The Dawn & Tint Authors
Ben Clayton8495aff2022-05-03 16:58:43 +00002//
Austin Engcc2516a2023-10-17 20:57:54 +00003// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions are met:
Ben Clayton8495aff2022-05-03 16:58:43 +00005//
Austin Engcc2516a2023-10-17 20:57:54 +00006// 1. Redistributions of source code must retain the above copyright notice, this
7// list of conditions and the following disclaimer.
Ben Clayton8495aff2022-05-03 16:58:43 +00008//
Austin Engcc2516a2023-10-17 20:57:54 +00009// 2. Redistributions in binary form must reproduce the above copyright notice,
10// this list of conditions and the following disclaimer in the documentation
11// and/or other materials provided with the distribution.
12//
13// 3. Neither the name of the copyright holder nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Ben Clayton8495aff2022-05-03 16:58:43 +000027
28package roll
29
30import (
31 "testing"
32
33 "dawn.googlesource.com/dawn/tools/src/buildbucket"
34 "dawn.googlesource.com/dawn/tools/src/cmd/cts/common"
35 "dawn.googlesource.com/dawn/tools/src/git"
36 "github.com/google/go-cmp/cmp"
37)
38
39func MustParseHash(s string) git.Hash {
40 hash, err := git.ParseHash("d5e605a556408eaeeda64fb9d33c3f596fd90b70")
41 if err != nil {
42 panic(err)
43 }
44 return hash
45}
46
Ben Claytonb0eae2c2024-03-20 22:03:13 +000047func rollCommitMessageFor(ctsGitURL string) string {
Ben Clayton8495aff2022-05-03 16:58:43 +000048 r := roller{
49 cfg: common.Config{
50 Builders: map[string]buildbucket.Builder{
51 "Win": {Project: "chromium", Bucket: "try", Builder: "win-dawn-rel"},
52 "Mac": {Project: "dawn", Bucket: "try", Builder: "mac-dbg"},
53 "Linux": {Project: "chromium", Bucket: "try", Builder: "linux-dawn-rel"},
54 },
55 },
Ben Claytonb0eae2c2024-03-20 22:03:13 +000056 flags: rollerFlags{ctsGitURL: ctsGitURL},
Ben Clayton8495aff2022-05-03 16:58:43 +000057 }
Ben Claytonb0eae2c2024-03-20 22:03:13 +000058
59 r.cfg.Git.CTS.Host = "chromium.googlesource.com"
60 r.cfg.Git.CTS.Project = "external/github.com/gpuweb/cts"
61
Ben Clayton8495aff2022-05-03 16:58:43 +000062 msg := r.rollCommitMessage(
63 "d5e605a556408eaeeda64fb9d33c3f596fd90b70",
64 "29275672eefe76986bd4baa7c29ed17b66616b1b",
65 []git.CommitInfo{
66 {
67 Hash: MustParseHash("d5e605a556408eaeeda64fb9d33c3f596fd90b70"),
68 Subject: "Added thing A",
69 },
70 {
71 Hash: MustParseHash("29275672eefe76986bd4baa7c29ed17b66616b1b"),
72 Subject: "Tweaked thing B",
73 },
74 },
75 "I4aa059c6c183e622975b74dbdfdfe0b12341ae15",
76 )
Ben Claytonb0eae2c2024-03-20 22:03:13 +000077
78 return msg
79}
80
81func TestRollCommitMessageFromInternal(t *testing.T) {
82 msg := rollCommitMessageFor("https://chromium.googlesource.com/external/github.com/gpuweb/cts")
Ben Clayton8495aff2022-05-03 16:58:43 +000083 expect := `Roll third_party/webgpu-cts/ d5e605a55..29275672e (2 commits)
84
Ben Clayton19f6cf92022-11-17 22:38:04 +000085Regenerated:
Austin Engfaf98b12022-06-10 18:33:23 +000086 - expectations.txt
Gregg Tavares3fea1892023-11-01 13:01:16 +000087 - compat-expectations.txt
Austin Engfaf98b12022-06-10 18:33:23 +000088 - ts_sources.txt
Ben Clayton19f6cf92022-11-17 22:38:04 +000089 - test_list.txt
Austin Engfaf98b12022-06-10 18:33:23 +000090 - resource_files.txt
91 - webtest .html files
92
Ben Clayton8495aff2022-05-03 16:58:43 +000093
94https://chromium.googlesource.com/external/github.com/gpuweb/cts/+log/d5e605a55640..29275672eefe
95 - d5e605 Added thing A
96 - d5e605 Tweaked thing B
97
98Created with './tools/run cts roll'
99
100Cq-Include-Trybots: luci.chromium.try:linux-dawn-rel,win-dawn-rel;luci.dawn.try:mac-dbg
Ben Clayton62f8e732022-09-27 19:29:56 +0000101Include-Ci-Only-Tests: true
Ben Clayton8495aff2022-05-03 16:58:43 +0000102Change-Id: I4aa059c6c183e622975b74dbdfdfe0b12341ae15
103`
104 if diff := cmp.Diff(msg, expect); diff != "" {
105 t.Errorf("rollCommitMessage: %v", diff)
106 }
107}
Ben Claytonb0eae2c2024-03-20 22:03:13 +0000108
109func TestRollCommitMessageFromExternal(t *testing.T) {
110 msg := rollCommitMessageFor("https://www.github.com/a_cts_contributor/cts.git")
111
112 expect := `[DO NOT` + ` SUBMIT] Roll third_party/webgpu-cts/ d5e605a55..29275672e (2 commits)
113
114Rolled from external repo: https://www.github.com/a_cts_contributor/cts.git
115
116Regenerated:
117 - expectations.txt
118 - compat-expectations.txt
119 - ts_sources.txt
120 - test_list.txt
121 - resource_files.txt
122 - webtest .html files
123
124
125https://chromium.googlesource.com/external/github.com/gpuweb/cts/+log/d5e605a55640..29275672eefe
126 - d5e605 Added thing A
127 - d5e605 Tweaked thing B
128
129Created with './tools/run cts roll'
130
131Cq-Include-Trybots: luci.chromium.try:linux-dawn-rel,win-dawn-rel;luci.dawn.try:mac-dbg
132Include-Ci-Only-Tests: true
133Commit: false
134Change-Id: I4aa059c6c183e622975b74dbdfdfe0b12341ae15
135`
136 if diff := cmp.Diff(msg, expect); diff != "" {
137 t.Errorf("rollCommitMessage: %v", diff)
138 }
139}