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

Side by Side Diff: ppapi/generators/idl_outfile.py

Issue 8653004: Fix python scripts in src/ppapi/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase error Created 8 years, 11 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
« no previous file with comments | « ppapi/generators/idl_option.py ('k') | ppapi/generators/idl_parser.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 4 # found in the LICENSE file.
6 5
7 """ Output file objects for generator. """ 6 """ Output file objects for generator. """
8 7
9 import difflib 8 import difflib
10 import os 9 import os
11 import time 10 import time
12 import sys 11 import sys
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return True 112 return True
114 113
115 except IOError as (errno, strerror): 114 except IOError as (errno, strerror):
116 ErrOut.Log("I/O error(%d): %s" % (errno, strerror)) 115 ErrOut.Log("I/O error(%d): %s" % (errno, strerror))
117 except: 116 except:
118 ErrOut.Log("Unexpected error: %s" % sys.exc_info()[0]) 117 ErrOut.Log("Unexpected error: %s" % sys.exc_info()[0])
119 raise 118 raise
120 119
121 return False 120 return False
122 121
122
123 def TestFile(name, stringlist, force, update): 123 def TestFile(name, stringlist, force, update):
124 errors = 0 124 errors = 0
125 125
126 # Get the old timestamp 126 # Get the old timestamp
127 if os.path.exists(name): 127 if os.path.exists(name):
128 old_time = os.stat(filename)[ST_MTIME] 128 old_time = os.stat(filename)[ST_MTIME]
129 else: 129 else:
130 old_time = 'NONE' 130 old_time = 'NONE'
131 131
132 # Create the file and write to it 132 # Create the file and write to it
(...skipping 15 matching lines...) Expand all
148 return 1 148 return 1
149 else: 149 else:
150 if wrote: 150 if wrote:
151 ErrOut.Log('Should not have writen output %s.' % filename) 151 ErrOut.Log('Should not have writen output %s.' % filename)
152 return 1 152 return 1
153 if cur_time != old_time: 153 if cur_time != old_time:
154 ErrOut.Log('Should not have modified timestamp for %s.' % filename) 154 ErrOut.Log('Should not have modified timestamp for %s.' % filename)
155 return 1 155 return 1
156 return 0 156 return 0
157 157
158 if __name__ == '__main__':
159 158
159 def main():
160 errors = 0 160 errors = 0
161 stringlist = ['Test', 'Testing\n', 'Test'] 161 stringlist = ['Test', 'Testing\n', 'Test']
162 filename = 'outtest.txt' 162 filename = 'outtest.txt'
163 163
164 # Test forcibly writing a file 164 # Test forcibly writing a file
165 errors += TestFile(filename, stringlist, force=True, update=True) 165 errors += TestFile(filename, stringlist, force=True, update=True)
166 166
167 # Test conditionally writing the file skipping 167 # Test conditionally writing the file skipping
168 errors += TestFile(filename, stringlist, force=False, update=False) 168 errors += TestFile(filename, stringlist, force=False, update=False)
169 169
170 # Test conditionally writing the file updating 170 # Test conditionally writing the file updating
171 errors += TestFile(filename, stringlist + ['X'], force=False, update=True) 171 errors += TestFile(filename, stringlist + ['X'], force=False, update=True)
172 172
173 # Clean up file 173 # Clean up file
174 os.remove(filename) 174 os.remove(filename)
175 if not errors: InfoOut.Log('All tests pass.') 175 if not errors: InfoOut.Log('All tests pass.')
176 sys.exit(errors) 176 return errors
177
178
179 if __name__ == '__main__':
180 sys.exit(main())
OLDNEW
« no previous file with comments | « ppapi/generators/idl_option.py ('k') | ppapi/generators/idl_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698