Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-python
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-python
Commits
cd52da61
Commit
cd52da61
authored
Jan 24, 2017
by
Kenneth Reitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tell travis to run the tests
parent
acd93479
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1324 additions
and
4 deletions
+1324
-4
.travis.yml
.travis.yml
+6
-2
Makefile
Makefile
+6
-2
requirements.txt
test/fixtures/psycopg2/requirements.txt
+1
-0
requirements.txt
test/fixtures/requirements-standard/requirements.txt
+1
-0
setup.py
test/fixtures/setup-py/setup.py
+0
-0
run
test/run
+72
-0
shunit2
test/shunit2
+1048
-0
utils
test/utils
+190
-0
No files found.
.travis.yml
View file @
cd52da61
sudo
:
false
script
:
exit 0
language
:
bash
sudo
:
required
services
:
-
docker
install
:
docker pull heroku/cedar:14
script
:
make test
Makefile
View file @
cd52da61
# These targets are not files
.PHONY
:
tests
tests
:
./bin/test
test
:
test-cedar-14
test-cedar-14
:
@
echo
"Running tests in docker (cedar-14)..."
@
docker run
-v
$(
shell
pwd
)
:/buildpack:ro
--rm
-it
-e
"STACK=cedar-14"
heroku/cedar:14 bash
-c
'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;'
@
echo
""
tools
:
git clone https://github.com/kennethreitz/pip-pop.git
...
...
test/fixtures/psycopg2/requirements.txt
0 → 100644
View file @
cd52da61
psycopg2
\ No newline at end of file
test/fixtures/requirements-standard/requirements.txt
0 → 100644
View file @
cd52da61
requests
\ No newline at end of file
test/fixtures/setup-py/setup.py
0 → 100644
View file @
cd52da61
test/run
0 → 100755
View file @
cd52da61
#!/usr/bin/env bash
# See README.md for info on running these tests.
testStandardRequirements
()
{
compile
"requirements-standard"
assertCaptured
"requests"
assertCapturedSuccess
}
testPsycopg2
()
{
compile
"psycopg2"
assertCaptured
"psycopg2"
assertCapturedSuccess
}
pushd
$(
dirname
0
)
>
/dev/null
popd
>
/dev/null
source
$(
pwd
)
/test/utils
mktmpdir
()
{
dir
=
$(
mktemp
-t
testXXXXX
)
rm
-rf
$dir
mkdir
$dir
echo
$dir
}
detect
()
{
capture
$(
pwd
)
/bin/detect
$(
pwd
)
/test/fixtures/
$1
}
compile_dir
=
""
default_process_types_cleanup
()
{
file
=
"/tmp/default_process_types"
if
[
-f
"
$file
"
]
;
then
rm
"
$file
"
fi
}
compile
()
{
default_process_types_cleanup
bp_dir
=
$(
mktmpdir
)
compile_dir
=
$(
mktmpdir
)
cp
-a
$(
pwd
)
/
*
${
bp_dir
}
cp
-a
${
bp_dir
}
/test/fixtures/
$1
/.
${
compile_dir
}
capture
${
bp_dir
}
/bin/compile
${
compile_dir
}
${
2
:-$(
mktmpdir
)}
$3
}
compileDir
()
{
default_process_types_cleanup
local
bp_dir
=
$(
mktmpdir
)
local
compile_dir
=
${
1
:-$(
mktmpdir
)}
local
cache_dir
=
${
2
:-$(
mktmpdir
)}
local
env_dir
=
$3
cp
-a
$(
pwd
)
/
*
${
bp_dir
}
capture
${
bp_dir
}
/bin/compile
${
compile_dir
}
${
cache_dir
}
${
env_dir
}
}
release
()
{
bp_dir
=
$(
mktmpdir
)
cp
-a
$(
pwd
)
/
*
${
bp_dir
}
capture
${
bp_dir
}
/bin/release
${
bp_dir
}
/test/fixtures/
$1
}
assertFile
()
{
assertEquals
"
$1
"
"
$(
cat
${
compile_dir
}
/
$2
)
"
}
source
$(
pwd
)
/test/shunit2
test/shunit2
0 → 100755
View file @
cd52da61
This diff is collapsed.
Click to expand it.
test/utils
0 → 100644
View file @
cd52da61
#!/bin/sh
# taken from
# https://github.com/ryanbrainard/heroku-buildpack-testrunner/blob/master/lib/test_utils.sh
oneTimeSetUp
()
{
TEST_SUITE_CACHE
=
"
$(
mktemp
-d
${
SHUNIT_TMPDIR
}
/test_suite_cache.XXXX
)
"
}
oneTimeTearDown
()
{
rm
-rf
${
TEST_SUITE_CACHE
}
}
setUp
()
{
OUTPUT_DIR
=
"
$(
mktemp
-d
${
SHUNIT_TMPDIR
}
/output.XXXX
)
"
STD_OUT
=
"
${
OUTPUT_DIR
}
/stdout"
STD_ERR
=
"
${
OUTPUT_DIR
}
/stderr"
BUILD_DIR
=
"
${
OUTPUT_DIR
}
/build"
CACHE_DIR
=
"
${
OUTPUT_DIR
}
/cache"
mkdir
-p
${
OUTPUT_DIR
}
mkdir
-p
${
BUILD_DIR
}
mkdir
-p
${
CACHE_DIR
}
}
tearDown
()
{
rm
-rf
${
OUTPUT_DIR
}
}
capture
()
{
resetCapture
LAST_COMMAND
=
"
$@
"
$@
>
${
STD_OUT
}
2>
${
STD_ERR
}
RETURN
=
$?
rtrn
=
${
RETURN
}
# deprecated
}
resetCapture
()
{
if
[
-f
${
STD_OUT
}
]
;
then
rm
${
STD_OUT
}
fi
if
[
-f
${
STD_ERR
}
]
;
then
rm
${
STD_ERR
}
fi
unset
LAST_COMMAND
unset
RETURN
unset
rtrn
# deprecated
}
detect
()
{
capture
${
BUILDPACK_HOME
}
/bin/detect
${
BUILD_DIR
}
}
compile
()
{
capture
${
BUILDPACK_HOME
}
/bin/compile
${
BUILD_DIR
}
${
CACHE_DIR
}
}
release
()
{
capture
${
BUILDPACK_HOME
}
/bin/release
${
BUILD_DIR
}
}
assertCapturedEquals
()
{
assertEquals
"
$@
"
"
$(
cat
${
STD_OUT
})
"
}
assertCapturedNotEquals
()
{
assertNotEquals
"
$@
"
"
$(
cat
${
STD_OUT
})
"
}
assertCaptured
()
{
assertFileContains
"
$@
"
"
${
STD_OUT
}
"
}
assertNotCaptured
()
{
assertFileNotContains
"
$@
"
"
${
STD_OUT
}
"
}
assertCapturedSuccess
()
{
assertEquals
"Expected captured exit code to be 0; was <
${
RETURN
}
>"
"0"
"
${
RETURN
}
"
assertEquals
"Expected STD_ERR to be empty; was <
$(
cat
${
STD_ERR
})
>"
""
"
$(
cat
${
STD_ERR
})
"
}
# assertCapturedError [[expectedErrorCode] expectedErrorMsg]
assertCapturedError
()
{
if
[
$#
-gt
1
]
;
then
local
expectedErrorCode
=
${
1
}
shift
fi
local
expectedErrorMsg
=
${
1
:-
""
}
if
[
-z
${
expectedErrorCode
}
]
;
then
assertTrue
"Expected captured exit code to be greater than 0; was <
${
RETURN
}
>"
"[
${
RETURN
}
-gt 0 ]"
else
assertTrue
"Expected captured exit code to be <
${
expectedErrorCode
}
>; was <
${
RETURN
}
>"
"[
${
RETURN
}
-eq
${
expectedErrorCode
}
]"
fi
if
[
"
${
expectedErrorMsg
}
"
!=
""
]
;
then
assertFileContains
"Expected STD_ERR to contain error <
${
expectedErrorMsg
}
>"
"
${
expectedErrorMsg
}
"
"
${
STD_ERR
}
"
fi
}
_assertContains
()
{
if
[
5
-eq
$#
]
;
then
local
msg
=
$1
shift
elif
[
!
4
-eq
$#
]
;
then
fail
"Expected 4 or 5 parameters; Receieved
$#
parameters"
fi
local
needle
=
$1
local
haystack
=
$2
local
expectation
=
$3
local
haystack_type
=
$4
case
"
${
haystack_type
}
"
in
"file"
)
grep
-q
-F
-e
"
${
needle
}
"
${
haystack
}
;;
"text"
)
echo
"
${
haystack
}
"
|
grep
-q
-F
-e
"
${
needle
}
"
;;
esac
if
[
"
${
expectation
}
"
!=
"
$?
"
]
;
then
case
"
${
expectation
}
"
in
0
)
default_msg
=
"Expected <
${
haystack
}
> to contain <
${
needle
}
>"
;;
1
)
default_msg
=
"Did not expect <
${
haystack
}
> to contain <
${
needle
}
>"
;;
esac
fail
"
${
msg
:-${
default_msg
}}
"
fi
}
assertContains
()
{
_assertContains
"
$@
"
0
"text"
}
assertNotContains
()
{
_assertContains
"
$@
"
1
"text"
}
assertFileContains
()
{
_assertContains
"
$@
"
0
"file"
}
assertFileNotContains
()
{
_assertContains
"
$@
"
1
"file"
}
command_exists
()
{
type
"
$1
"
>
/dev/null 2>&1
;
}
assertFileMD5
()
{
expectedHash
=
$1
filename
=
$2
if
command_exists
"md5sum"
;
then
md5_cmd
=
"md5sum
${
filename
}
"
expected_md5_cmd_output
=
"
${
expectedHash
}
${
filename
}
"
elif
command_exists
"md5"
;
then
md5_cmd
=
"md5
${
filename
}
"
expected_md5_cmd_output
=
"MD5 (
${
filename
}
) =
${
expectedHash
}
"
else
fail
"no suitable MD5 hashing command found on this system"
fi
assertEquals
"
${
expected_md5_cmd_output
}
"
"
`
${
md5_cmd
}
`
"
}
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