zayfod / pyfranca

A Python module and tools for working with Franca interface definition language (IDL) models.
MIT License
19 stars 13 forks source link

fix bug in import_file() #23

Closed jb090979 closed 7 years ago

jb090979 commented 7 years ago

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.

jb090979 commented 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:

File already loaded.

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.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.003%) to 93.889% when pulling a667626c22c9ab4f88f41b50d10cd706050e857e on jb090979:feature/bug_import_file into 6cc79e3f006955179bc59a6e6a2d484a7342e83b on zayfod:dev.

zayfod commented 7 years ago

OK, thanks.