Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ruby-build
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ruby-build
Commits
c7851c51
Commit
c7851c51
authored
Oct 25, 2013
by
Mislav Marohnić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for Homebrew libyaml integration
parent
892ac959
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
1 deletions
+132
-1
test/build.bats
+81
-0
test/fixtures/definitions/needs-yaml
+2
-0
test/test_helper.bash
+49
-1
No files found.
test/build.bats
0 → 100644
View file @
c7851c51
#!/usr/bin/env bats
load test_helper
tarball() {
local name="$1"
local path="$TMP/$name"
local configure="$path/configure"
mkdir -p "$path"
cat > "$configure" <<OUT
#!$BASH
echo "$name: \$@" > build.log
OUT
chmod +x "$configure"
tar czf "${path}.tgz" -C "$TMP" "$name"
echo "${path}.tgz"
}
stub_download() {
stub curl "-C - -o * -*S* $1 : cp '$(tarball "$2")' \$4"
}
@test "yaml is installed for ruby" {
mkdir -p "$INSTALL_ROOT/bin"
stub md5 false
stub brew false
stub_download "http://pyyaml.org/*" "yaml-0.1.4"
stub_download "http://ruby-lang.org/*" "ruby-2.0.0"
stub make \
' : echo make "$@" >> build.log' \
"install : cp build.log '$INSTALL_ROOT/yaml.log'" \
' : echo make "$@" >> build.log' \
"install : cp build.log '$INSTALL_ROOT/ruby.log'"
install_fixture definitions/needs-yaml
assert_success
unstub curl
unstub make
run cat "$INSTALL_ROOT/yaml.log"
assert_output <<OUT
yaml-0.1.4: --prefix=$INSTALL_ROOT
make -j 2
OUT
run cat "$INSTALL_ROOT/ruby.log"
assert_output <<OUT
ruby-2.0.0: --prefix=$INSTALL_ROOT
make -j 2
OUT
}
@test "yaml is linked from Homebrew" {
brew_libdir="$TMP/homebrew-yaml"
mkdir -p "$INSTALL_ROOT/bin"
mkdir -p "$brew_libdir"
stub md5 false
stub brew "--prefix libyaml : echo '$brew_libdir'"
stub_download "http://ruby-lang.org/*" "ruby-2.0.0"
stub make \
' : echo make "$@" >> build.log' \
"install : cp build.log '$INSTALL_ROOT/ruby.log'"
install_fixture definitions/needs-yaml
assert_success
unstub brew
unstub curl
unstub make
run cat "$INSTALL_ROOT/ruby.log"
assert_output <<OUT
ruby-2.0.0: --prefix=$INSTALL_ROOT --with-libyaml-dir=$brew_libdir
make -j 2
OUT
}
test/fixtures/definitions/needs-yaml
0 → 100644
View file @
c7851c51
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz" --if needs_yaml
install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
test/test_helper.bash
View file @
c7851c51
...
...
@@ -23,7 +23,6 @@ stub() {
mkdir
-p
"
${
TMP
}
/bin"
ln
-shf
"
${
BATS_TEST_DIRNAME
}
/stubs/stub"
"
${
TMP
}
/bin/
${
program
}
"
rm
-f
"
${
TMP
}
/
${
program
}
-stub-plan"
"
${
TMP
}
/
${
program
}
-stub-run"
touch
"
${
TMP
}
/
${
program
}
-stub-plan"
for
arg
in
"
$@
"
;
do
printf
"%s
\n
"
"
$arg
"
>>
"
${
TMP
}
/
${
program
}
-stub-plan"
;
done
}
...
...
@@ -37,6 +36,7 @@ unstub() {
"
$path
"
rm
-f
"
$path
"
rm
-f
"
${
TMP
}
/
${
program
}
-stub-plan"
"
${
TMP
}
/
${
program
}
-stub-run"
}
install_fixture
()
{
...
...
@@ -46,3 +46,51 @@ install_fixture() {
run ruby-build
"
$FIXTURE_ROOT
/
$name
"
"
$destination
"
}
assert
()
{
if
!
"
$@
"
;
then
flunk
"failed:
$@
"
fi
}
flunk
()
{
{
if
[
"$#"
-eq
0
]
;
then
cat
-
else
echo
"
$@
"
fi
}
| sed
"s:
${
TMP
}
:
\$
{TMP}:g"
>
&2
return
1
}
assert_success
()
{
if
[
"
$status
"
-ne
0
]
;
then
{
echo
"command failed with exit status
$status
"
echo
"output:
$output
"
}
| flunk
elif
[
"$#"
-gt
0
]
;
then
assert_output
"
$1
"
fi
}
assert_failure
()
{
if
[
"
$status
"
-eq
0
]
;
then
flunk
"expected failed exit status"
elif
[
"$#"
-gt
0
]
;
then
assert_output
"
$1
"
fi
}
assert_equal
()
{
if
[
"
$1
"
!=
"
$2
"
]
;
then
{
echo
"expected:
$1
"
echo
"actual:
$2
"
}
| flunk
fi
}
assert_output
()
{
local
expected
if
[
$#
-eq
0
]
;
then
expected
=
"
$(
cat
-
)
"
else
expected
=
"
$1
"
fi
assert_equal
"
$expected
"
"
$output
"
}
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