Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit a000ef1

Browse files
author
Juanjo Alvarez
committed
Test for issue 60 + bblfshd update
- Test and fixture for issue 60. - Update libuast dependency to 1.5.0, compile with C++11 standard. - Tests: Use bblfshd + driver install instead of the server. Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
1 parent a85d54f commit a000ef1

4 files changed

Lines changed: 53 additions & 9 deletions

File tree

bblfsh/fixtures/issue60.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name="apollo",
5+
description="source{d} Gemini's evil twin which runs everything using Python.",
6+
version="0.1.0",
7+
license="Apache 2.0",
8+
author="source{d}",
9+
author_email="machine-learning@sourced.tech",
10+
url="https://github.com/src-d/gemini",
11+
download_url="https://github.com/src-d/gemini",
12+
packages=find_packages(exclude=("gemini.tests",)),
13+
entry_points={
14+
"console_scripts": ["gemini=gemini.__main__:main"],
15+
},
16+
keywords=["machine learning on source code", "weighted minhash", "minhash",
17+
"bblfsh", "babelfish"],
18+
install_requires=["cassandra_driver >= 3.12.0, <4.0",
19+
"libMHCUDA >= 1.1.5, <2.0"],
20+
# "sourcedml >= 0.4.0, <1.0"],
21+
package_data={"": ["LICENSE", "README.md"]},
22+
classifiers=[
23+
"Development Status :: 3 - Alpha",
24+
"Environment :: Console",
25+
"Intended Audience :: Developers",
26+
"License :: OSI Approved :: Apache Software License",
27+
"Operating System :: POSIX",
28+
"Programming Language :: Python :: 3.4",
29+
"Programming Language :: Python :: 3.5",
30+
"Programming Language :: Python :: 3.6",
31+
"Topic :: Software Development :: Libraries"
32+
]
33+
)

bblfsh/launcher.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,24 @@ def ensure_bblfsh_is_running():
1616

1717
def after_start(container):
1818
log.warning(
19-
"Launched the Babelfish server (name bblfsh, id %s).\nStop it "
20-
"with: docker rm -f bblfsh", container.id)
19+
"Launched the Babelfish server (name bblfshd, id %s).\nStop it "
20+
"with: docker rm -f bblfshd", container.id)
2121
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
2222
result = -1
2323
while result != 0:
2424
time.sleep(0.1)
2525
result = sock.connect_ex(("0.0.0.0", 9432))
2626
log.warning("Babelfish server is up and running.")
27+
log.info("Installing Python driver")
28+
container.exec_run("bblfshctl driver install python bblfsh/python-driver:latest")
2729

2830
try:
29-
container = client.containers.get("bblfsh")
31+
container = client.containers.get("bblfshd")
3032
if container.status != "running":
3133
try:
3234
container.start()
3335
except Exception as e:
34-
log.warning("Failed to start the existing bblfsh container: "
36+
log.warning("Failed to start the existing bblfshd container: "
3537
"%s: %s", type(e).__name__, e)
3638
else:
3739
after_start(container)
@@ -44,7 +46,7 @@ def after_start(container):
4446
return False
4547
except docker.errors.NotFound:
4648
container = client.containers.run(
47-
"bblfsh/server", name="bblfsh", detach=True, privileged=True,
49+
"bblfsh/bblfshd", name="bblfshd", detach=True, privileged=True,
4850
ports={9432: 9432}
4951
)
5052
after_start(container)

bblfsh/test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def setUpClass(cls):
1717
def tearDownClass(cls):
1818
if not cls.BBLFSH_SERVER_EXISTED:
1919
client = docker.from_env(version="auto")
20-
client.containers.get("bblfsh").remove(force=True)
20+
client.containers.get("bblfshd").remove(force=True)
2121
client.api.close()
2222

2323
def setUp(self):
@@ -112,6 +112,15 @@ def testFilterEndCol(self):
112112
self.assertTrue(any(filter(node, "//*[@endCol=50]")))
113113
self.assertFalse(any(filter(node, "//*[@endCol=5]")))
114114

115+
def testFilterBadQuery(self):
116+
node = Node()
117+
self.assertRaises(RuntimeError, filter, node, "//*roleModule")
118+
119+
def testIssue60(self):
120+
rep = self.client.parse("fixtures/issue60.py")
121+
assert(rep.uast)
122+
self.assertFalse(any(filter(rep.uast, "//@roleLiteral")))
123+
115124
def testRoleIdName(sedlf):
116125
assert(role_id(role_name(1)) == 1)
117126
assert(role_name(role_id("IDENTIFIER")) == "IDENTIFIER")

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from setuptools import setup, find_packages, Extension
66
from setuptools.command.build_ext import build_ext
77

8-
LIBUAST_VERSION = "v1.4.1"
8+
LIBUAST_VERSION = "v1.5.0"
99
SDK_VERSION = "v1.8.0"
1010
SDK_MAJOR = SDK_VERSION.split('.')[0]
1111
PYTHON = "python3"
@@ -23,7 +23,7 @@ def run(self):
2323
if "--global-uast" in sys.argv:
2424
libraries.append('uast')
2525
else:
26-
sources.append('bblfsh/libuast/uast.c')
26+
sources.append('bblfsh/libuast/uast.cc')
2727
sources.append('bblfsh/libuast/roles.c')
2828

2929
getLibuast()
@@ -123,7 +123,7 @@ def main():
123123
'bblfsh.pyuast',
124124
libraries=libraries,
125125
library_dirs=['/usr/lib', '/usr/local/lib'],
126-
extra_compile_args=['-std=gnu99'],
126+
extra_compile_args=['-std=c++11'],
127127
include_dirs=['bblfsh/libuast/', '/usr/local/include', '/usr/local/include/libxml2',
128128
'/usr/include', '/usr/include/libxml2'], sources=sources)
129129

0 commit comments

Comments
 (0)