-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathtest.py
More file actions
66 lines (53 loc) · 2.01 KB
/
Copy pathtest.py
File metadata and controls
66 lines (53 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import sys
import subprocess
import threading
testProjectsDir = './gerbv_example'
testProjects = [os.path.join(testProjectsDir, subdir)
for subdir in os.listdir(testProjectsDir)]
class Builder(threading.Thread):
def __init__(self, project_dir, output_dir_name ):
threading.Thread.__init__(self)
self._project_dir = project_dir
self._output_dir_name = output_dir_name
def run(self):
build_project( self._project_dir, self._output_dir_name )
def build_project( project_dir, output_dir_name ):
prog_path = subprocess.check_output('pwd')[0:-1] + '/../pcb2gcode'
subprocess.Popen( args=prog_path, cwd=project_dir ).wait()
subprocess.Popen( args='mkdir -p '+output_dir_name+' && mv *.ngc '+output_dir_name, \
cwd=project_dir, shell=True ).wait()
def check_project( project_dir ):
ret = subprocess.call(['diff', '-q', project_dir+'/old', project_dir+'/new'])
if ret != 0:
print 'ERROR: differences found in test project ' + project_dir
subprocess.call(['meld', project_dir+'/old', project_dir+'/new'])
else:
print 'No differences found.'
def clean_project( project_dir ):
subprocess.call(['rm', '-rf', project_dir+'/old', project_dir+'/new', project_dir+'/*.png'])
def build_projects( output_dir_name ):
builders = []
for project in testProjects:
print 'Building ' + project
builder = Builder( project, output_dir_name )
builders.append(builder)
builder.start()
for builder in builders:
builder.join()
def check_projects():
for project in testProjects:
print 'Checking ' + project
check_project( project )
def clean_projects():
for project in testProjects:
print 'Cleaning up.'
clean_project( project )
if sys.argv[1] == 'buildold':
build_projects('old')
elif sys.argv[1] == 'buildnew':
build_projects('new')
elif sys.argv[1] == 'cmp':
check_projects()
elif sys.argv[1] == 'clean':
clean_projects()