summaryrefslogtreecommitdiff
path: root/automatelorrytest
blob: e96247fa01811730ebfc631639805b6c5cce06ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#!/bin/sh
bzrTest()
{
  #every test start from lorry script directory to be 
  #base directory and should return to it after the 
  #test
  echo "----------------"
  echo "starting BZR test..."
  echo "----------------"

  mkdir -p repobzr/trunk
  bzr init-repo repobzr #creating repo
  cd repobzr
  bzr init trunk  #creating trunk
  cd trunk
  echo "Bzr Test file" > testbzr.txt 
  bzr add testbzr.txt #adding file to repo
  echo "Second line" >> testbzr.txt
  bzr commit -m "Added second line of text" #commiting a change
  cd ../../  #going back to base directory
  echo "{ 
         \"BZR\":{ 
         \"type\":\"bzr\", 
         \"url\":\"file://`pwd`/repobzr/trunk\"
         }
        } " > atl.lorry
  echo "running bzr lorry test"
  ./lorry --pull-only --log=atl.log  atl.lorry  -w `pwd`/workd
  cd workd/BZR/git 
  test=`git branch`
  if [ "$test" = "  trunk" ]
  then
    echo "bzr repo success in lorry"
    cd ../../../
    rm -fr workd/BZR repobzr
  else
    echo "bzr repo failed in lorry"
    exit 1
  fi
  
  
  
}
tarTest()
{
  #every test start from lorry script directory to be 
  #base directory and should return to it after the 
  #test
  #rm atl.lorry
  echo "----------------"
  echo "tar ball test..."
  echo "----------------"

  mkdir repotar
  #cd repotar
  echo "tar file gzip/lzma/bzip2" > repotar/testg-l.txt
  tar -czf repotar.tar.gz repotar/
  tar -cf repotar.tar.lzma repotar/ --lzma
  tar -cf repotar.tar.bzip2 repotar/ --bzip2
 # cd ..
  echo "{ 
         \"targzip\":{ 
         \"type\":\"tarball\",
         \"compression\":\"gzip\",
         \"strip\": 1, 
         \"url\":\"file://`pwd`/repotar.tar.gz\"
         },
         \"tarlzma\":{ 
         \"type\":\"tarball\",
         \"compression\":\"lzma\",
         \"strip\": 1, 
         \"url\":\"file://`pwd`/repotar.tar.lzma\"
         },
          \"tarbzip2\":{ 
         \"type\":\"tarball\",
         \"compression\":\"bzip2\",
         \"strip\": 1, 
         \"url\":\"file://`pwd`/repotar.tar.bzip2\"
         }

        } " > atl.lorry
   echo "going to tar gzip and lzma test"
  ./lorry --pull-only --log=atl.log atl.lorry -w `pwd`/workd 
  test1=`find workd/tarlzma/git/ -name testg-l.txt`
  test2=`find workd/targzip/git/ -name testg-l.txt`
  test3=`find workd/tarbzip2/git/ -name testg-l.txt`
  if  [ "$test1" = ""  ] || [ "$test2" = ""  ] || [ "$test3" = "" ] 
  then

     echo "tar repo fail in lorry test"
     exit 1
  else
     echo "tar repo success in lorry test"
     rm -fr workd/tar* repotar
     rm -fr repotar.tar.*
  fi
 

}
svnTest()
{
   #every test start from lorry script directory to be 
  #base directory and should return to it after the 
  #test
   echo "----------------"
   echo "Starting svn test..."
   echo "----------------"
 
   rm -fr reposvn localhost branches #if there is any
   mkdir reposvn
   svnadmin create `pwd`/reposvn
   #changes to configuration svn files
   sed -r -e's/^# (password-db.*)/\1/g' -i `pwd`/reposvn/conf/svnserve.conf  
   
   sed -r -e's/^# (anon-access.*)/\1/g' -i `pwd`/reposvn/conf/svnserve.conf  
   sed -r -e's/^# (auth-access.*)/\1/g' -i `pwd`/reposvn/conf/svnserve.conf
   echo "adnan = test" >> `pwd`/reposvn/conf/passwd #creat test password
   #run server svn
   killall svnserve
   svnserve -d --root `pwd`/reposvn
   #checkout repo add trunk directory and add test file and commit
   svn co svn://localhost
   cd localhost
   svn mkdir branches tags trunk
   echo "hello" > trunk/test.txt
   svn add trunk/test.txt
   svn commit  --username adnan --password test -m "trunk added" --no-auth-cache
   
   cd ..
   rm -fr localhost   #remove workd for lorry checkout
   echo "{ 
         \"SVN\":{ 
         \"type\":\"svn\", 
         \"url\":\"svn://localhost\",
         \"layout\":\"standard\"
         }
        } " > atl.lorry
   echo "going to run svn lorry test"
  ./lorry --pull-only --log=atl.log atl.lorry -w `pwd`/workd
  cd workd/SVN/git 
  test=`git branch`
  if [ -z  "$test"  ]
  then

     echo "svn repo fail in lorry test"
     exit 1
  else
     echo "svn repo success in lorry test"
     cd ../../../
     rm -fr workd/SVN   reposvn
  fi
  
   
}

gitTest()
{
  #every test start from lorry script directory to be 
  #base directory and should return to it after the 
  #test
  echo "----------------"
  echo "git repo test..."
  echo "----------------"

  rm -fr repogit
  mkdir repogit
  cd repogit
  git init 
  echo "test git repo file" > test.txt
  git add .
  git commit -m "first file commit"
  cd ..
  echo "{ 
         \"git\":{ 
         \"type\":\"git\", 
         \"url\":\"file://`pwd`/repogit\"
         }
        } " > atl.lorry  
  echo "going to run git lorry test"
  ./lorry --pull-only --log=atl.log atl.lorry -w `pwd`/workd
  cd workd/git/git
  test=`git branch`
  if [ "$test" = "* master"  ]
  then

     echo "git repo success in lorry test"
     cd  ../../../
     rm -fr workd/git repogit
  else
     echo "git repo fail in lorry test"
     exit 1
  fi
 
    
}

hgTest()
{
  #every test start from lorry script directory to be 
  #base directory and should return to it after the 
  #test
  echo "----------------"
  echo "hg repo test..."
  echo "----------------"

  rm -fr repohg
  mkdir repohg
  cd repohg
  hg init
  touch readme
  hg add readme
  hg commit -u adnan -m "test commit"
  cd ..
  echo "comming out of repo"
  echo "{ 
         \"hg\":{ 
         \"type\":\"hg\", 
         \"url\":\"file://`pwd`/repohg\"
         }
        } " > atl.lorry
  echo "going to run hg lorry test" `pwd`
  ./lorry --pull-only  --log=lorry.log atl.lorry -w `pwd`/workd    

  test=`find workd/hg/hg/ -name readme`
  if [ -z  "$test"  ]
  then

     echo "hg repo fail in lorry test"
     exit 1
  else
     echo "hg repo success in lorry test"
     rm -fr workd/hg repohg
     
  fi


}

cvsTest()
{
   #every test start from lorry script directory to be 
  #base directory and should return to it after the 
  #test
  echo "----------------"
  echo "cvs repo test..."
  echo "----------------"

  rm -fr repocvs
  mkdir repocvs

  export CVSROOT=`pwd`/repocvs
  export CVS_RSH=
  cd repocvs
  cvs init
  cd ..
  cvs checkout CVSROOT
  cd CVSROOT
  touch readmetoo
  cvs add readmetoo
  cvs commit  -m "first file added to cvs"
  cd ..
 rm -fr CVSROOT  
  echo "{ 
         \"cvs\":{ 
         \"type\":\"cvs\", 
         \"url\":\"`pwd`/repocvs\",
          \"module\":\"CVSROOT\"
         }
        } " > atl.lorry
  echo "going to run cvs lorry test" `pwd`
  
  ./lorry --pull-only  --log=lorry.log atl.lorry -w `pwd`/workd
 
  test=`find workd/cvs/git/ -name readmetoo` 
  if [ -z  "$test"  ]
  then

     echo "cvs repo fail in lorry test"
     exit 1
  else
     echo "cvs repo success in lorry test"
     rm -fr workd/cvs repocvs
  fi
    
  
}
main()
{
  ##initial requriment for test
  #rm -fr workd
  rm -fr repobzr/  repogit/ reposvn/ repotar repohg/ repocvs/ repotar.tar.* workd/ atl.*
  mkdir workd
}

main
bzrTest $@
tarTest
svnTest
gitTest
hgTest
cvsTest