コード例 #1
0
    def test_allow_interactiv_follow_up(self):
        wdir = self.tmp_dir.add("inter_follow_up")
        comm = __file__

        case = AS.FromComm("c")
        cfg = AS.Cfg()
        cfg.add("n", AS.Param("nomjob", "ifup"))
        cfg.add("m", AS.Param("mode", "batch"))
        case.use(cfg)
        case.use_working_dir(wdir)
        case.use(AS.InteractivFollowUp())
        case.use(AS.CommFile(comm))

        fname = case.build_export_file().fname

        res = [
            "P nomjob ifup",
            "P mode batch",
            "P follow_output yes",
            "F comm %s D 1" % comm,
        ]
        fid = open(fname)
        expf = fid.read()
        for line in res:
            self.assert_(line in expf, "not found : %s" % line)
        fid.close()
コード例 #2
0
    def test_use_comm_file_rep_if_no_rep_given(self):
        rep = self.tmp_dir.add("no_rep_given")
        cfg = AS.Cfg()
        cfg.add("name", AS.Param("nomjob", "test"))
        cfg.add("mode", AS.Param("mode", "batch"))
        comm = osp.join(rep, "f.comm")
        open(comm, "w").close()
        case = AS.build_case("f")
        case.use(cfg)
        case.use(AS.CommFile(comm))

        fname = case.build_export_file().fname

        self.assert_(osp.isfile(fname))
        self.assertEqual(osp.dirname(fname), rep)
        self.assert_(case.export_bld.working_dir is None)
コード例 #3
0
    def test_display_astk_parameters_for_solver(self):
        cfg = astk.Cfg()
        cfg.add("dbg", astk.Param("debug", "nodebug"))
        cfg.add("mem", astk.Attr("memory", 128))

        cparams = aster_s.AstkParams(cfg)
        cparams.name = "p"
        params = cparams.build(self.std)
        pnode = params.node
        self.assertEqual(params.read_name(), "p")
        params.attach_cfg(cfg)
        dbg = ST.Line(pnode.find_node("dbg"))
        self.assertEqual(dbg.read_name(), "dbg")
        self.assertEqual(dbg.read_value(), "nodebug")
        self.assertEqual(params["dbg"], "nodebug")

        mem = ST.Line(pnode.find_node("mem"))
        self.assertEqual(mem.read_value(), 128)
        self.assertEqual(mem.read_visible_value(), '128')
        params["mem"] = 256
        self.assertEqual(mem.read_value(), 256)
        self.assertEqual(mem.read_visible_value(), '256')
        
        params["dbg"] = "debug"
        astk_cfg = params.get_cfg()
        self.assertEqual(astk_cfg["mem"].value, 256)
        self.assertEqual(astk_cfg["dbg"].value, "debug")
コード例 #4
0
 def test_check_two_configuration_equality(self):
     cfgs = [AS.Cfg() for idx in range(2)]
     for cfg in cfgs:
         cfg.add("v", AS.Param("v", "v1"))
         cfg.add("p", AS.Attr("p", "p1"))
     self.assert_(cfgs[0] is not cfgs[1])
     self.assert_(cfgs[0].equal(cfgs[1]))
     cfgs[0]["v"].value = "v2"
     self.assert_(not cfgs[0].equal(cfgs[1]))
コード例 #5
0
    def test_copy_configuration(self):
        cfg = AS.Cfg()
        cfg.add("v", AS.Param("v", "v1"))
        cfg.add("c", AS.Attr("m", "f"))
        copy = cfg.copy()
        self.assert_(copy is not cfg)
        self.assert_(copy.equal(cfg))

        self.assert_(cfg["v"] is not copy["v"])
        self.assert_(cfg["c"] is not copy["c"])
コード例 #6
0
    def test_build_export_file(self):
        rep = self.tmp_dir.add("build")
        comm = get_data("forma01a.comm")
        med = get_data("forma01a.comm")
        cfg = AS.Cfg()
        cfg.add("v", AS.Param("version", "STA10.0"))
        cfg.add("name", AS.Param("nomjob"))
        cfg.add("m", AS.Param("mode", "bash"))
        cfg.add("n", AS.Attr("nb-cpu", 2))

        bld = AS.ExportFileBuilder("forma01-case")
        bld.working_dir = rep
        bld.add(cfg)
        bld.add(AS.RMessFile())
        bld.add(AS.CommFile(comm))
        bld.add(AS.MedFile(med))
        bld.add(AS.RResuFile())
        bld.add(AS.RRMedFile())
        bld.add(AS.Base())

        fname = bld.write().fname

        fpat = osp.join(rep, "forma01-case")
        self.assertEqual(fname, fpat + ".export")
        res = [
            "P version STA10.0",
            "P nomjob forma01-case",
            "P mode bash",
            "A nb-cpu 2",
            "F comm %s D 1" % comm,
            "F mmed %s D 20" % med,
            "F mess %s R 6" % (fpat + ".mess"),
            "F resu %s R 8" % (fpat + ".resu"),
            "F rmed %s R 80" % (fpat + ".rmed"),
            "R base %s RC 0" % (fpat + "base"),
        ]
        fid = open(fname)
        expf = fid.read()
        for line in res:
            self.assert_(line in expf, "not found : %s" % line)
        fid.close()
コード例 #7
0
 def test_write_export_file_for_stanley(self):
     wdir = self.tmp_dir.add("write_stanley_export")
     basename = "/tmp/aster/base_dir"
     res = [
         "P nomjob stanley",
         "P mode bash",
         "P special stanley%%NEXT%%R base %s DC 0" % basename,
     ]
     cfg = AS.Cfg()
     cfg.add("name", AS.Param("nomjob", "stanley"))
     cfg.add("m", AS.Param("mode", "bash"))
     case = AS.build_case("run_stanley", AS.RunStanley)
     case.use_working_dir(wdir)
     case.use(cfg)
     case.use(AS.StanleyBase(basename))
     exf = case.build_export_file()
     fid = open(exf.fname)
     lines = fid.read().splitlines()
     for line in res:
         self.assert_(line in lines, line)
     fid.close()
コード例 #8
0
    def test_clear_section_when_new_configuration_attached(self):
        cfg = astk.Cfg()
        cfg.add("mem", astk.Attr("memory", 128))
        parent = AS.Elt(self.std.node.add_node("p"), AS.Elt)

        cparams = aster_s.AstkParams(cfg)
        params = cparams.build(parent)
        mem = params.get_elt("mem")
        self.assert_(mem.node.is_alive())
        
        cfg = astk.Cfg()
        cfg.add("dbg", astk.Param("debug"))
        params.attach_cfg(cfg)
        self.assert_(not mem.node.is_alive())
コード例 #9
0
    def test_build_astk_case(self):
        acfg = astk.Cfg()
        acfg.add("name", astk.Param("n")) 
        comm = __file__
        mmed = UT.__file__

        case = self.std.add_case("a")
        case.use(aster_s.AstkParams(acfg))
        case.use(aster_s.CommFile(comm))
        acs = case.build_astk_case()
        bld = acs.export_bld
        self.assert_(bld.working_dir is None)
        cfg = bld.get(astk.Cfg)
        self.assert_(cfg.equal(acfg))
        self.assertEqual(bld.name, "a")
        self.assertEqual(bld.get(astk.CommFile).fname, comm)
        self.assert_(not bld.get(astk.MedFile))

        case.use(aster_s.WorkingDir("/tmp/a"))
        acs = case.build_astk_case()
        self.assertEqual(acs.export_bld.working_dir, "/tmp/a")

        case.use(aster_s.MedFile(mmed))
        case.write_name("c")
        acs = case.build_astk_case()
        bld = acs.export_bld
        self.assertEqual(bld.name, "c")
        self.assertEqual(bld.get(astk.MedFile).fname, mmed)

        case.use(aster_s.HasBaseResult())
        acs = case.build_astk_case()
        bld = acs.export_bld
        self.assert_(bld.get(astk.Base))

        comm_file = case.get(aster_s.CommFile)
        med_file = case.get(aster_s.MedFile)
        case = self.std.add_case("d")
        case.use(aster_s.CommEntry(comm_file.node.entry))
        case.use(aster_s.MedEntry(med_file.node.entry))
        acs = case.build_astk_case()
        bld = acs.export_bld
        self.assertEqual(bld.get(astk.CommFile).fname, comm)
        self.assertEqual(bld.get(astk.MedFile).fname, mmed)