def test_commit_no_tags(git_modules_dir, module_without_tags, dev, tag, version_tag_in_output): add_file(module_without_tags, "dummyfile", "Content", "Commit without tags", version="5.0", dev=dev, tag=tag) output = subprocess.check_output(["git", "tag", "-l"], cwd=module_without_tags, stderr=subprocess.STDOUT) assert ("5.0" in str(output)) is version_tag_in_output
def test_module_update_with_install_mode_master( tmpdir: py.path.local, modules_repo: str, kwargs_update_method: Dict[str, str], mod2_should_be_updated: bool, mod8_should_be_updated: bool, ) -> None: # Make a copy of masterproject_multi_mod masterproject_multi_mod = tmpdir.join("masterproject_multi_mod") clone_repo(modules_repo, "masterproject_multi_mod", tmpdir) libs_folder = os.path.join(masterproject_multi_mod, "libs") os.mkdir(libs_folder) # Set masterproject_multi_mod as current project os.chdir(masterproject_multi_mod) Config.load_config() # Dependencies masterproject_multi_mod for mod in ["mod2", "mod8"]: # Clone mod in root tmpdir clone_repo(modules_repo, mod, tmpdir) # Clone mod from root of tmpdir into libs folder of masterproject_multi_mod clone_repo(tmpdir, mod, libs_folder) # Update module in root of tmpdir by adding an extra file file_name_extra_file = "test_file" path_mod = os.path.join(tmpdir, mod) add_file(path_mod, file_name_extra_file, "test", "Second commit") # Assert test_file not present in libs folder of masterproject_multi_mod path_extra_file = os.path.join(libs_folder, mod, file_name_extra_file) assert not os.path.exists(path_extra_file) # Update module(s) of masterproject_multi_mod ModuleTool().update(**kwargs_update_method) # Assert availability of test_file in masterproject_multi_mod extra_file_mod2 = os.path.join(libs_folder, "mod2", file_name_extra_file) assert os.path.exists(extra_file_mod2) == mod2_should_be_updated extra_file_mod8 = os.path.join(libs_folder, "mod8", file_name_extra_file) assert os.path.exists(extra_file_mod8) == mod8_should_be_updated
def modules_repo(git_modules_dir) -> str: """ +--------+-------------+----------+ | Name | Requires | Versions | +--------+-------------+----------+ | std | | 0.0.1 | +--------+-------------+----------+ | | | 3.2 | +--------+-------------+----------+ | mod1 | mod3 ~= 0.1 | 0.0.1 | +--------+-------------+----------+ | | mod3 ~= 0.1 | 3.2 | +--------+-------------+----------+ | mod2 | | 0.0.1 | +--------+-------------+----------+ | | | 2016.1 | +--------+-------------+----------+ | mod3 | | 0.0.1 | +--------+-------------+----------+ | | | 0.1 | +--------+-------------+----------+ | badmod | mod2 < 2016 | 0.0.1 | +--------+-------------+----------+ | | | 0.1 | +--------+-------------+----------+ | mod5 | | 0.0.1 | +--------+-------------+----------+ | | | 0.1 | +--------+-------------+----------+ | mod6 | | 0.0.1 | +--------+-------------+----------+ | | | 3.2 | +--------+-------------+----------+ | mod7 | | 0.0.1 | +--------+-------------+----------+ | | | 3.2 | +--------+-------------+----------+ | | | 3.2.1 | +--------+-------------+----------+ | | | 3.2.2 | +--------+-------------+----------+ | | | 4.0 | +--------+-------------+----------+ | | | 4.2 | +--------+-------------+----------+ | | | 4.3 | +--------+-------------+----------+ | mod8 | | 0.0.1 | +--------+-------------+----------+ | | | 3.2 | +--------+-------------+----------+ | | | 3.3.dev | +--------+-------------+----------+""" tempdir = git_modules_dir reporoot = os.path.join(tempdir, "repos") os.makedirs(reporoot) make_module_simple(reporoot, "std") make_module_simple(reporoot, "mod1", depends=[("mod3", "~=0.1")]) make_module_simple(reporoot, "mod2", version="2016.1") mod3 = make_module_simple(reporoot, "mod3", version="0.1") add_file(mod3, "badsignal", "present", "third commit") mod4 = make_module_simple(reporoot, "badmod", [("mod2", "<2016")]) add_file(mod4, "badsignal", "present", "third commit") mod5 = make_module_simple(reporoot, "mod5", version="0.1") add_file(mod5, "badsignal", "present", "third commit") mod6 = make_module_simple(reporoot, "mod6") add_file(mod6, "badsignal", "present", "third commit") mod7 = make_module_simple(reporoot, "mod7") add_file(mod7, "nsignal", "present", "third commit", version="3.2.1") add_file(mod7, "signal", "present", "fourth commit", version="3.2.2") add_file_and_compiler_constraint(mod7, "badsignal", "present", "fifth commit", version="4.0", compiler_version="1000000.4") add_file(mod7, "badsignal", "present", "sixth commit", version="4.1") add_file_and_compiler_constraint(mod7, "badsignal", "present", "fifth commit", version="4.2", compiler_version="1000000.5") add_file(mod7, "badsignal", "present", "sixth commit", version="4.3") mod8 = make_module_simple(reporoot, "mod8", []) add_file(mod8, "devsignal", "present", "third commit", version="3.3.dev2") add_file(mod8, "mastersignal", "present", "last commit") mod11 = make_module_simple(reporoot, "mod11") add_file(mod11, "file", "test", "release version 3.2.1", version="3.2.1") add_file(mod11, "file", "test", "release version 4.0.0", version="4.0.0") add_file(mod11, "file", "test", "release version 4.1.0", version="4.1.0") add_file(mod11, "file", "test", "release version 4.1.2", version="4.1.2") add_file(mod11, "file", "test", "release version 4.2.0", version="4.2.0") proj = makemodule(reporoot, "testproject", [("mod1", None), ("mod2", ">2016"), ("mod5", None)], True, ["mod1", "mod2", "mod6", "mod7"]) # results in loading of 1,2,3,6 commitmodule(proj, "first commit") badproject = makemodule(reporoot, "badproject", [("mod15", None)], True) commitmodule(badproject, "first commit") baddep = makemodule(reporoot, "baddep", [("badmod", None), ("mod2", ">2016")], True) commitmodule(baddep, "first commit") devproject = makeproject(reporoot, "devproject", imports=["mod8"], install_mode=InstallMode.prerelease) commitmodule(devproject, "first commit") masterproject = makeproject(reporoot, "masterproject", imports=["mod8"], install_mode=InstallMode.master) commitmodule(masterproject, "first commit") masterproject_multi_mod = makeproject(reporoot, "masterproject_multi_mod", imports=["mod2", "mod8"], install_mode=InstallMode.master) commitmodule(masterproject_multi_mod, "first commit") nover = makemodule(reporoot, "nover", []) commitmodule(nover, "first commit") add_file(nover, "signal", "present", "second commit") noverproject = makeproject(reporoot, "noverproject", imports=["nover"]) commitmodule(noverproject, "first commit") """ for freeze, test from C A-> B,C,D C-> E,F,E::a C::a -> I E::a -> J E-> H D-> F,G """ make_module_simple_deps(reporoot, "A", ["B", "C", "D"], project=True) make_module_simple_deps(reporoot, "B") c = make_module_simple_deps(reporoot, "C", ["E", "F", "E::a"], version="3.0") add_file(c, "model/a.cf", "import modI", "add mod C::a", "3.2") make_module_simple_deps(reporoot, "D", ["F", "G"]) e = make_module_simple_deps(reporoot, "E", ["H"], version="3.0") add_file(e, "model/a.cf", "import modJ", "add mod E::a", "3.2") make_module_simple_deps(reporoot, "F") make_module_simple_deps(reporoot, "G") make_module_simple_deps(reporoot, "H") make_module_simple_deps(reporoot, "I") make_module_simple_deps(reporoot, "J") return reporoot
def test_module_corruption(modules_dir, modules_repo): mod9 = make_module_simple(modules_repo, "mod9", [("mod10", None)]) add_file(mod9, "signal", "present", "third commit", version="3.3") add_file(mod9, "model/b.cf", "import mod9", "fourth commit", version="4.0") mod10 = make_module_simple(modules_repo, "mod10", []) add_file(mod10, "signal", "present", "a commit", version="3.3") # syntax error add_file(mod10, "model/_init.cf", "SomeInvalidThings", "a commit", version="3.5") # fix it add_file(mod10, "model/_init.cf", "", "a commit", version="3.6") add_file(mod10, "secondsignal", "import mod9", "b commit", version="4.0") add_file(mod10, "badsignal", "import mod9", "c commit", version="5.0") p9 = makeproject(modules_repo, "proj9", [("mod9", "==3.3"), ("mod10", "==3.3")], ["mod9"]) commitmodule(p9, "first commit") # setup project proj = install_project(modules_dir, "proj9") app(["modules", "install"]) print(os.listdir(proj)) # unfreeze deps to allow update projectyml = os.path.join(proj, "project.yml") assert os.path.exists(projectyml) with open(projectyml, "r", encoding="utf-8") as fh: pyml = yaml.load(fh) pyml["requires"] = ["mod10 == 3.5"] with open(projectyml, "w", encoding="utf-8") as fh: yaml.dump(pyml, fh) # clear cache Project._project = None # attempt to update, mod10 is wrong, but only after the update app(["modules", "update"]) with pytest.raises(ParserException): # clear cache Project._project = None # attempt to update, mod10 is wrong, can not be fixed app(["modules", "update"]) # unfreeze deps to allow update pyml["requires"] = ["mod10 == 4.0"] with open(projectyml, "w", encoding="utf-8") as fh: yaml.dump(pyml, fh) # overwrite main to import unknown sub module main = os.path.join(proj, "main.cf") assert os.path.exists(main) with open(main, "w", encoding="utf-8") as fh: fh.write("import mod9::b") # clear cache Project._project = None # attempt to update app(["modules", "update"]) # Additional output Project._project = None app(["modules", "list"]) # Verify m9dir = os.path.join(proj, "libs", "mod9") assert os.path.exists(os.path.join(m9dir, "model", "b.cf")) m10dir = os.path.join(proj, "libs", "mod10") assert os.path.exists(os.path.join(m10dir, "secondsignal")) # should not be lastest version assert not os.path.exists(os.path.join(m10dir, "badsignal"))