Skip to content

Commit

Permalink
Update SCanner/FortranTests.py
Browse files Browse the repository at this point in the history
Signed-off-by: Mats Wichmann <mats@linux.com>
  • Loading branch information
mwichmann committed Dec 29, 2023
1 parent 8305863 commit 621d144
Showing 1 changed file with 25 additions and 30 deletions.
55 changes: 25 additions & 30 deletions SCons/Scanner/FortranTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
'd1/f1.f', 'd1/f2.f', 'd1/f3.f', 'd1/fi.f',
'd1/d2/f1.f', 'd1/d2/f2.f', 'd1/d2/f3.f',
'd1/d2/f4.f', 'd1/d2/fi.f']

for h in test_headers:
test.write(h, "\n")

Expand Down Expand Up @@ -160,12 +159,17 @@
USE mod07;USE mod08; USE mod09 ;USE mod10 ; USE mod11 ! Test various semicolon placements
use mod12 ;use mod13! Test comment at end of line
! Test handling of module use that should be excluded.
! Note interleaving of 'use modi` with numbered modules that should be found,
! so by looking at the unsorted scanner module list, we can see *which*
! instance of 'modi' was picked up. known regex deficiencies are noted.
! USE modi
! USE modia ; use modib ! Scanner regexp will only ignore the first - this is a deficiency in the regexp
! USE modia ; use modib ! regex deficiency: modib picked up
! USE modic ; ! use modid ! Scanner regexp should ignore both modules
USE mod14 !; USE modi ! Only ignore the second
USE mod15!;USE modi
USE mod16 ! ; USE modi
USE mod14 !; USE modi ! regex deficiency: modi picked up
USE mod15!;USE modi ! regex deficiency: modi picked up
USE mod16 ! ; USE modi ! regex deficiency: modi picked up
! Test semicolon syntax - use various spacings
USE :: mod17
Expand All @@ -177,15 +181,15 @@
USE mod25 ! Test USE statement at the beginning of line
; USE modi ! Scanner should ignore this since it isn't valid syntax
; USE modi ! Scanner should ignore this since it isn't valid syntax (deficiency)
USEmodi ! No space in between USE and module name - ignore it
USE mod01 ! This one is a duplicate - there should only be one dependency to it.
STOP
END
""")

# TODO: not really needed as we don't scan for modules any more. Leave for now.
test_modules = [f"mod{i:02}.mod" for i in range(1, 26)]
for m in test_modules:
test.write(m, "\n")
Expand Down Expand Up @@ -308,7 +312,7 @@ def runTest(self) -> None:
deps = s(env.File('fff1.f'), env, path)
headers = ['d1/f1.f', 'd1/f2.f']
deps_match(self, deps, headers)
test.write(['d1', 'f2.f'], "\n")
test.write(['d1', 'f2.f'], "\n") # "global", restore it


class FortranScannerTestCase5(unittest.TestCase):
Expand Down Expand Up @@ -428,11 +432,11 @@ def runTest(self) -> None:
env.fs.chdir(env.Dir('include'))
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
test.write('include/fff4.f', test.read('fff4.f'))
test.write(['include', 'fff4.f'], test.read('fff4.f'))
deps = s(env.File('#include/fff4.f'), env, path)
env.fs.chdir(env.Dir(''))
deps_match(self, deps, ['f4.f'])
test.unlink('include/fff4.f')
test.unlink(['include', 'fff4.f'])


class FortranScannerTestCase13(unittest.TestCase):
Expand Down Expand Up @@ -492,32 +496,25 @@ def subst(self, arg, target=None, source=None, conv=None, test=test):
deps = s(env.File('fff1.f'), env, path)
headers = ['d1/f1.f', 'd1/f2.f']
deps_match(self, deps, headers)
test.write(['d1', 'f2.f'], "\n")
test.write(['d1', 'f2.f'], "\n") # "global", restore it


class FortranScannerTestCase16(unittest.TestCase):
def runTest(self) -> None:
test.write('f1.f', "\n")
test.write('f2.f', "\n")
test.write('f3.f', "\n")
test.write('f4.f', "\n")
test.write('f5.f', "\n")
test.write('f6.f', "\n")
test.write('f7.f', "\n")
test.write('f8.f', "\n")
test.write('f9.f', "\n")
test.write('f10.f', "\n")
headers = [f"f{i}.f" for i in range(1, 10)]
for header in headers:
test.write(header, "\n")
env = DummyEnvironment([test.workpath('modules')])
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
deps = s(env.File('fff90a.f90'), env, path)
headers = ['f1.f', 'f2.f', 'f3.f', 'f4.f', 'f5.f', 'f6.f', 'f7.f', 'f8.f', 'f9.f']
modules = ['mod01.mod', 'mod02.mod', 'mod03.mod', 'mod04.mod', 'mod05.mod',
'mod06.mod', 'mod07.mod', 'mod08.mod', 'mod09.mod', 'mod10.mod',
'mod11.mod', 'mod12.mod', 'mod13.mod', 'mod14.mod', 'mod15.mod',
'mod16.mod', 'mod17.mod', 'mod18.mod', 'mod19.mod', 'mod20.mod',
'mod21.mod', 'mod22.mod', 'mod23.mod', 'mod24.mod', 'mod25.mod', 'modules/use.mod']
deps_expected = headers + modules
modules = [f"mod{i:02}.mod" for i in range(1, 26)]
extra_modules = [
'modi.mod', # TODO: due to regex deficiency
'modib.mod', # TODO: due to regex deficiency
'use.mod'
]
deps_expected = headers + modules + extra_modules
deps_match(self, deps, deps_expected)
test.unlink('f1.f')
test.unlink('f2.f')
Expand All @@ -528,8 +525,6 @@ def runTest(self) -> None:
test.unlink('f7.f')
test.unlink('f8.f')
test.unlink('f9.f')
test.unlink('f10.f')



if __name__ == "__main__":
Expand Down

0 comments on commit 621d144

Please sign in to comment.