0

Fix the .ycm_extra_conf.py and SublimeText documentation.

There were a few broken links in the documentation and the provided
YCM template would not load properly in Sublime Text 3 on windows.

Lastly make the unit presubmit test pass on Windows too.

BUG=NONE
TEST=chromium.ycm_extra_conf_unittest.py

Review-Url: https://codereview.chromium.org/2039923002
Cr-Commit-Position: refs/heads/master@{#398330}
This commit is contained in:
pastarmovj
2016-06-07 10:53:58 -07:00
committed by Commit bot
parent 116457a690
commit 7e3be85fc1
3 changed files with 17 additions and 22 deletions

@ -15,8 +15,8 @@ Here's what works:
* Editing code works well (especially if you're used to it and get used to the
shortcuts).
* Navigating around the code works well. There are multiple ways to do this (a
full list of keyboard shortcuts is available for [Windows/Linux](http://docs
.sublimetext.info/en/latest/reference/keyboard_shortcuts_win.html) and
full list of keyboard shortcuts is available for [Windows/Linux](http://
docs.sublimetext.info/en/latest/reference/keyboard_shortcuts_win.html) and
[Mac](http://docs.sublimetext.info/en/latest/reference/keyboard_shortcuts_osx.html)).
* Building works fairly well and it does a decent job of parsing errors so
that you can click and jump to the problem spot.
@ -569,8 +569,8 @@ Some other useful packages that improve sublime can be installed from `Ctrl+Shif
* Code navigation tools
* [AutoFileName](https://packagecontrol.io/packages/AutoFileName) - Auto-
completes filenames in #includes
* [Open-Include](https://packagecontrol.io/packagenavigations/Open-
Include) - Opens the file path under the cursor with `Alt + D`
* [Open-Include](https://packagecontrol.io/packagenavigations/Open-Include)
- Opens the file path under the cursor with `Alt + D`
* Text tools
* [Case Conversion](https://packagecontrol.io/packages/Case%20Conversion) -
automatically changes the case of selected text, e.g. `kConstantName` to

@ -162,9 +162,10 @@ def GetNinjaBuildOutputsForSourceFile(out_dir, filename):
rel_filename = os.path.relpath(os.path.realpath(filename), out_dir)
p = subprocess.Popen(['ninja', '-C', out_dir, '-t', 'query', rel_filename],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True)
stdout, _ = p.communicate()
if p.returncode:
if p.returncode != 0:
return []
# The output looks like:
@ -196,9 +197,9 @@ def GetClangCommandLineForNinjaOutput(out_dir, build_target):
"""
p = subprocess.Popen(['ninja', '-v', '-C', out_dir,
'-t', 'commands', build_target],
stdout=subprocess.PIPE)
stdout=subprocess.PIPE, universal_newlines=True)
stdout, stderr = p.communicate()
if p.returncode:
if p.returncode != 0:
return None
# Ninja will return multiple build steps for all dependencies up to
@ -331,7 +332,7 @@ def GetClangOptionsFromNinjaForFilename(chrome_root, filename):
out_dir, GetDefaultSourceFile(chrome_root, filename))
if not clang_line:
return (additional_flags, [])
return additional_flags
return GetClangOptionsFromCommandLine(clang_line, out_dir, additional_flags)

@ -53,15 +53,6 @@ def CreateFile(path,
statinfo = os.stat(path)
os.chmod(path, statinfo.st_mode | stat.S_IXUSR)
@unittest.skipIf(sys.platform.startswith('linux'),
'Tests are only valid on Linux.')
class Chromium_ycmExtraConfTest_NotOnLinux(unittest.TestCase):
def testAlwaysFailsIfNotRunningOnLinux(self):
self.fail('Changes to chromium.ycm_extra_conf.py currently need to be ' \
'uploaded from Linux since the tests only run on Linux.')
@unittest.skipUnless(sys.platform.startswith('linux'),
'Tests are only valid on Linux.')
class Chromium_ycmExtraConfTest(unittest.TestCase):
def SetUpFakeChromeTreeBelowPath(self):
@ -104,7 +95,7 @@ class Chromium_ycmExtraConfTest(unittest.TestCase):
def NormalizeString(self, string):
return string.replace(self.out_dir, '[OUT]').\
replace(self.chrome_root, '[SRC]')
replace(self.chrome_root, '[SRC]').replace('\\', '/')
def NormalizeStringsInList(self, list_of_strings):
return [self.NormalizeString(s) for s in list_of_strings]
@ -172,8 +163,10 @@ class Chromium_ycmExtraConfTest(unittest.TestCase):
clang_options = \
self.ycm_extra_conf.GetClangOptionsFromNinjaForFilename(
self.chrome_root, os.path.join(self.chrome_root, 'one.cpp'))
self.assertIn('-I%s/a' % out_dir, clang_options)
self.assertIn('-I%s/tag-one' % out_dir, clang_options)
self.assertIn('-I%s/a' % self.NormalizeString(out_dir),
self.NormalizeStringsInList(clang_options))
self.assertIn('-I%s/tag-one' % self.NormalizeString(out_dir),
self.NormalizeStringsInList(clang_options))
def testGetFlagsForFileForKnownCppFile(self):
result = self.ycm_extra_conf.FlagsForFile(
@ -313,7 +306,8 @@ class Chromium_ycmExtraConfTest(unittest.TestCase):
# output.
p = subprocess.Popen(['ninja', '-C', self.out_dir, '-t',
'query', '../../four.cc'],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True)
stdout, _ = p.communicate()
self.assertFalse(p.returncode)
self.assertEquals(stdout,