aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/with_coverage.py
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /build/scripts/with_coverage.py
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'build/scripts/with_coverage.py')
-rw-r--r--build/scripts/with_coverage.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/build/scripts/with_coverage.py b/build/scripts/with_coverage.py
new file mode 100644
index 00000000000..d62435c3b8f
--- /dev/null
+++ b/build/scripts/with_coverage.py
@@ -0,0 +1,40 @@
+# TODO prettyboy remove after ya-bin release
+
+import os
+import sys
+import subprocess
+import tarfile
+import random
+import shutil
+
+
+def mkdir_p(path):
+ try:
+ os.makedirs(path)
+ except OSError:
+ pass
+
+
+def main(args):
+ coverage_path = os.path.abspath(args[0])
+ coverage_dir = coverage_path + '.' + str(random.getrandbits(64))
+
+ mkdir_p(coverage_dir)
+
+ env = os.environ.copy()
+ env['GCOV_PREFIX'] = coverage_dir
+
+ subprocess.check_call(args[1:], env=env)
+
+ arch_path = coverage_dir + '.archive'
+
+ with tarfile.open(arch_path, 'w:') as tar:
+ tar.add(coverage_dir, arcname='.')
+
+ os.rename(arch_path, coverage_path)
+
+ shutil.rmtree(coverage_dir)
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])