Skip to content

Commit a7061c6

Browse files
author
Ali
committedMar 23, 2022
Testing support
1 parent 72c29a5 commit a7061c6

File tree

4 files changed

+93
-18
lines changed

4 files changed

+93
-18
lines changed
 

‎Telegram/BUILD

-17
Original file line numberDiff line numberDiff line change
@@ -1943,23 +1943,6 @@ ios_application(
19431943
],
19441944
)
19451945

1946-
swift_library(
1947-
name = "UITestsLib",
1948-
module_name = "UITestsLib",
1949-
srcs = glob(["UITests/**/*.swift"]),
1950-
deps = [
1951-
"//submodules/TelegramUI:TelegramUI",
1952-
],
1953-
)
1954-
1955-
ios_ui_test(
1956-
name = "UITests",
1957-
minimum_os_version = "9.0",
1958-
deps = [":UITestsLib"],
1959-
infoplists = [":UITestsLib/Info.plist"],
1960-
test_host = ":Telegram",
1961-
)
1962-
19631946
# Temporary targets used to simplify webrtc build tests
19641947

19651948
ios_application(

‎Tests/AllTests/BUILD

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
test_suite(
3+
name = "AllTests",
4+
tests = [
5+
"//submodules/TgVoipWebrtc:TgCallsTests",
6+
],
7+
visibility = [
8+
"//visibility:public",
9+
],
10+
)

‎build-system/Make/Make.py

+82
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ def set_configuration(self, configuration):
144144
# Build single-architecture binaries. It is almost 2 times faster is 32-bit support is not required.
145145
'--ios_multi_cpus=arm64',
146146

147+
# Always build universal Watch binaries.
148+
'--watchos_cpus=armv7k,arm64_32'
149+
] + self.common_debug_args
150+
elif configuration == 'debug_sim_arm64':
151+
self.configuration_args = [
152+
# bazel debug build configuration
153+
'-c', 'dbg',
154+
155+
# Build single-architecture binaries. It is almost 2 times faster is 32-bit support is not required.
156+
'--ios_multi_cpus=sim_arm64',
157+
147158
# Always build universal Watch binaries.
148159
'--watchos_cpus=armv7k,arm64_32'
149160
] + self.common_debug_args
@@ -317,6 +328,47 @@ def invoke_build(self):
317328
call_executable(combined_arguments)
318329

319330

331+
def invoke_test(self):
332+
combined_arguments = [
333+
self.build_environment.bazel_path
334+
]
335+
combined_arguments += self.get_startup_bazel_arguments()
336+
combined_arguments += ['test']
337+
338+
combined_arguments += ['--cache_test_results=no']
339+
combined_arguments += ['--test_output=errors']
340+
341+
combined_arguments += ['Tests/AllTests']
342+
343+
if self.configuration_path is None:
344+
raise Exception('configuration_path is not defined')
345+
346+
combined_arguments += [
347+
'--override_repository=build_configuration={}'.format(self.configuration_path)
348+
]
349+
350+
combined_arguments += self.common_args
351+
combined_arguments += self.common_build_args
352+
combined_arguments += self.get_define_arguments()
353+
combined_arguments += self.get_additional_build_arguments()
354+
355+
if self.remote_cache is not None:
356+
combined_arguments += [
357+
'--remote_cache={}'.format(self.remote_cache),
358+
'--experimental_remote_downloader={}'.format(self.remote_cache)
359+
]
360+
elif self.cache_dir is not None:
361+
combined_arguments += [
362+
'--disk_cache={path}'.format(path=self.cache_dir)
363+
]
364+
365+
combined_arguments += self.configuration_args
366+
367+
print('TelegramBuild: running')
368+
print(subprocess.list2cmdline(combined_arguments))
369+
call_executable(combined_arguments)
370+
371+
320372
def clean(bazel, arguments):
321373
bazel_command_line = BazelCommandLine(
322374
bazel=bazel,
@@ -430,6 +482,27 @@ def build(bazel, arguments):
430482
bazel_command_line.invoke_build()
431483

432484

485+
def test(bazel, arguments):
486+
bazel_command_line = BazelCommandLine(
487+
bazel=bazel,
488+
override_bazel_version=arguments.overrideBazelVersion,
489+
override_xcode_version=arguments.overrideXcodeVersion,
490+
bazel_user_root=arguments.bazelUserRoot
491+
)
492+
493+
if arguments.cacheDir is not None:
494+
bazel_command_line.add_cache_dir(arguments.cacheDir)
495+
elif arguments.cacheHost is not None:
496+
bazel_command_line.add_remote_cache(arguments.cacheHost)
497+
498+
resolve_configuration(bazel_command_line, arguments)
499+
500+
bazel_command_line.set_configuration('debug_sim_arm64')
501+
bazel_command_line.set_build_number('10000')
502+
503+
bazel_command_line.invoke_test()
504+
505+
433506
def add_project_and_build_common_arguments(current_parser: argparse.ArgumentParser):
434507
group = current_parser.add_mutually_exclusive_group(required=True)
435508
group.add_argument(
@@ -520,6 +593,13 @@ def add_project_and_build_common_arguments(current_parser: argparse.ArgumentPars
520593
'''
521594
)
522595

596+
testParser = subparsers.add_parser(
597+
'test', help='''
598+
Run all tests.
599+
'''
600+
)
601+
add_project_and_build_common_arguments(testParser)
602+
523603
generateProjectParser = subparsers.add_parser('generateProject', help='Generate Xcode project')
524604
generateProjectParser.add_argument(
525605
'--buildNumber',
@@ -646,6 +726,8 @@ def add_project_and_build_common_arguments(current_parser: argparse.ArgumentPars
646726
generate_project(bazel=bazel_path, arguments=args)
647727
elif args.commandName == 'build':
648728
build(bazel=bazel_path, arguments=args)
729+
elif args.commandName == 'test':
730+
test(bazel=bazel_path, arguments=args)
649731
else:
650732
raise Exception('Unknown command')
651733
except KeyboardInterrupt:

‎build-system/Make/ProjectGeneration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def generate(build_environment: BuildEnvironment, disable_extensions, disable_pr
9292
bazel_build_arguments += ['--//{}:disableProvisioningProfiles'.format(app_target)]
9393
if generate_dsym:
9494
bazel_build_arguments += ['--apple_generate_dsym']
95-
bazel_build_arguments += ['--//{}:disableStripping'.format(app_target)]
95+
bazel_build_arguments += ['--//{}:disableStripping'.format('Telegram')]
9696
bazel_build_arguments += ['--strip=never']
9797

9898
call_executable([

0 commit comments

Comments
 (0)
Please sign in to comment.