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.cmmi
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.recipe.cmmi
Commits
3f728307
Commit
3f728307
authored
Nov 30, 2009
by
Kai Lautaportti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the is_build_dir() helper to make it easier to customize.
parent
ceaecd7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
12 deletions
+63
-12
hexagonit/recipe/cmmi/__init__.py
hexagonit/recipe/cmmi/__init__.py
+10
-8
hexagonit/recipe/cmmi/tests.py
hexagonit/recipe/cmmi/tests.py
+53
-4
No files found.
hexagonit/recipe/cmmi/__init__.py
View file @
3f728307
...
...
@@ -67,6 +67,11 @@ class Recipe(object):
log
.
error
(
'Error executing command: %s'
%
cmd
)
raise
zc
.
buildout
.
UserError
(
'System error'
)
def
is_build_dir
(
self
):
"""Returns True if the current directory contains files that we
consider buildable, False otherwise."""
return
os
.
path
.
isfile
(
'configure'
)
or
os
.
path
.
isfile
(
'Makefile.PL'
)
def
install
(
self
):
log
=
logging
.
getLogger
(
self
.
name
)
parts
=
[]
...
...
@@ -94,7 +99,7 @@ class Recipe(object):
if
self
.
options
[
'url'
]:
compile_dir
=
self
.
options
[
'compile-directory'
]
os
.
mkdir
(
compile_dir
)
try
:
opt
=
self
.
options
.
copy
()
opt
[
'destination'
]
=
compile_dir
...
...
@@ -109,22 +114,19 @@ class Recipe(object):
os
.
mkdir
(
self
.
options
[
'location'
])
os
.
chdir
(
compile_dir
)
def
is_build_dir
():
return
os
.
path
.
isfile
(
'configure'
)
or
os
.
path
.
isfile
(
'Makefile.PL'
)
try
:
if
not
is_build_dir
():
if
not
self
.
is_build_dir
():
contents
=
os
.
listdir
(
compile_dir
)
if
len
(
contents
)
==
1
:
os
.
chdir
(
contents
[
0
])
if
not
is_build_dir
():
if
not
self
.
is_build_dir
():
log
.
error
(
'Unable to find the configure script'
)
raise
zc
.
buildout
.
UserError
(
'Invalid package contents'
)
else
:
log
.
error
(
'Unable to find the configure script'
)
raise
zc
.
buildout
.
UserError
(
'Invalid package contents'
)
if
patches
:
log
.
info
(
'Applying patches'
)
for
patch
in
patches
:
...
...
hexagonit/recipe/cmmi/tests.py
View file @
3f728307
from
zope.testing
import
doctest
from
zope.testing
import
renormalizing
import
os
import
re
import
shutil
import
tempfile
import
unittest
import
zc.buildout.tests
import
zc.buildout.testing
import
re
from
zope.testing
import
doctest
,
renormalizing
import
zc.buildout.tests
optionflags
=
(
doctest
.
ELLIPSIS
|
doctest
.
NORMALIZE_WHITESPACE
|
...
...
@@ -14,6 +18,50 @@ def setUp(test):
zc
.
buildout
.
testing
.
install
(
'hexagonit.recipe.download'
,
test
)
zc
.
buildout
.
testing
.
install_develop
(
'hexagonit.recipe.cmmi'
,
test
)
class
NonInformativeTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
dir
=
tempfile
.
mkdtemp
()
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
dir
)
def
write_file
(
self
,
filename
,
contents
):
path
=
os
.
path
.
join
(
self
.
dir
,
filename
)
fh
=
open
(
path
,
'w'
)
fh
.
write
(
contents
)
fh
.
close
()
return
path
def
make_recipe
(
self
,
buildout
,
name
,
options
):
from
hexagonit.recipe.cmmi
import
Recipe
bo
=
{
'buildout'
:
{
'parts-directory'
:
''
,
}
}
bo
.
update
(
buildout
)
return
Recipe
(
bo
,
name
,
options
)
def
test_is_build_dir__with_configure
(
self
):
recipe
=
self
.
make_recipe
({},
'test'
,
{
'url'
:
'http://no.where.com/'
})
os
.
chdir
(
self
.
dir
)
self
.
failIf
(
recipe
.
is_build_dir
())
configure
=
self
.
write_file
(
'configure'
,
'Dummy configure script'
)
self
.
failUnless
(
os
.
path
.
exists
(
configure
))
self
.
failUnless
(
recipe
.
is_build_dir
())
def
test_is_build_dir__with_makefile_pl
(
self
):
recipe
=
self
.
make_recipe
({},
'test'
,
{
'url'
:
'http://no.where.com/'
})
os
.
chdir
(
self
.
dir
)
self
.
failIf
(
recipe
.
is_build_dir
())
makefile
=
self
.
write_file
(
'Makefile.PL'
,
'Dummy Makefile.PL script'
)
self
.
failUnless
(
os
.
path
.
exists
(
makefile
))
self
.
failUnless
(
recipe
.
is_build_dir
())
def
test_suite
():
suite
=
unittest
.
TestSuite
((
doctest
.
DocFileSuite
(
...
...
@@ -29,6 +77,7 @@ def test_suite():
zc
.
buildout
.
testing
.
normalize_path
,
]),
),
unittest
.
makeSuite
(
NonInformativeTests
),
))
return
suite
...
...
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