Exemplo n.º 1
0
    def test_b_user_mods(self):
        cls = self.__class__

        testdir = os.path.join(cls._testroot, "testusermods")
        if os.path.exists(testdir):
            shutil.rmtree(testdir)

        cls._testdirs.append(testdir)

        user_mods_dir = os.path.join(
            utils.get_python_libs_root(), "..", "tests", "user_mods_test1"
        )
        args = (
            " --case %s --compset X --user-mods-dir %s --output-root %s --handle-preexisting-dirs=r"
            % (testdir, user_mods_dir, cls._testroot)
        )
        if utils.get_model() == "cesm":
            args += " --run-unsupported"
        if self.TEST_COMPILER is not None:
            args = args + " --compiler %s" % self.TEST_COMPILER
        if self.TEST_MPILIB is not None:
            args = args + " --mpilib %s" % self.TEST_MPILIB
        if utils.get_cime_default_driver() == "nuopc":
            args += " --res f19_g17 "
        else:
            args += " --res f19_g16 "

        args += f" --machine {self.MACHINE.get_machine_name()}"

        self.run_cmd_assert_result(
            "%s/create_newcase %s " % (self.SCRIPT_DIR, args), from_dir=self.SCRIPT_DIR
        )

        self.assertTrue(
            os.path.isfile(
                os.path.join(testdir, "SourceMods", "src.drv", "somefile.F90")
            ),
            msg="User_mods SourceMod missing",
        )

        with open(os.path.join(testdir, "user_nl_cpl"), "r") as fd:
            contents = fd.read()
            self.assertTrue(
                "a different cpl test option" in contents,
                msg="User_mods contents of user_nl_cpl missing",
            )
            self.assertTrue(
                "a cpl namelist option" in contents,
                msg="User_mods contents of user_nl_cpl missing",
            )
        cls._do_teardown.append(testdir)
Exemplo n.º 2
0
    def test_c_create_clone_keepexe(self):
        cls = self.__class__

        testdir = os.path.join(cls._testroot, "test_create_clone_keepexe")
        if os.path.exists(testdir):
            shutil.rmtree(testdir)
        prevtestdir = cls._testdirs[0]
        user_mods_dir = os.path.join(
            utils.get_python_libs_root(), "..", "tests", "user_mods_test3"
        )

        cmd = "%s/create_clone --clone %s --case %s --keepexe --user-mods-dir %s" % (
            self.SCRIPT_DIR,
            prevtestdir,
            testdir,
            user_mods_dir,
        )
        self.run_cmd_assert_result(cmd, from_dir=self.SCRIPT_DIR, expected_stat=1)
        cls._do_teardown.append(testdir)
Exemplo n.º 3
0
    def _setup_cs_files(self):
    ###########################################################################
        try:
            python_libs_root = get_python_libs_root()

            create_cs_status(test_root=self._test_root,
                             test_id=self._test_id)

            template_file = os.path.join(python_libs_root, "cs.submit.template")
            template = open(template_file, "r").read()
            setup_cmd = "./case.setup" if self._no_setup else ":"
            build_cmd = "./case.build" if self._no_build else ":"
            test_cmd  = "./case.submit"
            template = template.replace("<SETUP_CMD>", setup_cmd).\
                       replace("<BUILD_CMD>", build_cmd).\
                       replace("<RUN_CMD>", test_cmd).\
                       replace("<TESTID>", self._test_id)

            if self._no_run:
                cs_submit_file = os.path.join(self._test_root, "cs.submit.{}".format(self._test_id))
                with open(cs_submit_file, "w") as fd:
                    fd.write(template)
                os.chmod(cs_submit_file,
                         os.stat(cs_submit_file).st_mode | stat.S_IXUSR | stat.S_IXGRP)

            if self._cime_model == "cesm":
                template_file = os.path.join(python_libs_root, "testreporter.template")
                template = open(template_file, "r").read()
                template = template.replace("<PATH>",
                                            os.path.join(self._cime_root, "scripts", "Tools"))
                testreporter_file = os.path.join(self._test_root, "testreporter")
                with open(testreporter_file, "w") as fd:
                    fd.write(template)
                os.chmod(testreporter_file, os.stat(testreporter_file).st_mode
                         | stat.S_IXUSR | stat.S_IXGRP)

        except Exception as e:
            logger.warning("FAILED to set up cs files: {}".format(str(e)))