Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added TRUFFLE_TEST distribution #107

Merged
merged 1 commit into from
Mar 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions mx.truffle/mx_truffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# ----------------------------------------------------------------------------------------------------

import os
import re
import subprocess

import mx
Expand Down Expand Up @@ -93,3 +94,58 @@ def _truffle_gate_runner(args, tasks):
'sldebug' : [sldebug, '[SL args|@VM options]'],
'testdownstream' : [testdownstream, ''],
})

"""
Merges META-INF/truffle/language and META-INF/truffle/instrumentation files.
This code is tightly coupled with the file format generated by
LanguageRegistrationProcessor and InstrumentRegistrationProcessor.
"""
class TruffleArchiveParticipant:
PROPERTY_RE = re.compile(r'(language\d+|instrumentation\d+)(\..+)')

def _truffle_metainf_file(self, arcname):
if arcname == 'META-INF/truffle/language':
return 'language'
if arcname == 'META-INF/truffle/instrumentation':
return 'instrumentation'
return None

def __opened__(self, arc, srcArc, services):
self.settings = {}
self.arc = arc

def __add__(self, arcname, contents):
metainfFile = self._truffle_metainf_file(arcname)
if metainfFile:
properties = self.settings.setdefault(metainfFile, {})
for line in contents.strip().split(os.linesep):
if not line.startswith('#'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't rely on the file to have windows line endings on windows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - will fix.

m = TruffleArchiveParticipant.PROPERTY_RE.match(line)
assert m, line
enum = m.group(1)
prop = m.group(2)
properties.setdefault(enum, []).append(prop)
return True
return False

def __addsrc__(self, arcname, contents):
return False

def __closing__(self):
for metainfFile, properties in self.settings.iteritems():
arcname = 'META-INF/truffle/' + metainfFile
lines = []
counter = 1
for enum in sorted(properties.viewkeys()):
assert enum.startswith(metainfFile)
newEnum = metainfFile + str(counter)
counter += 1
for prop in properties[enum]:
lines.append(newEnum + prop)

content = os.linesep.join(lines)
self.arc.zf.writestr(arcname, content + '\n')

def mx_post_parse_cmd_line(opts):
dist = mx.distribution('TRUFFLE_TEST')
dist.set_archiveparticipant(TruffleArchiveParticipant())
22 changes: 21 additions & 1 deletion mx.truffle/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,26 @@
],
"description" : "Experimental REPL server to build your debugger console for your language.",
"allowsJavadocWarnings": True,
}
},

"TRUFFLE_TEST" : {
"subDir" : "truffle",
"javaCompliance" : "1.7",
"dependencies" : [
"com.oracle.truffle.api.test",
"com.oracle.truffle.api.dsl.test",
"com.oracle.truffle.api.instrumentation.test",
"com.oracle.truffle.api.debug.test",
"com.oracle.truffle.api.interop.java.test",
"com.oracle.truffle.api.object.dsl.test",
"com.oracle.truffle.tools.test",
],
"exclude" : ["mx:HAMCREST", "mx:JUNIT"],
"distDependencies" : [
"TRUFFLE_API",
"TRUFFLE_DSL_PROCESSOR",
"TRUFFLE_DEBUG",
],
},
},
}