mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-02 11:15:19 +08:00
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
import os
|
|
import glob
|
|
import subprocess
|
|
|
|
env = os.environ.copy()
|
|
env["PYTHONIOENCODING"] = "utf-8"
|
|
|
|
if __name__ == "__main__":
|
|
# ソースコードのファイルを探す
|
|
src_paths = sorted(glob.glob("chapter_*/*.py"))
|
|
errors = []
|
|
|
|
# Python コードを実行する
|
|
for src_path in src_paths:
|
|
process = subprocess.Popen(
|
|
["python", src_path],
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
text=True,
|
|
env=env,
|
|
encoding='utf-8'
|
|
)
|
|
# プロセスの終了を待ち、出力とエラーメッセージを取得する
|
|
stdout, stderr = process.communicate()
|
|
# 終了ステータスを確認する
|
|
exit_status = process.returncode
|
|
if exit_status != 0:
|
|
errors.append(stderr)
|
|
|
|
print(f"{len(src_paths)} 個のファイルをテストしました")
|
|
print(f"{len(errors)} 個のファイルで例外が見つかりました")
|
|
if len(errors) > 0:
|
|
raise RuntimeError("\n\n".join(errors))
|