Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
| 2 # Copyright (C) 2009 Daniel Bates (dbates@intudata.com). All rights reserved. | 2 # Copyright (C) 2009 Daniel Bates (dbates@intudata.com). All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 tempfile, temp_name = fs.open_binary_tempfile('') | 81 tempfile, temp_name = fs.open_binary_tempfile('') |
| 82 tempfile.write(content) | 82 tempfile.write(content) |
| 83 tempfile.close() | 83 tempfile.close() |
| 84 file_interpreter = Executive.interpreter_for_script(temp_name, fs) | 84 file_interpreter = Executive.interpreter_for_script(temp_name, fs) |
| 85 | 85 |
| 86 self.assertEqual(file_interpreter, intepreter) | 86 self.assertEqual(file_interpreter, intepreter) |
| 87 | 87 |
| 88 def test_interpreter_for_script(self): | 88 def test_interpreter_for_script(self): |
| 89 self.assert_interpreter_for_content(None, '') | 89 self.assert_interpreter_for_content(None, '') |
| 90 self.assert_interpreter_for_content(None, 'abcd\nefgh\nijklm') | 90 self.assert_interpreter_for_content(None, 'abcd\nefgh\nijklm') |
| 91 self.assert_interpreter_for_content(None, '##/usr/bin/perl') | 91 self.assert_interpreter_for_content(None, '##/usr/bin/env python') |
|
Julien - ping for review
2015/07/31 21:51:25
Dirk, I think this unit test updates makes sense.
Dirk Pranke
2015/07/31 22:01:24
Yup, that's fine. Still lgtm.
| |
| 92 self.assert_interpreter_for_content('perl', '#!/usr/bin/env perl') | |
| 93 self.assert_interpreter_for_content('perl', '#!/usr/bin/env perl\nfirst\ nsecond') | |
| 94 self.assert_interpreter_for_content('perl', '#!/usr/bin/perl') | |
| 95 self.assert_interpreter_for_content('perl', '#!/usr/bin/perl -w') | |
| 96 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/env pyth on') | 92 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/env pyth on') |
| 97 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/env pyth on\nfirst\nsecond') | 93 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/env pyth on\nfirst\nsecond') |
| 98 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/python') | 94 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/python') |
| 99 self.assert_interpreter_for_content('ruby', '#!/usr/bin/env ruby') | 95 self.assert_interpreter_for_content('ruby', '#!/usr/bin/env ruby') |
| 100 self.assert_interpreter_for_content('ruby', '#!/usr/bin/env ruby\nfirst\ nsecond') | 96 self.assert_interpreter_for_content('ruby', '#!/usr/bin/env ruby\nfirst\ nsecond') |
| 101 self.assert_interpreter_for_content('ruby', '#!/usr/bin/ruby') | 97 self.assert_interpreter_for_content('ruby', '#!/usr/bin/ruby') |
| 102 | 98 |
| 103 def test_run_command_with_bad_command(self): | 99 def test_run_command_with_bad_command(self): |
| 104 def run_bad_command(): | 100 def run_bad_command(): |
| 105 Executive().run_command(["foo_bar_command_blah"], error_handler=Exec utive.ignore_error, return_exit_code=True) | 101 Executive().run_command(["foo_bar_command_blah"], error_handler=Exec utive.ignore_error, return_exit_code=True) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 import msvcrt | 197 import msvcrt |
| 202 msvcrt.setmode(stdout.fileno(), os.O_BINARY) | 198 msvcrt.setmode(stdout.fileno(), os.O_BINARY) |
| 203 if cmd == '--cat': | 199 if cmd == '--cat': |
| 204 stdout.write(stdin.read()) | 200 stdout.write(stdin.read()) |
| 205 elif cmd == '--echo': | 201 elif cmd == '--echo': |
| 206 stdout.write(' '.join(args)) | 202 stdout.write(' '.join(args)) |
| 207 return 0 | 203 return 0 |
| 208 | 204 |
| 209 if __name__ == '__main__' and len(sys.argv) > 1 and sys.argv[1] in ('--cat', '-- echo'): | 205 if __name__ == '__main__' and len(sys.argv) > 1 and sys.argv[1] in ('--cat', '-- echo'): |
| 210 sys.exit(main(sys.platform, sys.stdin, sys.stdout, sys.argv[1], sys.argv[2:] )) | 206 sys.exit(main(sys.platform, sys.stdin, sys.stdout, sys.argv[1], sys.argv[2:] )) |
| OLD | NEW |