|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +test_description="sync with special manifests file" |
| 4 | + |
| 5 | +. ./lib/sharness.sh |
| 6 | + |
| 7 | +# Create manifest repositories |
| 8 | +manifest_url="file://${HOME}/repositories/hello/manifests" |
| 9 | + |
| 10 | +test_expect_success "setup" ' |
| 11 | + ( |
| 12 | + # create .repo file as a barrier, not find .repo deeper |
| 13 | + touch .repo && |
| 14 | + mkdir repositories && |
| 15 | + cd repositories && |
| 16 | + ln -s "${REPO_TEST_REPOSITORIES}/drivers" . && |
| 17 | + ln -s "${REPO_TEST_REPOSITORIES}/others" . && |
| 18 | + mkdir hello && |
| 19 | + cd hello && |
| 20 | + ln -s "${REPO_TEST_REPOSITORIES}/hello/main.git" . && |
| 21 | + ln -s "${REPO_TEST_REPOSITORIES}/hello/project1.git" . && |
| 22 | + ln -s "${REPO_TEST_REPOSITORIES}/hello/project2.git" . && |
| 23 | + ln -s "${REPO_TEST_REPOSITORIES}/hello/project1" . && |
| 24 | + git clone --mirror \ |
| 25 | + "${REPO_TEST_REPOSITORIES}/hello/manifests.git" \ |
| 26 | + manifests.git |
| 27 | + ) |
| 28 | +' |
| 29 | + |
| 30 | +test_expect_success "setup manifests: no name attr in project element" ' |
| 31 | + ( |
| 32 | + git clone "${manifest_url}.git" manifests && |
| 33 | + cd manifests && |
| 34 | + git checkout master && |
| 35 | +
|
| 36 | + cat >default.xml <<-EOF && |
| 37 | + <?xml version="1.0" encoding="UTF-8"?> |
| 38 | + <manifest> |
| 39 | + <remote name="aone" |
| 40 | + alias="origin" |
| 41 | + fetch="." |
| 42 | + review="https://example.com" /> |
| 43 | + <remote name="driver" |
| 44 | + fetch=".." |
| 45 | + revision="Maint" |
| 46 | + review="https://example.com" /> |
| 47 | + <default remote="aone" |
| 48 | + revision="master" |
| 49 | + sync-j="4" /> |
| 50 | + <project name="main" groups="app"> |
| 51 | + <copyfile src="VERSION" dest="VERSION"></copyfile> |
| 52 | + <linkfile src="Makefile" dest="Makefile"></linkfile> |
| 53 | + </project> |
| 54 | + <project name="project1" path="projects/app1" groups="app"> |
| 55 | + <project name="module1" groups="app" revision="refs/tags/v1.0.0" /> |
| 56 | + </project> |
| 57 | + <project path="projects/app2" groups="app"/> |
| 58 | + <project name="drivers/driver1" path="drivers/driver-1" groups="drivers" remote="driver" /> |
| 59 | + <project name="drivers/driver2" path="drivers/driver-2" groups="notdefault,drivers" remote="driver" /> |
| 60 | + </manifest> |
| 61 | + <!-- no name attr in project element --> |
| 62 | + EOF |
| 63 | + git add -u && |
| 64 | + git commit -m "default.xml: no name attr in project element" && |
| 65 | + git push |
| 66 | + ) |
| 67 | +' |
| 68 | + |
| 69 | +test_expect_success "fail to sync: empty name attr in project" ' |
| 70 | + ( |
| 71 | + mkdir work1 && |
| 72 | + cd work1 && |
| 73 | + git-repo init -u "$manifest_url" && |
| 74 | + test_must_fail git-repo sync \ |
| 75 | + --mock-ssh-info-status 200 \ |
| 76 | + --mock-ssh-info-response \ |
| 77 | + "{\"host\":\"ssh.example.com\", \"port\":22, \"type\":\"agit\"}" >out 2>&1 && |
| 78 | + grep "^FATAL" out >actual && |
| 79 | + cat >expect <<-\EOF && |
| 80 | + FATAL: "project" element has empty "name" |
| 81 | + EOF |
| 82 | + test_cmp expect actual |
| 83 | + ) |
| 84 | +' |
| 85 | + |
| 86 | + |
| 87 | +test_expect_success "setup manifests: no name attr in remote element" ' |
| 88 | + ( |
| 89 | + cd manifests && |
| 90 | +
|
| 91 | + cat >default.xml <<-EOF && |
| 92 | + <?xml version="1.0" encoding="UTF-8"?> |
| 93 | + <manifest> |
| 94 | + <remote |
| 95 | + alias="origin" |
| 96 | + fetch="." |
| 97 | + review="https://example.com" /> |
| 98 | + <remote |
| 99 | + fetch=".." |
| 100 | + revision="Maint" |
| 101 | + review="https://example.com" /> |
| 102 | + <default remote="aone" |
| 103 | + revision="master" |
| 104 | + sync-j="4" /> |
| 105 | + <project name="main" groups="app"> |
| 106 | + <copyfile src="VERSION" dest="VERSION"></copyfile> |
| 107 | + <linkfile src="Makefile" dest="Makefile"></linkfile> |
| 108 | + </project> |
| 109 | + <project name="project1" path="projects/app1" groups="app"> |
| 110 | + <project name="module1" groups="app" revision="refs/tags/v1.0.0" /> |
| 111 | + </project> |
| 112 | + <project name="projects/app2" path="projects/app2" groups="app"/> |
| 113 | + <project name="drivers/driver1" path="drivers/driver-1" groups="drivers" remote="driver" /> |
| 114 | + <project name="drivers/driver2" path="drivers/driver-2" groups="notdefault,drivers" remote="driver" /> |
| 115 | + </manifest> |
| 116 | + <!-- no name attr in remote element --> |
| 117 | + EOF |
| 118 | + git add -u && |
| 119 | + git commit -m "default.xml: no name attr in remote element" && |
| 120 | + git push |
| 121 | + ) |
| 122 | +' |
| 123 | + |
| 124 | +test_expect_success "fail to sync: empty name attr in remote element" ' |
| 125 | + ( |
| 126 | + mkdir work2 && |
| 127 | + cd work2 && |
| 128 | + git-repo init -u "$manifest_url" && |
| 129 | + test_must_fail git-repo sync \ |
| 130 | + --mock-ssh-info-status 200 \ |
| 131 | + --mock-ssh-info-response \ |
| 132 | + "{\"host\":\"ssh.example.com\", \"port\":22, \"type\":\"agit\"}" >out 2>&1 && |
| 133 | + grep "^FATAL" out >actual && |
| 134 | + cat >expect <<-\EOF && |
| 135 | + FATAL: "remote" element has empty "name" |
| 136 | + EOF |
| 137 | + test_cmp expect actual |
| 138 | + ) |
| 139 | +' |
| 140 | + |
| 141 | +test_expect_success "setup manifests: no path attr in project element" ' |
| 142 | + ( |
| 143 | + cd manifests && |
| 144 | +
|
| 145 | + cat >default.xml <<-EOF && |
| 146 | + <?xml version="1.0" encoding="UTF-8"?> |
| 147 | + <manifest> |
| 148 | + <remote name="aone" |
| 149 | + alias="origin" |
| 150 | + fetch="." |
| 151 | + review="https://example.com" /> |
| 152 | + <remote name="driver" |
| 153 | + fetch=".." |
| 154 | + revision="Maint" |
| 155 | + review="https://example.com" /> |
| 156 | + <default remote="aone" |
| 157 | + revision="master" |
| 158 | + sync-j="4" /> |
| 159 | + <project name="main" groups="app"> |
| 160 | + <copyfile src="VERSION" dest="VERSION"></copyfile> |
| 161 | + <linkfile src="Makefile" dest="Makefile"></linkfile> |
| 162 | + </project> |
| 163 | + <project name="project1" path="projects/app1" groups="app"> |
| 164 | + <project name="module1" groups="app" revision="refs/tags/v1.0.0" /> |
| 165 | + </project> |
| 166 | + <project name="project2" path="projects/app2" groups="app"/> |
| 167 | + <project name="drivers/driver1" groups="drivers" remote="driver" /> |
| 168 | + <project name="drivers/driver2" groups="notdefault,drivers" remote="driver" /> |
| 169 | + </manifest> |
| 170 | + <!-- no path attr in project element --> |
| 171 | + EOF |
| 172 | + git add -u && |
| 173 | + git commit -m "default.xml: no path attributes for some projects" && |
| 174 | + git push |
| 175 | + ) |
| 176 | +' |
| 177 | + |
| 178 | +test_expect_success "sync ok for project without path attr" ' |
| 179 | + ( |
| 180 | + mkdir work3 && |
| 181 | + cd work3 && |
| 182 | + git-repo init -u "$manifest_url" && |
| 183 | + git-repo sync \ |
| 184 | + --mock-ssh-info-status 200 \ |
| 185 | + --mock-ssh-info-response \ |
| 186 | + "{\"host\":\"ssh.example.com\", \"port\":22, \"type\":\"agit\"}" && |
| 187 | + test -f main/VERSION && |
| 188 | + test -f projects/app1/VERSION && |
| 189 | + test -f projects/app2/VERSION && |
| 190 | + test -f projects/app1/module1/VERSION && |
| 191 | + test -f drivers/driver1/VERSION |
| 192 | + ) |
| 193 | +' |
| 194 | + |
| 195 | +test_done |
0 commit comments