comments for pso
[imago.git] / test / test.py
1 #!/usr/bin/env python
2
3 import subprocess
4 import pickle
5 import time
6 import datetime
7 import sys
8
9 proc = subprocess.Popen("ls *.jpg", shell=True,
10                         stdout=subprocess.PIPE,
11                         stderr=subprocess.PIPE)
12 test_files = proc.communicate()[0].split()
13
14 proc = subprocess.Popen("git log --pretty=format:'%h' -n 1", shell=True,
15                         stdout=subprocess.PIPE,
16                         stderr=subprocess.PIPE)
17
18 git_hash = proc.communicate()[0].strip()
19
20 res_name = "res" + datetime.datetime.now().strftime("%Y%m%d%H%M") + "-" + git_hash
21
22 test_results = []
23 n = 1
24
25 for fl in test_files:
26     print "testing file", fl, str(n) + "/" + str(len(test_files))
27     n += 1
28     t0 = time.time()
29     proc = subprocess.Popen(["../imago", "-w", "640", fl],
30                             stdout=subprocess.PIPE,
31                             stderr=subprocess.PIPE)
32     [output, err] = proc.communicate()
33     r_code = proc.returncode
34     t1 = time.time()
35     test_results.append((fl, t1 - t0, output, err, r_code))
36
37 pickle.dump(test_results, open(res_name, 'w'))
38
39 print "written file", res_name