This is an archive of the discontinued LLVM Phabricator instance.

python binding: expose compile command filename
ClosedPublic

Authored by Sarcasm on Feb 15 2016, 2:19 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

Sarcasm updated this revision to Diff 48016.Feb 15 2016, 2:19 PM
Sarcasm retitled this revision from to python binding: expose compile command filename.
Sarcasm added reviewers: compnerd, skalinichev.
compnerd added inline comments.Feb 24 2016, 9:17 AM
bindings/python/tests/cindex/test_cdb.py
67 ↗(On Diff #48016)

Cant we use expected[0]['file'] here rather than duplicating the filename?

Sarcasm added inline comments.Feb 24 2016, 9:28 AM
bindings/python/tests/cindex/test_cdb.py
67 ↗(On Diff #48016)

We can't because the expected array in this test is just the command line, it is different from the one in test_all_compilecommand where it represents the command line + file + directory.

I'm fine making a local variable to hold this filename so that we can have:

file = '/home/john.doe/MyProject/project.cpp'
cmds = cdb.getCompileCommands(file)
assert len(cmds) == 1
assert cmds[0].directory == '/home/john.doe/MyProject'
assert cmds[0].filename == file

Do you think it's better?

compnerd edited edge metadata.Feb 24 2016, 9:50 AM

Right, I mixed up the scope. Actually, I like the suggestion. You can change the other assert to use 'os.path.dirname' and avoid that being duplicated as well.

Sarcasm updated this revision to Diff 49327.Feb 28 2016, 12:19 PM
Sarcasm edited edge metadata.

remove some duplication in a test

compnerd accepted this revision.Feb 28 2016, 12:37 PM
compnerd edited edge metadata.

LGTM; do you have commit rights or do you need help to get this merged?

This revision is now accepted and ready to land.Feb 28 2016, 12:37 PM
jbcoe added a subscriber: jbcoe.Mar 1 2016, 12:25 PM
jbcoe removed a subscriber: jbcoe.
jbcoe added a subscriber: jbcoe.
This revision was automatically updated to reflect the committed changes.