Commit f15399e3 authored by Marius Wachtler's avatar Marius Wachtler

Merge pull request #1119 from undingen/paste_test

add a paste, pylons and routes integration test
parents b0253978 c6c4356b
......@@ -75,7 +75,7 @@ before_script:
script:
- ccache -z
- ninja -j4 pyston check-deps && PYSTON_RUN_ARGS=G travis_wait 30 ctest --output-on-failure
- ninja -j4 pyston check-deps && PYSTON_RUN_ARGS=G travis_wait 45 ctest --output-on-failure
- ccache -s
- if [ -n "$(git status --porcelain --untracked=no)" ]; then echo "test suite left the source directory dirty"; git status; false; fi
......
......@@ -1702,7 +1702,7 @@ Box* _strSlice(BoxedString* self, i64 start, i64 stop, i64 step, i64 length) {
return bs;
}
static Box* str_slice(Box* o, Py_ssize_t i, Py_ssize_t j) {
static Box* str_slice(Box* o, Py_ssize_t i, Py_ssize_t j) noexcept {
BoxedString* a = static_cast<BoxedString*>(o);
if (i < 0)
i = 0;
......@@ -1721,7 +1721,7 @@ static Box* str_slice(Box* o, Py_ssize_t i, Py_ssize_t j) {
}
// Analoguous to CPython's, used for sq_ slots.
static Py_ssize_t str_length(Box* a) {
static Py_ssize_t str_length(Box* a) noexcept {
return Py_SIZE(a);
}
......@@ -2081,18 +2081,24 @@ Box* strSwapcase(BoxedString* self) {
return rtn;
}
static inline int string_contains_shared(BoxedString* self, Box* elt) {
template <ExceptionStyle S> static inline int stringContainsShared(BoxedString* self, Box* elt) noexcept(S == CAPI) {
assert(PyString_Check(self));
if (PyUnicode_Check(elt)) {
int r = PyUnicode_Contains(self, elt);
if (r < 0)
if (r < 0 && S == CXX)
throwCAPIException();
return r;
}
if (!PyString_Check(elt))
raiseExcHelper(TypeError, "'in <string>' requires string as left operand, not %s", getTypeName(elt));
if (!PyString_Check(elt)) {
if (S == CXX)
raiseExcHelper(TypeError, "'in <string>' requires string as left operand, not %s", getTypeName(elt));
else {
PyErr_Format(TypeError, "'in <string>' requires string as left operand, not %s", getTypeName(elt));
return -1;
}
}
BoxedString* sub = static_cast<BoxedString*>(elt);
......@@ -2106,12 +2112,12 @@ static inline int string_contains_shared(BoxedString* self, Box* elt) {
}
// Analoguous to CPython's, used for sq_ slots.
static int string_contains(PyObject* str_obj, PyObject* sub_obj) {
return string_contains_shared((BoxedString*)str_obj, sub_obj);
static int string_contains(PyObject* str_obj, PyObject* sub_obj) noexcept {
return stringContainsShared<CAPI>((BoxedString*)str_obj, sub_obj);
}
Box* strContains(BoxedString* self, Box* elt) {
return boxBool(string_contains_shared(self, elt));
return boxBool(stringContainsShared<CXX>(self, elt));
}
// compares (a+a_pos, len) with (str)
......@@ -2310,11 +2316,12 @@ Box* strEncode(BoxedString* self, Box* encoding, Box* error) {
return result;
}
static PyObject* string_item(PyStringObject* self, register Py_ssize_t i) {
static PyObject* string_item(PyStringObject* self, register Py_ssize_t i) noexcept {
BoxedString* boxedString = (BoxedString*)self;
if (i < 0 || i >= boxedString->size()) {
raiseExcHelper(IndexError, "string index out of range");
PyErr_SetString(PyExc_IndexError, "string index out of range");
return NULL;
}
char c = boxedString->s()[i];
......
# expected: fail
# The paste test suite uses pytest, so this test file incentally also tests pytest.
# Pytest relies quite heavily on a number of code introspection features, which
# we currently don't have. This includes:
# 1) The ast module
# 2) traceback.tb_frame, traceback.tb_next
import os, sys, subprocess
sys.path.append(os.path.dirname(__file__) + "/../lib")
......@@ -13,21 +6,38 @@ from test_helper import create_virtenv, run_test
ENV_NAME = "paste_test_env_" + os.path.basename(sys.executable)
PYTHON_EXE = os.path.abspath(os.path.join(ENV_NAME, "bin", "python"))
PYTEST_EXE = os.path.abspath(os.path.join(ENV_NAME, "bin", "py.test"))
PASTE_DIR = os.path.abspath(os.path.join(ENV_NAME, "paste"))
PASTE_TEST_DIR = os.path.abspath(os.path.join(PASTE_DIR, "tests"))
packages = ["pytest", "paste", "nose==1.3.7"]
packages = ["py==1.4.31", "pytest==2.8.7", "nose==1.3.7"]
create_virtenv(ENV_NAME, packages, force_create = True)
# Need the test files in the source
subprocess.check_call(["hg", "clone", "https://bitbucket.org/ianb/paste"], cwd=ENV_NAME)
url = "https://pypi.python.org/packages/source/P/Paste/Paste-1.7.5.tar.gz"
subprocess.check_call(["wget", url], cwd=ENV_NAME)
subprocess.check_call(["tar", "-zxf", "Paste-1.7.5.tar.gz"], cwd=ENV_NAME)
PASTE_DIR = os.path.abspath(os.path.join(ENV_NAME, "Paste-1.7.5"))
PASTE_TEST_DIR = os.path.abspath(os.path.join(PASTE_DIR, "tests"))
print ">> "
print ">> Setting up paste..."
print ">> "
subprocess.check_call([PYTHON_EXE, "setup.py", "build"], cwd=PASTE_DIR)
print ">> "
print ">> Installing paste..."
print ">> "
subprocess.check_call([PYTHON_EXE, "setup.py", "install"], cwd=PASTE_DIR)
print ">> "
print ">> Running paste tests..."
print ">> "
subprocess.check_call([PYTEST_EXE], cwd=PASTE_TEST_DIR)
# current cpython also does not pass all tests. (9 failed, 127 passed)
# the additional test we fail are because:
# - we have str.__iter__
# - no sys.settrace
# - no shiftjis encoding
# - slightly different error messages
expected = [{"failed" : 22, "passed" : 112}]
run_test([PYTEST_EXE], cwd=PASTE_TEST_DIR, expected=expected)
import os, sys, subprocess, shutil
sys.path.append(os.path.dirname(__file__) + "/../lib")
from test_helper import create_virtenv, run_test
ENV_NAME = "pylons_test_env_" + os.path.basename(sys.executable)
SRC_DIR = os.path.abspath(os.path.join(ENV_NAME, "src"))
PYTHON_EXE = os.path.abspath(os.path.join(ENV_NAME, "bin", "python"))
NOSE_EXE = os.path.abspath(os.path.join(ENV_NAME, "bin", "nosetests"))
def install_and_test_pylons():
shutil.rmtree(SRC_DIR, ignore_errors=True)
os.makedirs(SRC_DIR)
url = "https://pypi.python.org/packages/source/P/Pylons/Pylons-0.9.6.2.tar.gz"
subprocess.check_call(["wget", url], cwd=SRC_DIR)
subprocess.check_call(["tar", "-zxf", "Pylons-0.9.6.2.tar.gz"], cwd=SRC_DIR)
PYLONS_DIR = os.path.abspath(os.path.join(SRC_DIR, "Pylons-0.9.6.2"))
subprocess.check_call([PYTHON_EXE, "setup.py", "install"], cwd=PYLONS_DIR)
# most of the errors are because of our coerceUnicodeToStr which raises a TypeError instead of a UnicodeError
# but as we don't support the unicode string correctly every where I don't want to change this currently.
expected = [{ "ran": 50, "errors": 7}]
run_test([NOSE_EXE], cwd=PYLONS_DIR, expected=expected)
pkg = [ "Mako==1.0.3",
"decorator==4.0.9",
"simplejson==3.8.2",
"FormEncode==1.3.0",
"PasteScript==2.0.2",
"PasteDeploy==1.5.2",
"Paste==2.0.2",
"Beaker==1.8.0",
"WebHelpers==1.3",
"Routes==2.2",
"MarkupSafe==0.23",
"six==1.10.0",
"funcsigs==0.4",
"repoze.lru==0.6",
"nose==1.3.7"]
create_virtenv(ENV_NAME, pkg, force_create = True)
install_and_test_pylons()
import os, sys, subprocess, shutil
sys.path.append(os.path.dirname(__file__) + "/../lib")
from test_helper import create_virtenv, run_test
ENV_NAME = "routes_test_env_" + os.path.basename(sys.executable)
SRC_DIR = os.path.abspath(os.path.join(ENV_NAME, "src"))
PYTHON_EXE = os.path.abspath(os.path.join(ENV_NAME, "bin", "python"))
pkg = ["nose==1.3.7", "paste==2.0.2", "six==1.10.0"]
pkg += ["-e", "git+https://github.com/bbangert/routes.git@v1.7.3#egg=Routes"]
create_virtenv(ENV_NAME, pkg, force_create = True)
ROUTES_DIR = os.path.abspath(os.path.join(SRC_DIR, "routes"))
expected = [{ "ran" : 141 }]
run_test([PYTHON_EXE, "setup.py", "test"], cwd=ROUTES_DIR, expected=expected)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment