| OLD | NEW | 
|---|
| 1 # Copyright (C) 2011 Google Inc.  All rights reserved. | 1 # Copyright (C) 2011 Google Inc.  All rights reserved. | 
| 2 # | 2 # | 
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without | 
| 4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions | 
| 5 # are met: | 5 # are met: | 
| 6 # 1. Redistributions of source code must retain the above copyright | 6 # 1. Redistributions of source code must retain the above copyright | 
| 7 #    notice, this list of conditions and the following disclaimer. | 7 #    notice, this list of conditions and the following disclaimer. | 
| 8 # 2. Redistributions in binary form must reproduce the above copyright | 8 # 2. Redistributions in binary form must reproduce the above copyright | 
| 9 #    notice, this list of conditions and the following disclaimer in the | 9 #    notice, this list of conditions and the following disclaimer in the | 
| 10 #    documentation and/or other materials provided with the distribution. | 10 #    documentation and/or other materials provided with the distribution. | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 75 | 75 | 
| 76     def newtempdir(self): | 76     def newtempdir(self): | 
| 77         path = tempfile.mkdtemp() | 77         path = tempfile.mkdtemp() | 
| 78         self.directories.append(path) | 78         self.directories.append(path) | 
| 79         return path | 79         return path | 
| 80 | 80 | 
| 81 provider = ScopedTempFileProvider() | 81 provider = ScopedTempFileProvider() | 
| 82 | 82 | 
| 83 | 83 | 
| 84 class BindingsTests(object): | 84 class BindingsTests(object): | 
| 85     def __init__(self, reset_results, executive): | 85     def __init__(self, reset_results, test_python, executive): | 
| 86         self.reset_results = reset_results | 86         self.reset_results = reset_results | 
|  | 87         self.test_python = test_python | 
| 87         self.executive = executive | 88         self.executive = executive | 
| 88         _, self.interface_dependencies_filename = provider.newtempfile() | 89         _, self.interface_dependencies_filename = provider.newtempfile() | 
| 89         if reset_results: | 90         if reset_results: | 
| 90             self.event_names_filename = os.path.join(reference_directory, 'Event
     Interfaces.in') | 91             self.event_names_filename = os.path.join(reference_directory, 'Event
     Interfaces.in') | 
| 91         else: | 92         else: | 
| 92             _, self.event_names_filename = provider.newtempfile() | 93             _, self.event_names_filename = provider.newtempfile() | 
| 93 | 94 | 
| 94     def run_command(self, cmd): | 95     def run_command(self, cmd): | 
| 95         return self.executive.run_command(cmd) | 96         return self.executive.run_command(cmd) | 
| 96 | 97 | 
| 97     def generate_from_idl_pl(self, idl_file, output_directory): | 98     def generate_from_idl_pl(self, idl_file, output_directory): | 
| 98         cmd = ['perl', '-w', | 99         cmd = ['perl', '-w', | 
| 99                '-Ibindings/scripts', | 100                '-Ibindings/scripts', | 
| 100                '-Icore/scripts', | 101                '-Icore/scripts', | 
| 101                '-I../../JSON/out/lib/perl5', | 102                '-I../../JSON/out/lib/perl5', | 
| 102                'bindings/scripts/deprecated_generate_bindings.pl', | 103                'bindings/scripts/generate_bindings.pl', | 
| 103                # idl include directories (path relative to generate-bindings.pl) | 104                # idl include directories (path relative to generate-bindings.pl) | 
| 104                '--include', '.', | 105                '--include', '.', | 
| 105                '--outputDir', output_directory, | 106                '--outputDir', output_directory, | 
| 106                '--interfaceDependenciesFile', self.interface_dependencies_filena
     me, | 107                '--interfaceDependenciesFile', self.interface_dependencies_filena
     me, | 
| 107                '--idlAttributesFile', 'bindings/scripts/IDLAttributes.txt', | 108                '--idlAttributesFile', 'bindings/scripts/IDLAttributes.txt', | 
| 108                idl_file] | 109                idl_file] | 
| 109         try: | 110         try: | 
| 110             output = self.run_command(cmd) | 111             output = self.run_command(cmd) | 
| 111         except ScriptError, e: | 112         except ScriptError, e: | 
| 112             print e.output | 113             print e.output | 
| 113             return e.exit_code | 114             return e.exit_code | 
| 114         if output: | 115         if output: | 
| 115             print output | 116             print output | 
| 116         return 0 | 117         return 0 | 
| 117 | 118 | 
| 118     def generate_from_idl_py(self, idl_file, output_directory): | 119     def generate_from_idl_py(self, idl_file, output_directory): | 
| 119         cmd = ['python', | 120         cmd = ['python', | 
| 120                'bindings/scripts/idl_compiler.py', | 121                'bindings/scripts/unstable/idl_compiler.py', | 
| 121                '--output-dir', output_directory, | 122                '--output-dir', output_directory, | 
| 122                '--idl-attributes-file', 'bindings/scripts/IDLAttributes.txt', | 123                '--idl-attributes-file', 'bindings/scripts/IDLAttributes.txt', | 
| 123                '--include', '.', | 124                '--include', '.', | 
| 124                '--interface-dependencies-file', | 125                '--interface-dependencies-file', | 
| 125                self.interface_dependencies_filename, | 126                self.interface_dependencies_filename, | 
| 126                idl_file] | 127                idl_file] | 
| 127         try: | 128         try: | 
| 128             output = self.run_command(cmd) | 129             output = self.run_command(cmd) | 
| 129         except ScriptError, e: | 130         except ScriptError, e: | 
| 130             print e.output | 131             print e.output | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 227 | 228 | 
| 228         if self.reset_results: | 229         if self.reset_results: | 
| 229             passed = True | 230             passed = True | 
| 230         else: | 231         else: | 
| 231             passed = self.identical_file(reference_event_names_filename, | 232             passed = self.identical_file(reference_event_names_filename, | 
| 232                                          self.event_names_filename) | 233                                          self.event_names_filename) | 
| 233         passed &= all([generate_and_check_output_pl(input_file) | 234         passed &= all([generate_and_check_output_pl(input_file) | 
| 234                        for input_file in os.listdir(input_directory) | 235                        for input_file in os.listdir(input_directory) | 
| 235                        if input_file.endswith('.idl')]) | 236                        if input_file.endswith('.idl')]) | 
| 236         print | 237         print | 
| 237         print 'Python:' | 238         if self.test_python: | 
| 238         passed &= all([generate_and_check_output_py(input_file) | 239             print 'Python:' | 
| 239                        for input_file in os.listdir(input_directory) | 240             passed &= all([generate_and_check_output_py(input_file) | 
| 240                        if input_file.endswith('.idl')]) | 241                            for input_file in os.listdir(input_directory) | 
|  | 242                            if input_file.endswith('.idl')]) | 
| 241         return passed | 243         return passed | 
| 242 | 244 | 
| 243     def main(self): | 245     def main(self): | 
| 244         current_scm = detect_scm_system(os.curdir) | 246         current_scm = detect_scm_system(os.curdir) | 
| 245         os.chdir(os.path.join(current_scm.checkout_root, 'Source')) | 247         os.chdir(os.path.join(current_scm.checkout_root, 'Source')) | 
| 246 | 248 | 
| 247         if self.generate_interface_dependencies(): | 249         if self.generate_interface_dependencies(): | 
| 248             print 'Failed to generate interface dependencies file.' | 250             print 'Failed to generate interface dependencies file.' | 
| 249             return -1 | 251             return -1 | 
| 250 | 252 | 
| 251         all_tests_passed = self.run_tests() | 253         all_tests_passed = self.run_tests() | 
| 252         print | 254         print | 
| 253         if all_tests_passed: | 255         if all_tests_passed: | 
| 254             print 'All tests PASS!' | 256             print 'All tests PASS!' | 
| 255             return 0 | 257             return 0 | 
| 256         print 'Some tests FAIL! (To update the reference files, execute "run-bin
     dings-tests --reset-results")' | 258         print 'Some tests FAIL! (To update the reference files, execute "run-bin
     dings-tests --reset-results")' | 
| 257         return -1 | 259         return -1 | 
| OLD | NEW | 
|---|