Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.build
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.recipe.build
Commits
35849c3a
Commit
35849c3a
authored
Jan 18, 2019
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for develop mode
parent
5b69b5c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
10 deletions
+75
-10
slapos/recipe/build/tests.py
slapos/recipe/build/tests.py
+75
-10
No files found.
slapos/recipe/build/tests.py
View file @
35849c3a
...
...
@@ -137,6 +137,14 @@ class GitCloneNonInformativeTests(unittest.TestCase):
myFile
.
write
(
line
)
myFile
.
close
()
def
checkLocalChanges
(
self
,
parent_local_change_path
,
submodule_local_change_path
):
# Check if the file are created at the expected position and check contents
self
.
assertTrue
(
os
.
path
.
exists
(
parent_local_change_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
submodule_local_change_path
))
self
.
assertEqual
(
check_output
([
'cat'
,
parent_local_change_path
]),
'foo'
)
self
.
assertEqual
(
check_output
([
'cat'
,
submodule_local_change_path
]),
'bar'
)
def
makeGitCloneRecipe
(
self
,
options
):
from
slapos.recipe.gitclone
import
Recipe
bo
=
{
...
...
@@ -181,6 +189,71 @@ class GitCloneNonInformativeTests(unittest.TestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
git_repository_path
))
self
.
assertFalse
(
os
.
path
.
exists
(
bad_file_path
),
"pyc file not removed"
)
@
with_buildout
def
test_clone_and_update_submodule_develop_mode
(
self
,
buildout
,
write
,
sample_buildout
,
**
kw
):
"""
Cloning in develop mode should be keeping the local change untouched, same
for update it should do nothing.
"""
self
.
setUpSubmoduleRepository
()
# STEP I: Clone repositories in status M1 and S1 (M1---->S1)
write
(
sample_buildout
,
'buildout.cfg'
,
"""
[buildout]
parts = git-clone
[git-clone]
recipe = slapos.recipe.build:gitclone
repository = %s
develop = true
"""
%
self
.
project_dir
)
check_call
([
buildout
])
main_repo_path
=
os
.
path
.
join
(
sample_buildout
,
'parts'
,
'git-clone'
)
self
.
assertTrue
(
os
.
path
.
exists
(
main_repo_path
))
submodule_repo_path
=
os
.
path
.
join
(
main_repo_path
,
'dir1'
,
'submodule_repo'
)
# Check if the submodule is not empty
self
.
assertTrue
(
os
.
listdir
(
submodule_repo_path
))
# Get the head commit of the submodule repo
head_commit_submodule_after_clone
=
self
.
getRepositoryHeadCommit
(
submodule_repo_path
)
# Add a marker file in parent as well as submodule repo
parent_local_change_path
=
os
.
path
.
join
(
main_repo_path
,
'local_change_main'
)
submodule_local_change_path
=
os
.
path
.
join
(
submodule_repo_path
,
'local_change_submodule'
)
self
.
echo
(
parent_local_change_path
,
'foo'
)
self
.
echo
(
submodule_local_change_path
,
'bar'
)
self
.
checkLocalChanges
(
parent_local_change_path
,
submodule_local_change_path
)
# Update buildout and check local changes which still should be there
# unchanged
check_call
([
buildout
])
self
.
checkLocalChanges
(
parent_local_change_path
,
submodule_local_change_path
)
# Update the builout revision to trigger uninstall and install again. In
# this case, as there have been local changes, buildot will try to keep
# the repository directory
write
(
sample_buildout
,
'buildout.cfg'
,
"""
[buildout]
parts = git-clone
[git-clone]
recipe = slapos.recipe.build:gitclone
repository = %s
revision = %s
develop = true
"""
%
(
self
.
project_dir
,
str
(
self
.
getRepositoryHeadCommit
(
self
.
project_dir
))))
check_call
([
buildout
])
# The local changes should be still there
self
.
checkLocalChanges
(
parent_local_change_path
,
submodule_local_change_path
)
@
with_buildout
def
test_clone_and_update_submodule
(
self
,
buildout
,
write
,
sample_buildout
,
**
kw
):
...
...
@@ -232,21 +305,13 @@ repository = %s
'local_change_submodule'
)
self
.
echo
(
parent_local_change_path
,
'foo'
)
self
.
echo
(
submodule_local_change_path
,
'bar'
)
# Check if the file are created at the expected position and check contents
self
.
assertTrue
(
os
.
path
.
exists
(
parent_local_change_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
submodule_local_change_path
))
self
.
assertEqual
(
check_output
([
'cat'
,
parent_local_change_path
]),
'foo'
)
self
.
assertEqual
(
check_output
([
'cat'
,
submodule_local_change_path
]),
'bar'
)
self
.
checkLocalChanges
(
parent_local_change_path
,
submodule_local_change_path
)
# Update buildout
check_call
([
buildout
])
# The local changes should be still there
self
.
assertTrue
(
os
.
path
.
exists
(
parent_local_change_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
submodule_local_change_path
))
self
.
assertEqual
(
check_output
([
'cat'
,
parent_local_change_path
]),
'foo'
)
self
.
assertEqual
(
check_output
([
'cat'
,
submodule_local_change_path
]),
'bar'
)
self
.
checkLocalChanges
(
parent_local_change_path
,
submodule_local_change_path
)
# Update submodule repository and main repo separately
self
.
touch
(
self
.
project_dir
,
'file2.py'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment