Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: tests/run_tests.py

Issue 159605: This changes variable expansion so that it is recursive (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 import difflib
4 import os
5 import subprocess
6 import sys
7
8 # Returns file contents as a list of lines.
9 def GetFileContents(filename, test_name):
10 try:
11 fd = open(filename, "r")
12 except IOError:
13 print "Unable to open %s for test %s" % (filename, test_name)
14 return False
15 output = fd.read().splitlines()
16 fd.close()
17 return output
18
19 def RunTest(test_name, golden_file):
20 gyp_script = os.path.normpath(
21 os.path.join(os.path.dirname(sys.argv[0]), '../gyp'))
22
23 p = subprocess.Popen(['python', gyp_script, '--depth', '..', test_name,
24 '--debug', 'variables', '--debug', 'general',
25 '--format', 'gypd'],
26 shell=(sys.platform == 'win32'), stdin=subprocess.PIPE,
27 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
28
29 (p_stdout, p_stderr) = p.communicate('')
30 if p_stderr:
31 print "Test %s FAILED to execute: with error output" % (test_name)
32 print "Error output was:\n%s" % p_stdout
33 print "Output was:\n%s" % p_stdout
34 return False
35
36 p_stdout = p_stdout.splitlines()
37
38 golden = GetFileContents(golden_file, test_name)
39
40 if golden != p_stdout:
41 print "Test %s FAILED: output doesn't match golden file %s" % (test_name,
42 golden_file)
43 print "Difference is:"
44 for d in difflib.context_diff(p_stdout, golden):
45 print d
46 return False
47
48 # Now we check to see that the gypd output matches the golden file.
49 golden = GetFileContents(test_name + 'd.golden', test_name)
50 gypd = GetFileContents(test_name + 'd', test_name)
51
52 if golden != gypd:
53 print 'Test %s FAILED: GYPD output ' \
54 'does not match golden file (%s)' % (test_name, golden_file)
55 print "Difference is:"
56 for d in difflib.context_diff(gypd, golden):
57 print d
58 return False
59
60 return True
61
62 if __name__ == '__main__':
63 tests = [
64 ('test1/test1.gyp', 'test1.golden'),
65 ]
66 failures = 0
67 for test in tests:
68 if not RunTest(test[0], test[1]):
69 failures = failures + 1
70 if failures > 0:
71 fail_plural = ""
72 if failures != 1:
73 fail_plural = "s"
74 print "%d test%s FAILED" % (failures, fail_plural)
75 successes = len(tests) - failures
76 success_plural = ""
77 if successes != 1:
78 success_plural = "s"
79 print "%d test%s SUCCEEDED" % (successes, success_plural)
80 sys.exit(2)
81 else:
82 print "ALL %d tests SUCCEEDED" % len(tests)
83 sys.exit(0)
OLDNEW
« pylib/gyp/input.py ('K') | « pylib/gyp/input.py ('k') | tests/test1.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698