()
| 25 | DSEP = "=" * 60 |
| 26 | |
| 27 | def main(): |
| 28 | results = {} |
| 29 | total_start = time.time() |
| 30 | |
| 31 | env = os.environ.copy() |
| 32 | env["PYTHONPATH"] = PROJECT_DIR + ":" + env.get("PYTHONPATH", "") |
| 33 | |
| 34 | print(DSEP) |
| 35 | print("FunASR Model Tests") |
| 36 | print(DSEP) |
| 37 | |
| 38 | for test_file in tests: |
| 39 | test_path = os.path.join(TEST_DIR, test_file) |
| 40 | print("\n" + SEP) |
| 41 | print("Running: " + test_file) |
| 42 | print(SEP) |
| 43 | |
| 44 | t0 = time.time() |
| 45 | try: |
| 46 | result = subprocess.run( |
| 47 | [sys.executable, test_path], |
| 48 | cwd=PROJECT_DIR, |
| 49 | env=env, |
| 50 | timeout=300, |
| 51 | capture_output=False, |
| 52 | ) |
| 53 | elapsed = time.time() - t0 |
| 54 | results[test_file] = ("PASSED" if result.returncode == 0 else "FAILED", elapsed) |
| 55 | except subprocess.TimeoutExpired: |
| 56 | elapsed = time.time() - t0 |
| 57 | results[test_file] = ("TIMEOUT", elapsed) |
| 58 | print(" TIMEOUT after %.1fs" % elapsed) |
| 59 | except Exception as e: |
| 60 | elapsed = time.time() - t0 |
| 61 | results[test_file] = ("ERROR", elapsed) |
| 62 | print(" ERROR: %s" % e) |
| 63 | |
| 64 | total_elapsed = time.time() - total_start |
| 65 | |
| 66 | print("\n" + DSEP) |
| 67 | print("SUMMARY") |
| 68 | print(DSEP) |
| 69 | passed = 0 |
| 70 | failed = 0 |
| 71 | for test_file, (status, elapsed) in results.items(): |
| 72 | icon = "+" if status == "PASSED" else "x" |
| 73 | print(" %s %-35s %-8s (%.1fs)" % (icon, test_file, status, elapsed)) |
| 74 | if status == "PASSED": |
| 75 | passed += 1 |
| 76 | else: |
| 77 | failed += 1 |
| 78 | |
| 79 | print("\n Total: %d passed, %d failed, %.1fs elapsed" % (passed, failed, total_elapsed)) |
| 80 | print(DSEP) |
| 81 | return 0 if failed == 0 else 1 |
| 82 | |
| 83 | if __name__ == "__main__": |
| 84 | sys.exit(main()) |
no test coverage detected
searching dependent graphs…