Skip to content

Commit 9f9a13c

Browse files
committed
Refactor exec_test
1 parent f3c9795 commit 9f9a13c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

exec_test.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
def exec_test(target_dir):
14+
print(target_dir)
1415
exit_status = 0
1516
try:
1617
subprocess.check_call(['green', '-vv', '--processes', '1', target_dir])
@@ -22,7 +23,7 @@ def exec_test(target_dir):
2223

2324
def copy_required_files(path):
2425
# テストの実行ディレクトリパスを取得
25-
test_dir = './' + path[:path.rfind('/')]
26+
test_dir = path[:path.rfind('/')]
2627

2728
# テスト対象ソースを複製(対象ソースは tests 配下と同一構造の src ディレクトリ配下が対象)
2829
copy_tree(re.sub('^\./tmp_tests', './src', test_dir), test_dir)
@@ -40,14 +41,12 @@ def main():
4041
shutil.rmtree(TEST_TMP_DIR)
4142

4243
# テスト実行のためのtmpディレクトリを作成し、testsをコピーする
43-
os.mkdir('./tmp_tests')
44-
copy_tree('./tests/', './tmp_tests')
44+
os.mkdir(TEST_TMP_DIR)
45+
copy_tree(TEST_DIR, TEST_TMP_DIR)
4546

4647
# 引数でファイル名を受け取っている場合は変数にセットする
4748
target_file_path = sys.argv[1] if len(sys.argv) == 2 else None
4849

49-
exec_dir = ''
50-
5150
if target_file_path:
5251
# tmpフォルダ上の指定されたファイルのパスを取得
5352
exec_file = TEST_TMP_DIR + target_file_path[(target_file_path.find(TEST_DIR) + len(TEST_DIR)):]
@@ -56,7 +55,7 @@ def main():
5655
else:
5756
exec_dir = TEST_TMP_DIR
5857

59-
for name in glob.iglob('tmp_tests/**/test_*.py', recursive=True):
58+
for name in glob.iglob(TEST_TMP_DIR + '/**/test_*.py', recursive=True):
6059
copy_required_files(name)
6160

6261
result = exec_test(exec_dir)

0 commit comments

Comments
 (0)