def test_write_depends_skip_programs(self, datadir):
        expected_contents = [
            DEPFILE_HEADER,
            "moduleA.o :",
            "moduleB.o : moduleA.o",
            "moduleC.o : moduleA.o moduleB.o",
            "moduleD.o : moduleC.o",
            "moduleE.o :",
            "multiple_modules.o :",
            "programTest.o : moduleC.o moduleD.o",
        ]

        testproject = FortranProject()
        testproject.write_depends(skip_programs=True)

        with open(str(datadir.join("makefile.dep")), 'r') as f:
            contents = f.read()

        # A little manipulation to remove extraneous whitespace is
        # required in order for a clean comparison
        contents = contents.replace('\\\n\t', ' ')
        contents = re.sub(r' +', ' ', contents)
        contents = [line.lstrip().rstrip(" \t\n") for line in contents.splitlines() if line != '']

        assert sorted(expected_contents) == sorted(contents)
    def test_write_depends_no_overwrite(self, datadir):
        expected_contents = [
            DEPFILE_HEADER,
            "moduleA.o :",
            "moduleB.o : moduleA.o",
            "moduleC.o : moduleA.o moduleB.o",
            "moduleD.o : moduleC.o",
            "moduleE.o :",
            "multiple_modules.o :",
            "programTest.o : moduleC.o moduleD.o",
            "progA : multiple_modules.o",
            "test : moduleA.o moduleB.o moduleC.o moduleD.o programTest.o",
        ]

        FortranProject().write_depends()
        testproject = FortranProject(exclude_files="multiple_modules.f90")

        with mock.patch.object(builtins, 'input', lambda x: 'N'):
            testproject.write_depends(overwrite=False)

        with open(str(datadir.join("makefile.dep")), 'r') as f:
            contents = f.read()

        # A little manipulation to remove extraneous whitespace is
        # required in order for a clean comparison
        contents = contents.replace('\\\n\t', ' ')
        contents = re.sub(r' +', ' ', contents)
        contents = [line.lstrip().rstrip(" \t\n") for line in contents.splitlines() if line != '']

        assert sorted(expected_contents) == sorted(contents)
예제 #3
0
    def test_write_depends_skip_programs(self, datadir):
        expected_contents = [
            DEPFILE_HEADER,
            "moduleA.o :",
            "moduleB.o : moduleA.o",
            "moduleC.o : moduleA.o moduleB.o",
            "moduleD.o : moduleC.o",
            "moduleE.o :",
            "multiple_modules.o :",
            "programTest.o : moduleC.o moduleD.o",
        ]

        testproject = FortranProject()
        testproject.write_depends(skip_programs=True)

        with open(str(datadir.join("makefile.dep")), 'r') as f:
            contents = f.read()

        # A little manipulation to remove extraneous whitespace is
        # required in order for a clean comparison
        contents = contents.replace('\\\n\t', ' ')
        contents = re.sub(r' +', ' ', contents)
        contents = [
            line.lstrip().rstrip(" \t\n") for line in contents.splitlines()
            if line != ''
        ]

        assert sorted(expected_contents) == sorted(contents)
예제 #4
0
    def test_write_depends_no_overwrite(self, datadir):
        expected_contents = [
            DEPFILE_HEADER,
            "moduleA.o :",
            "moduleB.o : moduleA.o",
            "moduleC.o : moduleA.o moduleB.o",
            "moduleD.o : moduleC.o",
            "moduleE.o :",
            "multiple_modules.o :",
            "programTest.o : moduleC.o moduleD.o",
            "progA : multiple_modules.o",
            "test : moduleA.o moduleB.o moduleC.o moduleD.o programTest.o",
        ]

        FortranProject().write_depends()
        testproject = FortranProject(exclude_files="multiple_modules.f90")

        with mock.patch.object(builtins, 'input', lambda x: 'N'):
            testproject.write_depends(overwrite=False)

        with open(str(datadir.join("makefile.dep")), 'r') as f:
            contents = f.read()

        # A little manipulation to remove extraneous whitespace is
        # required in order for a clean comparison
        contents = contents.replace('\\\n\t', ' ')
        contents = re.sub(r' +', ' ', contents)
        contents = [
            line.lstrip().rstrip(" \t\n") for line in contents.splitlines()
            if line != ''
        ]

        assert sorted(expected_contents) == sorted(contents)
예제 #5
0
def main(args=None):
    """Run the module as a script

    """

    parser = create_argument_parser()
    # Parse the command line arguments
    args = parser.parse_args()

    # Assemble a dictionary out of the macro definitions
    macros = {}
    if args.D:
        for arg in args.D:
            for var in arg:
                if '=' not in var:
                    macros[var] = ''
                else:
                    temp = var.split('=')
                    macros[temp[0]] = temp[1]

    output = args.output[0] if args.output else None
    build = args.build[0] if args.build else ''

    # Sorts out the terminal colours on Windows
    strip_colours = not args.colour
    colorama.init(strip=strip_colours)

    project = FortranProject(files=args.files,
                             exclude_files=args.exclude_files,
                             ignore_modules=args.ignore_modules,
                             macros=macros,
                             cpp_includes=args.I,
                             verbose=args.verbose,
                             use_preprocessor=not args.no_preprocessor)

    if output is not None:
        project.write_depends(filename=output,
                              overwrite=args.overwrite,
                              build=build,
                              skip_programs=args.skip_programs)

    if args.graph:
        project.make_graph()
예제 #6
0
def main(args=None):
    """Run the module as a script

    """

    parser = create_argument_parser()
    # Parse the command line arguments
    args = parser.parse_args()

    # Assemble a dictionary out of the macro definitions
    macros = {}
    if args.D:
        for arg in args.D:
            for var in arg:
                if '=' not in var:
                    macros[var] = ''
                else:
                    temp = var.split('=')
                    macros[temp[0]] = temp[1]

    output = args.output[0] if args.output else None
    build = args.build[0] if args.build else ''

    # Sorts out the terminal colours on Windows
    strip_colours = not args.colour
    colorama.init(strip=strip_colours)

    project = FortranProject(files=args.files, exclude_files=args.exclude_files,
                             ignore_modules=args.ignore_modules,
                             macros=macros, cpp_includes=args.I,
                             verbose=args.verbose,
                             use_preprocessor=not args.no_preprocessor)

    if output is not None:
        project.write_depends(filename=output, overwrite=args.overwrite, build=build,
                              skip_programs=args.skip_programs)

    if args.graph:
        project.make_graph()