kafka_neu-1778570057504.zip-extract/kafka-4.2.0-src/committer-tools/find-unfinished-test.py

Path
kafka_neu-1778570057504.zip-extract/kafka-4.2.0-src/committer-tools/find-unfinished-test.py
Status
scanned
Type
file
Name
find-unfinished-test.py
Extension
.py
Programming language
Python
Mime type
text/x-script.python
File type
Python script, ASCII text executable
Tag

      
    
Rootfs path

      
    
Size
2438 (2.4 KB)
MD5
bd1eb59d7ce643856649ce0a16893323
SHA1
f6567e3faec61fedbf526ceadbb4533ad70a2e1b
SHA256
88d986ab058bd83f042718c5b5736d419592bc05c3124d06429007b219df4092
SHA512

      
    
SHA1_git
44b0ed31ab13d3b120276db60773dbcc70010116
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
find-unfinished-test.py | 2.4 KB |

# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse from datetime import datetime def pretty_time_duration(seconds: float) -> str: time_min, time_sec = divmod(int(seconds), 60) time_hour, time_min = divmod(time_min, 60) time_fmt = "" if time_hour > 0: time_fmt += f"{time_hour}h" if time_min > 0: time_fmt += f"{time_min}m" time_fmt += f"{time_sec}s" return time_fmt if __name__ == "__main__": parser = argparse.ArgumentParser(description="Parse Gradle log output to find hanging tests") parser.add_argument("file", type=argparse.FileType("r"), help="Text file containing Gradle stdout") args = parser.parse_args() started = dict() last_test_line = None for line in args.file.readlines(): if "Gradle Test Run" not in line: continue last_test_line = line toks = line.strip().split(" > ") name, status = toks[-1].rsplit(" ", 1) name_toks = toks[2:-1] + [name] test = " > ".join(name_toks) if status == "STARTED": started[test] = line else: started.pop(test) last_timestamp, _ = last_test_line.split(" ", 1) last_dt = datetime.fromisoformat(last_timestamp) if len(started) > 0: print("Found tests that were started, but apparently not finished") for started_not_finished, line in started.items(): print("-"*80) timestamp, _ = line.split(" ", 1) dt = datetime.fromisoformat(timestamp) dur_s = (last_dt - dt).total_seconds() print(f"Test: {started_not_finished}") print(f"Duration: {pretty_time_duration(dur_s)}") print(f"Raw line: {line}")
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
35.31
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 8 8