Merge pull request #1713 from RustPython/coolreader18/no-azure

Fix up some testing stuff; only build one target profile of rustpython when testing
This commit is contained in:
Noah
2020-01-28 12:58:29 -08:00
committed by GitHub
6 changed files with 27 additions and 32 deletions

View File

@@ -1,4 +1,7 @@
on: [push, pull_request]
on:
push:
branches: [master]
pull_request:
name: CI

View File

@@ -352,11 +352,11 @@ assert bytearray(b"hjhtuyfjtyhuhjuyj").translate(None, delete=b"ht") == bytearra
# strip lstrip rstrip
assert bytearray(b" spacious ").strip() == bytearray(b"spacious")
assert bytearray(b" \n spacious \n ").strip() == bytearray(b"spacious")
assert bytearray(b"www.example.com").strip(b"cmowz.") == bytearray(b"example")
assert bytearray(b" spacious ").lstrip() == bytearray(b"spacious ")
assert bytearray(b" \n spacious ").lstrip() == bytearray(b"spacious ")
assert bytearray(b"www.example.com").lstrip(b"cmowz.") == bytearray(b"example.com")
assert bytearray(b" spacious ").rstrip() == bytearray(b" spacious")
assert bytearray(b" spacious \n ").rstrip() == bytearray(b" spacious")
assert bytearray(b"mississippi").rstrip(b"ipz") == bytearray(b"mississ")

View File

@@ -341,11 +341,11 @@ assert b"hjhtuyfjtyhuhjuyj".translate(None, delete=b"ht") == b"juyfjyujuyj"
# strip lstrip rstrip
assert b" spacious ".strip() == b"spacious"
assert b" \n spacious \n ".strip() == b"spacious"
assert b"www.example.com".strip(b"cmowz.") == b"example"
assert b" spacious ".lstrip() == b"spacious "
assert b" \n spacious ".lstrip() == b"spacious "
assert b"www.example.com".lstrip(b"cmowz.") == b"example.com"
assert b" spacious ".rstrip() == b" spacious"
assert b" spacious \n ".rstrip() == b" spacious"
assert b"mississippi".rstrip(b"ipz") == b"mississ"

View File

@@ -30,14 +30,7 @@ p.wait()
is_unix = "win" not in sys.platform or "darwin" in sys.platform
if is_unix:
# unix
test_output = b"test\n"
else:
# windows
test_output = b"test\r\n"
assert p.stdout.read() == test_output
assert p.stdout.read().strip() == b"test"
p = subprocess.Popen(["sleep", "2"])
p.terminate()
@@ -57,4 +50,4 @@ else:
p = subprocess.Popen(["echo", "test"], stdout=subprocess.PIPE)
(stdout, stderr) = p.communicate()
assert stdout == test_output
assert stdout.strip() == b"test"

View File

@@ -49,6 +49,7 @@ def run_via_cpython(filename):
env = os.environ.copy()
subprocess.check_call([sys.executable, filename], env=env)
RUST_TARGET = "debug" if os.environ.get("CODE_COVERAGE", "false") == "true" else "release"
def run_via_rustpython(filename, test_type):
env = os.environ.copy()
@@ -56,10 +57,7 @@ def run_via_rustpython(filename, test_type):
env['RUST_BACKTRACE'] = '1'
env['PYTHONPATH'] = RUSTPYTHON_LIB_DIR
target = "release"
if env.get("CODE_COVERAGE", "false") == "true":
target = "debug"
binary = os.path.abspath(os.path.join(ROOT_DIR, "target", target, "rustpython"))
binary = os.path.abspath(os.path.join(ROOT_DIR, "target", RUST_TARGET, "rustpython"))
subprocess.check_call([binary, filename], env=env)
@@ -136,8 +134,7 @@ class SampleTestCase(unittest.TestCase):
generate_slices(cls.slices_resource_path)
# cargo stuff
subprocess.check_call(["cargo", "build"])
subprocess.check_call(["cargo", "build", "--release"])
subprocess.check_call(["cargo", "build", "--{}".format(RUST_TARGET)])
@classmethod
def tearDownClass(cls):

View File

@@ -952,28 +952,30 @@ impl PyByteInner {
chars: OptionalArg<PyByteInner>,
position: ByteInnerPosition,
) -> PyResult<Vec<u8>> {
let chars = if let OptionalArg::Present(bytes) = chars {
bytes.elements
} else {
vec![b' ']
let is_valid_char = |c| {
if let OptionalArg::Present(ref bytes) = chars {
bytes.elements.contains(c)
} else {
c.is_ascii_whitespace()
}
};
let mut start = 0;
let mut end = self.len();
if let ByteInnerPosition::Left | ByteInnerPosition::All = position {
for (n, i) in self.elements.iter().enumerate() {
if !chars.contains(i) {
start = n;
for (i, c) in self.elements.iter().enumerate() {
if !is_valid_char(c) {
start = i;
break;
}
}
}
if let ByteInnerPosition::Right | ByteInnerPosition::All = position {
for (n, i) in self.elements.iter().rev().enumerate() {
if !chars.contains(i) {
end = self.len() - n;
for (i, c) in self.elements.iter().rev().enumerate() {
if !is_valid_char(c) {
end = self.len() - i;
break;
}
}