Changeset 82770 in webkit
- Timestamp:
- Apr 2, 2011 4:18:57 AM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r82766 r82770 1 2011-04-02 Patrick Gansterer <paroga@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Emulate shebang on Win32 6 https://bugs.webkit.org/show_bug.cgi?id=55927 7 8 Scripts on Windows work only if they are called with the explicit interpreter. 9 Read the first line of scripts to detect the correct executable. 10 11 * Scripts/webkitpy/common/config/ports.py: 12 * Scripts/webkitpy/common/system/executive.py: Added interpreter_for_script(). 13 * Scripts/webkitpy/common/system/executive_unittest.py: 14 1 15 2011-04-01 Adam Barth <abarth@webkit.org> 2 16 -
trunk/Tools/Scripts/webkitpy/common/config/ports.py
r80549 r82770 31 31 import os 32 32 import platform 33 import sys 33 34 34 35 from webkitpy.common.system.executive import Executive … … 44 45 @classmethod 45 46 def script_shell_command(cls, script_name): 46 return [cls.script_path(script_name)] 47 script_path = cls.script_path(script_name) 48 # Win32 does not support shebang. We need to detect the interpreter ourself. 49 if sys.platform == 'win32': 50 interpreter = Executive.interpreter_for_script(script_path) 51 if interpreter: 52 return [interpreter, script_path] 53 return [script_path] 47 54 48 55 @staticmethod -
trunk/Tools/Scripts/webkitpy/common/system/executive.py
r77745 r82770 46 46 47 47 from webkitpy.common.system.deprecated_logging import tee 48 from webkitpy.common.system.filesystem import FileSystem 48 49 from webkitpy.python24 import versioning 49 50 … … 179 180 # machines. 180 181 return 2 182 183 @staticmethod 184 def interpreter_for_script(script_path, fs=FileSystem()): 185 lines = fs.read_text_file(script_path).splitlines() 186 if not len(lines): 187 return None 188 first_line = lines[0] 189 if not first_line.startswith('#!'): 190 return None 191 if first_line.find('python') > -1: 192 return sys.executable 193 if first_line.find('perl') > -1: 194 return 'perl' 195 if first_line.find('ruby') > -1: 196 return 'ruby' 197 return None 181 198 182 199 def kill_process(self, pid): -
trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py
r80048 r82770 35 35 36 36 from webkitpy.common.system.executive import Executive, run_command, ScriptError 37 from webkitpy.common.system.filesystem_mock import MockFileSystem 37 38 from webkitpy.test import cat, echo 38 39 … … 65 66 66 67 class ExecutiveTest(unittest.TestCase): 68 69 def assert_interpreter_for_content(self, intepreter, content): 70 fs = MockFileSystem() 71 file_path = None 72 file_interpreter = None 73 74 tempfile, temp_name = fs.open_binary_tempfile('') 75 tempfile.write(content) 76 tempfile.close() 77 file_interpreter = Executive.interpreter_for_script(temp_name, fs) 78 79 self.assertEqual(file_interpreter, intepreter) 80 81 def test_interpreter_for_script(self): 82 self.assert_interpreter_for_content(None, '') 83 self.assert_interpreter_for_content(None, 'abcd\nefgh\nijklm') 84 self.assert_interpreter_for_content(None, '##/usr/bin/perl') 85 self.assert_interpreter_for_content('perl', '#!/usr/bin/env perl') 86 self.assert_interpreter_for_content('perl', '#!/usr/bin/env perl\nfirst\nsecond') 87 self.assert_interpreter_for_content('perl', '#!/usr/bin/perl') 88 self.assert_interpreter_for_content('perl', '#!/usr/bin/perl -w') 89 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/env python') 90 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/env python\nfirst\nsecond') 91 self.assert_interpreter_for_content(sys.executable, '#!/usr/bin/python') 92 self.assert_interpreter_for_content('ruby', '#!/usr/bin/env ruby') 93 self.assert_interpreter_for_content('ruby', '#!/usr/bin/env ruby\nfirst\nsecond') 94 self.assert_interpreter_for_content('ruby', '#!/usr/bin/ruby') 67 95 68 96 def test_run_command_with_bad_command(self):
Note: See TracChangeset
for help on using the changeset viewer.