Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | // Copyright 2022 The Dawn & Tint Authors |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 2 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | // Redistribution and use in source and binary forms, with or without |
| 4 | // modification, are permitted provided that the following conditions are met: |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 5 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | // 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | // list of conditions and the following disclaimer. |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 8 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | // 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 Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 27 | |
| 28 | package roll |
| 29 | |
| 30 | import ( |
| 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 | |
| 39 | func 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 Clayton | b0eae2c | 2024-03-20 22:03:13 +0000 | [diff] [blame] | 47 | func rollCommitMessageFor(ctsGitURL string) string { |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 48 | 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 Clayton | b0eae2c | 2024-03-20 22:03:13 +0000 | [diff] [blame] | 56 | flags: rollerFlags{ctsGitURL: ctsGitURL}, |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 57 | } |
Ben Clayton | b0eae2c | 2024-03-20 22:03:13 +0000 | [diff] [blame] | 58 | |
| 59 | r.cfg.Git.CTS.Host = "chromium.googlesource.com" |
| 60 | r.cfg.Git.CTS.Project = "external/github.com/gpuweb/cts" |
| 61 | |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 62 | 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 Clayton | b0eae2c | 2024-03-20 22:03:13 +0000 | [diff] [blame] | 77 | |
| 78 | return msg |
| 79 | } |
| 80 | |
| 81 | func TestRollCommitMessageFromInternal(t *testing.T) { |
| 82 | msg := rollCommitMessageFor("https://chromium.googlesource.com/external/github.com/gpuweb/cts") |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 83 | expect := `Roll third_party/webgpu-cts/ d5e605a55..29275672e (2 commits) |
| 84 | |
Ben Clayton | 19f6cf9 | 2022-11-17 22:38:04 +0000 | [diff] [blame] | 85 | Regenerated: |
Austin Eng | faf98b1 | 2022-06-10 18:33:23 +0000 | [diff] [blame] | 86 | - expectations.txt |
Gregg Tavares | 3fea189 | 2023-11-01 13:01:16 +0000 | [diff] [blame] | 87 | - compat-expectations.txt |
Austin Eng | faf98b1 | 2022-06-10 18:33:23 +0000 | [diff] [blame] | 88 | - ts_sources.txt |
Ben Clayton | 19f6cf9 | 2022-11-17 22:38:04 +0000 | [diff] [blame] | 89 | - test_list.txt |
Austin Eng | faf98b1 | 2022-06-10 18:33:23 +0000 | [diff] [blame] | 90 | - resource_files.txt |
| 91 | - webtest .html files |
| 92 | |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 93 | |
| 94 | https://chromium.googlesource.com/external/github.com/gpuweb/cts/+log/d5e605a55640..29275672eefe |
| 95 | - d5e605 Added thing A |
| 96 | - d5e605 Tweaked thing B |
| 97 | |
| 98 | Created with './tools/run cts roll' |
| 99 | |
| 100 | Cq-Include-Trybots: luci.chromium.try:linux-dawn-rel,win-dawn-rel;luci.dawn.try:mac-dbg |
Ben Clayton | 62f8e73 | 2022-09-27 19:29:56 +0000 | [diff] [blame] | 101 | Include-Ci-Only-Tests: true |
Ben Clayton | 8495aff | 2022-05-03 16:58:43 +0000 | [diff] [blame] | 102 | Change-Id: I4aa059c6c183e622975b74dbdfdfe0b12341ae15 |
| 103 | ` |
| 104 | if diff := cmp.Diff(msg, expect); diff != "" { |
| 105 | t.Errorf("rollCommitMessage: %v", diff) |
| 106 | } |
| 107 | } |
Ben Clayton | b0eae2c | 2024-03-20 22:03:13 +0000 | [diff] [blame] | 108 | |
| 109 | func 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 | |
| 114 | Rolled from external repo: https://www.github.com/a_cts_contributor/cts.git |
| 115 | |
| 116 | Regenerated: |
| 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 | |
| 125 | https://chromium.googlesource.com/external/github.com/gpuweb/cts/+log/d5e605a55640..29275672eefe |
| 126 | - d5e605 Added thing A |
| 127 | - d5e605 Tweaked thing B |
| 128 | |
| 129 | Created with './tools/run cts roll' |
| 130 | |
| 131 | Cq-Include-Trybots: luci.chromium.try:linux-dawn-rel,win-dawn-rel;luci.dawn.try:mac-dbg |
| 132 | Include-Ci-Only-Tests: true |
| 133 | Commit: false |
| 134 | Change-Id: I4aa059c6c183e622975b74dbdfdfe0b12341ae15 |
| 135 | ` |
| 136 | if diff := cmp.Diff(msg, expect); diff != "" { |
| 137 | t.Errorf("rollCommitMessage: %v", diff) |
| 138 | } |
| 139 | } |