Closed jb090979 closed 7 years ago
The function import_fiel() is not completely correct.
Remember my little modification on your unitest test_import_file_chain() self.processor.import_file(fspec) self.processor.import_file("./Type1.fidl")
In this case the unit test runs successful but if you debug your code, you see that fidl file Type1.fidl is imported twice.
abs_fspec = os.path.abspath(fspec) if abs_fspec in self.files:
fspec is just the file name --> "./Type1.fidl" abs_fspec = os.path.abspath(fspec) just join the current working directory with the file name 'E:\project\pyfranca\pyfranca\pyfranca\tests\Type1.fidl' in my case. But this is not the correct path and so "if abs_fspec in self.files:" failed. Later int the code the line " temp_fspec = os.path.abspath(os.path.join(path, fspec))" creates the correct path 'E:\project\pyfranca\pyfranca\pyfranca\tests\fidl\tmp\Type1.fidl'
Thats why it is important first to determine the fspec path and then checking if this file is already imported.
OK, thanks.
if fspec is a relative path it could be that a file is imported twice.
Fix: First determine absolute path of fidl file and then checks if the file is already imported.