Skip to content

Commit 5cafd3d

Browse files
committed
Attempt to fix C# tests
1 parent eb439c5 commit 5cafd3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+682
-2194
lines changed

build.py

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -905,50 +905,43 @@ def GetCsCompleterDataForPlatform():
905905
'win32': {
906906
'version': 'v1.39.12',
907907
'download_url': ( 'https://github.com/OmniSharp/omnisharp-roslyn/release'
908-
's/download/v1.39.12/omnisharp-win-x86.zip' ),
909-
'file_name': 'omnisharp-win-x86.zip',
910-
'check_sum': ( '05ffec8d8b72831f9dab73bcaef373e35115ef5a68951c78283cedc5'
911-
'fb578ddf' ),
908+
's/download/v1.39.12/omnisharp-win-x86-net6.0.zip' ),
909+
'file_name': 'omnisharp-win-x86-net6.0.zip',
910+
'check_sum': ( 'b38cfc810bbab7f922130d2c8df266454b7be038ef73d278ae082073'
911+
'58318eec' ),
912912
},
913913
'win64': {
914914
'version': 'v1.39.12',
915915
'download_url': ( 'https://github.com/OmniSharp/omnisharp-roslyn/release'
916-
's/download/v1.39.12/omnisharp-win-x64.zip' ),
917-
'file_name': 'omnisharp-win-x64.zip',
918-
'check_sum': ( 'a52562b44c9baa2811f0a617f182a5886bb79bb1532850827d89f173'
919-
'd8c962b6' ),
916+
's/download/v1.39.12/omnisharp-win-x64-net6.0.zip' ),
917+
'file_name': 'omnisharp-win-x64-net6.0.zip',
918+
'check_sum': ( '21bb3f7d990b6d464a748e9c11731582caeeaab87d7f749edeacfe13'
919+
'6a09c13e' ),
920920
},
921921
'macos': {
922922
'version': 'v1.39.12',
923923
'download_url': ( 'https://github.com/OmniSharp/omnisharp-roslyn/release'
924-
's/download/v1.39.12/omnisharp-osx.tar.gz' ),
925-
'file_name': 'omnisharp-osx.tar.gz',
926-
'check_sum': ( '663807abcaa8524b7853803df12e02415376c73bcc93a76eb95d6361'
927-
'aa5aa59a' ),
928-
},
929-
'linux32': {
930-
'version': 'v1.39.12',
931-
'download_url': ( 'https://github.com/OmniSharp/omnisharp-roslyn/release'
932-
's/download/v1.39.12/omnisharp-linux-x86.tar.gz' ),
933-
'file_name': 'omnisharp-linux-x86.tar.gz',
934-
'check_sum': ( 'd8f58e1f4e2ec68c19674b1d1ca377ee5acc19960802078a93c12919'
935-
'1aafc57a' ),
924+
's/download/v1.39.12/omnisharp-osx-arm64-net6.0.tar.gz'
925+
'' ),
926+
'file_name': 'omnisharp-osx-arm64-net6.0.tar.gz',
927+
'check_sum': ( '27db0ded7bf9b1c90155e01a762ea3a39c7da5c26716211bb367886c'
928+
'e27b5ac2' ),
936929
},
937930
'linux64': {
938931
'version': 'v1.39.12',
939932
'download_url': ( 'https://github.com/OmniSharp/omnisharp-roslyn/release'
940-
's/download/v1.39.12/omnisharp-linux-x64.tar.gz' ),
941-
'file_name': 'omnisharp-linux-x64.tar.gz',
942-
'check_sum': ( '759b45d4814c052d6dc4f43dbc779f6252dc5c1453556768369ee1fc'
943-
'dc6d79f5' ),
933+
's/download/v1.39.12/omnisharp-linux-x64-net6.0.tar.gz'
934+
'' ),
935+
'file_name': 'omnisharp-linux-x64-net6.0.tar.gz',
936+
'check_sum': ( 'e6496db73f44005b6c750d5f2da7d752edd181cde7e07062944da816'
937+
'95428f65' ),
944938
},
945939
}
946940
if OnWindows():
947941
return DATA[ 'win64' if IS_64BIT else 'win32' ]
948-
else:
949-
if OnMac():
950-
return DATA[ 'macos' ]
951-
return DATA[ 'linux64' if IS_64BIT else 'linux32' ]
942+
if OnMac():
943+
return DATA[ 'macos' ]
944+
return DATA[ 'linux64' ]
952945

953946

954947
def EnableGoCompleter( args ):

update_omnisharp.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
"releases/{version}/{file_name}" ),
2424
}
2525
FILE_NAME = {
26-
'win32': 'omnisharp-win-x86.zip',
27-
'win64': 'omnisharp-win-x64.zip',
28-
'macos': 'omnisharp-osx.tar.gz',
29-
'linux32': 'omnisharp-linux-x86.tar.gz',
30-
'linux64': 'omnisharp-linux-x64.tar.gz',
26+
'win32': 'omnisharp-win-x86-net6.0.zip',
27+
'win64': 'omnisharp-win-x64-net6.0.zip',
28+
'macos': 'omnisharp-osx-arm64-net6.0.tar.gz',
29+
'linux64': 'omnisharp-linux-x64-net6.0.tar.gz',
3130
}
3231

3332

ycmd/completers/cs/cs_completer.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929
os.path.abspath( os.path.dirname( __file__ ) ),
3030
'..', '..', '..', 'third_party', 'omnisharp-roslyn'
3131
)
32-
PATH_TO_OMNISHARP_ROSLYN_BINARY = os.path.join(
33-
PATH_TO_ROSLYN_OMNISHARP, 'Omnisharp.exe' )
34-
if ( not os.path.isfile( PATH_TO_OMNISHARP_ROSLYN_BINARY )
35-
and os.path.isfile( os.path.join(
36-
PATH_TO_ROSLYN_OMNISHARP, 'omnisharp', 'OmniSharp.exe' ) ) ):
37-
PATH_TO_OMNISHARP_ROSLYN_BINARY = (
38-
os.path.join( PATH_TO_ROSLYN_OMNISHARP, 'omnisharp', 'OmniSharp.exe' ) )
32+
if utils.OnWindows():
33+
PATH_TO_OMNISHARP_ROSLYN_BINARY = os.path.join(
34+
PATH_TO_ROSLYN_OMNISHARP, 'OmniSharp.exe' )
35+
else:
36+
PATH_TO_OMNISHARP_ROSLYN_BINARY = os.path.join(
37+
PATH_TO_ROSLYN_OMNISHARP, 'OmniSharp' )
3938

4039

4140
def MonoRequired( roslyn_path: str ):

ycmd/tests/cs/__init__.py

Lines changed: 20 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2021 ycmd contributors
1+
# Copyright (C) 2024 ycmd contributors
22
#
33
# This file is part of ycmd.
44
#
@@ -17,37 +17,36 @@
1717

1818
import functools
1919
import os
20-
import sys
21-
import time
22-
from contextlib import contextmanager
2320
from ycmd.tests.test_utils import ( BuildRequest,
2421
ClearCompletionsCache,
2522
IgnoreExtraConfOutsideTestsFolder,
2623
IsolatedApp,
27-
WaitUntilCompleterServerReady,
24+
SetUpApp,
2825
StopCompleterServer,
29-
SetUpApp )
26+
WaitUntilCompleterServerReady ) # noqa
3027

3128
shared_app = None
32-
# map of 'app' to filepaths
33-
shared_filepaths = {}
34-
shared_log_indexes = {}
35-
36-
37-
def PathToTestFile( *args ):
38-
dir_of_current_script = os.path.dirname( os.path.abspath( __file__ ) )
39-
return os.path.join( dir_of_current_script, 'testdata', *args )
4029

4130

4231
def setUpModule():
4332
global shared_app
4433
shared_app = SetUpApp()
34+
with IgnoreExtraConfOutsideTestsFolder():
35+
StartCsCompleterServerInDirectory( shared_app, PathToTestFile() )
4536

4637

4738
def tearDownModule():
48-
global shared_app, shared_filepaths
49-
for filepath in shared_filepaths.get( shared_app, [] ):
50-
StopCompleterServer( shared_app, 'cs', filepath )
39+
global shared_app
40+
StopCompleterServer( shared_app, 'cs' )
41+
42+
43+
def StartCsCompleterServerInDirectory( app, directory ):
44+
app.post_json( '/event_notification',
45+
BuildRequest(
46+
filepath = os.path.join( directory, 'Empty.cs' ),
47+
event_name = 'FileReadyToParse',
48+
filetype = 'cs' ) )
49+
WaitUntilCompleterServerReady( app, 'cs' )
5150

5251

5352
def SharedYcmd( test ):
@@ -69,81 +68,11 @@ def Wrapper( test_case_instance, *args, **kwargs ):
6968
try:
7069
test( test_case_instance, app, *args, **kwargs )
7170
finally:
72-
global shared_filepaths
73-
for filepath in shared_filepaths.get( app, [] ):
74-
StopCompleterServer( app, 'cs', filepath )
71+
StopCompleterServer( app, 'cs' )
7572
return Wrapper
7673
return Decorator
7774

7875

79-
def GetDebugInfo( app, filepath ):
80-
request_data = BuildRequest( filetype = 'cs', filepath = filepath )
81-
return app.post_json( '/debug_info', request_data ).json
82-
83-
84-
def ReadFile( filepath, fileposition ):
85-
with open( filepath, encoding = 'utf8' ) as f:
86-
if fileposition:
87-
f.seek( fileposition )
88-
return f.read(), f.tell()
89-
90-
91-
def GetDiagnostics( app, filepath ):
92-
contents, _ = ReadFile( filepath, 0 )
93-
94-
event_data = BuildRequest( filepath = filepath,
95-
event_name = 'FileReadyToParse',
96-
filetype = 'cs',
97-
contents = contents )
98-
99-
return app.post_json( '/event_notification', event_data ).json
100-
101-
102-
@contextmanager
103-
def WrapOmniSharpServer( app, filepath ):
104-
global shared_filepaths
105-
global shared_log_indexes
106-
107-
if filepath not in shared_filepaths.setdefault( app, [] ):
108-
GetDiagnostics( app, filepath )
109-
shared_filepaths[ app ].append( filepath )
110-
WaitUntilCsCompleterIsReady( app, filepath )
111-
112-
logfiles = []
113-
response = GetDebugInfo( app, filepath )
114-
for server in response[ 'completer' ][ 'servers' ]:
115-
logfiles.extend( server[ 'logfiles' ] )
116-
117-
try:
118-
yield
119-
finally:
120-
for logfile in logfiles:
121-
if os.path.isfile( logfile ):
122-
log_content, log_end_position = ReadFile(
123-
logfile, shared_log_indexes.get( logfile, 0 ) )
124-
shared_log_indexes[ logfile ] = log_end_position
125-
sys.stdout.write( f'Logfile { logfile }:\n\n' )
126-
sys.stdout.write( log_content )
127-
sys.stdout.write( '\n' )
128-
129-
130-
def WaitUntilCsCompleterIsReady( app, filepath ):
131-
WaitUntilCompleterServerReady( app, 'cs' )
132-
# Omnisharp isn't ready when it says it is, so wait until Omnisharp returns
133-
# at least one diagnostic multiple times.
134-
success_count = 0
135-
for reraise_error in [ False ] * 39 + [ True ]:
136-
try:
137-
if len( GetDiagnostics( app, filepath ) ) == 0:
138-
raise RuntimeError( "No diagnostic" )
139-
success_count += 1
140-
if success_count > 2:
141-
break
142-
except Exception:
143-
success_count = 0
144-
if reraise_error:
145-
raise
146-
147-
time.sleep( .5 )
148-
else:
149-
raise RuntimeError( "Never was ready" )
76+
def PathToTestFile( *args ):
77+
dir_of_current_script = os.path.dirname( os.path.abspath( __file__ ) )
78+
return os.path.join( dir_of_current_script, 'testdata', *args )

0 commit comments

Comments
 (0)