detect non-C languages in folders with C/C++ files
Improves on 2da75aa119
.
This commit is contained in:
parent
d85448b563
commit
9ce9d528fd
11 changed files with 39 additions and 40 deletions
0
tests/samples/codefiles/c_and_python/see.h
Normal file
0
tests/samples/codefiles/c_and_python/see.h
Normal file
0
tests/samples/codefiles/c_and_python/see.py
Normal file
0
tests/samples/codefiles/c_and_python/see.py
Normal file
0
tests/samples/codefiles/c_only/non_empty.h
Normal file
0
tests/samples/codefiles/c_only/non_empty.h
Normal file
|
@ -42,7 +42,7 @@ class DependenciesTestCase(utils.TestCase):
|
|||
|
||||
def test_token_parser(self):
|
||||
with self.assertRaises(NotYetImplemented):
|
||||
source_file = 'tests/samples/codefiles/see.h'
|
||||
source_file = 'tests/samples/codefiles/c_only/non_empty.h'
|
||||
parser = TokenParser(source_file)
|
||||
parser.parse()
|
||||
|
||||
|
@ -458,7 +458,7 @@ class DependenciesTestCase(utils.TestCase):
|
|||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||
|
||||
with utils.TemporaryDirectory() as tempdir:
|
||||
entity = 'tests/samples/codefiles/see.c'
|
||||
entity = 'tests/samples/codefiles/c_only/non_empty.c'
|
||||
shutil.copy(entity, os.path.join(tempdir, 'see.c'))
|
||||
entity = os.path.realpath(os.path.join(tempdir, 'see.c'))
|
||||
|
||||
|
@ -510,9 +510,9 @@ class DependenciesTestCase(utils.TestCase):
|
|||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||
|
||||
with utils.TemporaryDirectory() as tempdir:
|
||||
entity = 'tests/samples/codefiles/seeplusplus.cpp'
|
||||
shutil.copy(entity, os.path.join(tempdir, 'seeplusplus.cpp'))
|
||||
entity = os.path.realpath(os.path.join(tempdir, 'seeplusplus.cpp'))
|
||||
entity = 'tests/samples/codefiles/c_and_cpp/non_empty.cpp'
|
||||
shutil.copy(entity, os.path.join(tempdir, 'non_empty.cpp'))
|
||||
entity = os.path.realpath(os.path.join(tempdir, 'non_empty.cpp'))
|
||||
|
||||
now = u(int(time.time()))
|
||||
config = 'tests/samples/configs/good_config.cfg'
|
||||
|
@ -562,7 +562,7 @@ class DependenciesTestCase(utils.TestCase):
|
|||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||
|
||||
with utils.TemporaryDirectory() as tempdir:
|
||||
entity = 'tests/samples/codefiles/seesharp.cs'
|
||||
entity = 'tests/samples/codefiles/csharp/seesharp.cs'
|
||||
shutil.copy(entity, os.path.join(tempdir, 'seesharp.cs'))
|
||||
entity = os.path.realpath(os.path.join(tempdir, 'seesharp.cs'))
|
||||
|
||||
|
|
|
@ -23,31 +23,6 @@ class LanguagesTestCase(utils.TestCase):
|
|||
['wakatime.session_cache.SessionCache.connect', None],
|
||||
]
|
||||
|
||||
def test_language_detected_for_header_file(self):
|
||||
response = Response()
|
||||
response.status_code = 500
|
||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||
|
||||
now = u(int(time.time()))
|
||||
config = 'tests/samples/configs/good_config.cfg'
|
||||
entity = 'tests/samples/codefiles/see.h'
|
||||
args = ['--file', entity, '--config', config, '--time', now]
|
||||
|
||||
retval = execute(args)
|
||||
self.assertEquals(retval, 102)
|
||||
|
||||
language = u('C')
|
||||
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language)
|
||||
|
||||
entity = 'tests/samples/codefiles/seeplusplus.h'
|
||||
args[1] = entity
|
||||
|
||||
retval = execute(args)
|
||||
self.assertEquals(retval, 102)
|
||||
|
||||
language = u('C++')
|
||||
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language)
|
||||
|
||||
def test_c_language_detected_for_header_with_c_files_in_folder(self):
|
||||
response = Response()
|
||||
response.status_code = 500
|
||||
|
@ -80,6 +55,22 @@ class LanguagesTestCase(utils.TestCase):
|
|||
language = u('C++')
|
||||
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language)
|
||||
|
||||
def test_c_not_detected_for_non_header_with_c_files_in_folder(self):
|
||||
response = Response()
|
||||
response.status_code = 500
|
||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||
|
||||
now = u(int(time.time()))
|
||||
config = 'tests/samples/configs/good_config.cfg'
|
||||
entity = 'tests/samples/codefiles/c_and_python/see.py'
|
||||
args = ['--file', entity, '--config', config, '--time', now]
|
||||
|
||||
retval = execute(args)
|
||||
self.assertEquals(retval, 102)
|
||||
|
||||
language = u('Python')
|
||||
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language)
|
||||
|
||||
def test_guess_language(self):
|
||||
with utils.mock.patch('wakatime.stats.smart_guess_lexer') as mock_guess_lexer:
|
||||
mock_guess_lexer.return_value = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue