Skip to content
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Comment thread
aaronliu0130 marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ on:
paths-ignore: "*.rst"
jobs:
build-test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Python 3.7 is the highest available for actions/setup-python
python-version: ['3.7', 'pypy3.10', '3.12']
os: [ubuntu-latest, windows-latest]
fail-fast: false

steps:
Expand Down
19 changes: 18 additions & 1 deletion cpplint_clitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@

"""Command Line interface integration test for cpplint.py."""

import glob
import os
import platform
import sys
import subprocess
import unittest
import shutil
import tempfile

from testfixtures import compare

BASE_CMD = sys.executable + ' ' + os.path.abspath('./cpplint.py ')
Expand All @@ -58,6 +61,7 @@ def RunShellCommand(cmd, cwd='.'):
stderr=stderr_target)
out, err = proc.communicate()

# TODO: These transforms break testing of Windows --output=sed.
# Make output system-agnostic, aka support Windows
if os.sep == '\\':
out, err = out.replace(b'\\', b'/'), err.replace(b'\\', b'/')
Expand Down Expand Up @@ -132,8 +136,21 @@ def _checkDef(self, path):
with open(path, 'rb') as filehandle:
datalines = filehandle.readlines()
stdoutLines = int(datalines[2])
filenames = datalines[0].decode('utf8').strip()
args, _, filenames = filenames.rpartition(" ")
if '--output=sed' in args and platform.system() == 'Windows':
# TODO: Testing of Windows --output=sed is either broken
# by the transforms in `RunShellCommand`.
return
if '*' in filenames:
rel_cwd = os.path.dirname(path)
filenames = ' '.join(
filename[len(rel_cwd)+1:]
for filename in glob.glob(rel_cwd + '/' + filenames)
)
args += ' ' + filenames
self._runAndCheck(path,
datalines[0].decode('utf8').strip(),
args,
int(datalines[1]),
[line.decode('utf8').strip() for line in datalines[3:3 + stdoutLines]],
[line.decode('utf8').strip() for line in datalines[3 + stdoutLines:]])
Expand Down
9 changes: 9 additions & 0 deletions cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@

import codecs
import os
import platform
import random
import re
import shutil
import subprocess
import sys
import tempfile
import unittest

import pytest

import cpplint
Expand Down Expand Up @@ -3255,6 +3257,8 @@ def DoTest(self, raw_bytes, has_invalid_utf8):
# you can see by evaluating codecs.getencoder('utf8')(u'\ufffd')).
DoTest(self, codecs_latin_encode('\xef\xbf\xbd\n'), True)

@unittest.skipIf(platform.system() == 'Windows',
'Skipping test on Windows because it hangs')
def testBadCharacters(self):
# Test for NUL bytes only
error_collector = ErrorCollector(self.assertTrue)
Expand Down Expand Up @@ -4870,6 +4874,9 @@ def testIncludeItsHeader(self):
'test/foo.cc', 'cc',
[''],
error_collector)

if platform.system() == 'Windows':
test_directory = test_directory.replace('\\', '/')
expected = "{dir}/{fn}.cc should include its header file {dir}/{fn}.h [build/include] [5]".format(
fn="foo",
dir=test_directory)
Expand Down Expand Up @@ -4953,6 +4960,8 @@ def testPathSplitToList(self):
self.assertEqual(['a', 'b', 'c', 'd'],
cpplint.PathSplitToList(os.path.join('a', 'b', 'c', 'd')))

@unittest.skipIf(platform.system() == 'Windows',
'Skipping test on Windows because realpath can fail if mkdtemp uses D:')
def testBuildHeaderGuardWithRepository(self):
temp_directory = os.path.realpath(tempfile.mkdtemp())
temp_directory2 = os.path.realpath(tempfile.mkdtemp())
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup
import cpplint

# some pip versions bark on comments (e.g. on travis)
# some pip versions bark on comments
def read_without_comments(filename):
with open(filename) as f:
return [line for line in f.read().splitlines() if not len(line) == 0 and not line.startswith('#')]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ deps =
setuptools

commands =
{envpython} -m pytest {posargs:}
{envpython} -m pytest -v {posargs:}
{envpython} -m pylint cpplint.py
{envpython} -m flake8