@@ -10,6 +10,7 @@ import (
1010 "io"
1111 "os"
1212 "os/exec"
13+ "path/filepath"
1314 "strings"
1415 "testing"
1516
@@ -27,6 +28,7 @@ func TestRemoteLoad_LocalProtocol(t *testing.T) {
2728 root string
2829 simple string
2930 noSuffix string
31+ hash string
3032 multiBaseDev string
3133 withSubmodule string
3234 }
@@ -35,9 +37,10 @@ func TestRemoteLoad_LocalProtocol(t *testing.T) {
3537 // root/
3638 // simple.git/ - base with just a pod
3739 // nosuffix/ - same as simple.git/ without the .git suffix
40+ // hash-xx/ - same as simple.git/ with random hash at xx
3841 // multibase.git/ - base with a dev overlay
3942 // with-submodule.git/ - includes `simple` as a submodule
40- // submodule/ - the submodule referencing `simple
43+ // submodule/ - the submodule referencing `simple`
4144 createGitRepos := func (t * testing.T ) testRepos {
4245 t .Helper ()
4346
@@ -49,10 +52,16 @@ func TestRemoteLoad_LocalProtocol(t *testing.T) {
4952 }
5053 }
5154 root := t .TempDir ()
55+
56+ hashPath , err := os .MkdirTemp (root , "hash-" )
57+ require .NoError (t , err )
58+ hashDir := filepath .Base (hashPath )
59+
5260 bash (fmt .Sprintf (`
5361set -eux
5462
5563export ROOT="%s"
64+ export HASH_DIR="%s"
56655766export GIT_AUTHOR_NAME=Nobody
5867@@ -84,19 +93,27 @@ cp -r testdata/remoteload/multibase $ROOT/multibase.git
8493 git add .
8594 git commit -m "import"
8695)
96+ cp -r testdata/remoteload/with-submodule $ROOT/with-submodule.git # see README
97+ cp -r $ROOT/simple.git/. $ROOT/$HASH_DIR
8798(
88- mkdir $ROOT/with-submodule.git
8999 cd $ROOT/with-submodule.git
90100 git init --initial-branch=main
91- git submodule add $ROOT/simple.git submodule
101+ git add .
92102 git commit -m "import"
103+ git checkout -b relative-submodule
104+ git submodule add ../$HASH_DIR submodule
105+ git commit -m "relative submodule"
106+ git checkout main
107+ git submodule add $ROOT/simple.git submodule
108+ git commit -m "submodule"
93109)
94- ` , root ))
110+ ` , root , hashDir ))
95111 return testRepos {
96112 root : root ,
97113 // The strings below aren't currently used, and more serve as documentation.
98114 simple : "simple.git" ,
99115 noSuffix : "nosuffix" ,
116+ hash : hashDir ,
100117 multiBaseDev : "multibase.git" ,
101118 withSubmodule : "with-submodule.git" ,
102119 }
@@ -182,6 +199,15 @@ resources:
182199` ,
183200 expected : simpleBuild ,
184201 },
202+ {
203+ name : "has relative submodule" ,
204+ kustomization : `
205+ resources:
206+ - file://$ROOT/with-submodule.git/submodule?ref=relative-submodule
207+ ` ,
208+ // TODO(annasong): Replace with simpleBuild once #5131 is fixed.
209+ err : `failed to run '\S+/git submodule update --init --recursive'` ,
210+ },
185211 {
186212 name : "has timeout" ,
187213 kustomization : `
@@ -272,7 +298,7 @@ resources:
272298
273299 if test .err != "" {
274300 require .Error (t , err )
275- require .Contains (t , err .Error (), test . err )
301+ require .Regexp (t , test . err , err .Error ())
276302 } else {
277303 require .NoError (t , err )
278304 checkYaml (t , m , strings .ReplaceAll (test .expected , "$ROOT" , repos .root ))
0 commit comments