def test_prereq_failure(self): with self.assertRaises(PrereqException): self.pm.install_packages( PackageIdentifier.parse_list(["pkg-with-prereq_0.1"])) self.check_content(self.pm.list_installed_packages(), ["prereq-A_0.1-fail"]) self.assertEqual( 1, len( get_lines(self.install_folder / "prereq-A_0.1-fail" / "install.log"))) self.assertEqual( 1, len( get_lines(self.install_folder / "prereq-A_0.1-fail" / "sync.log"))) with self.assertRaises(PrereqException): self.pm.install_packages( PackageIdentifier.parse_list(["pkg-with-prereq_0.1"])) self.check_content(self.pm.list_installed_packages(), ["prereq-A_0.1-fail"]) self.assertEqual( 1, len( get_lines(self.install_folder / "prereq-A_0.1-fail" / "install.log"))) self.assertEqual( 2, len( get_lines(self.install_folder / "prereq-A_0.1-fail" / "sync.log")))
def test_deps_with_prereq(self): self.pm.install_packages(PackageIdentifier.parse_list(["pkg-with-deps-with-prereq_1.0"])) self.check_content(self.pm.list_installed_packages(), ["pkg-with-deps-with-prereq_1.0", "pkg-with-prereq_1.0", "prereq-A_1.0", "prereq-B_1.0"]) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-A_1.0" / "install.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-A_1.0" / "sync.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-B_1.0" / "install.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-B_1.0" / "sync.log")))
def test_sync(self): self.pm.install_packages(PackageIdentifier.parse_list(["sync_1.0"])) self.check_content(self.pm.list_installed_packages(), ["sync_1.0"]) self.check_installed_packages(["sync_1.0"]) sync_file = self.install_folder / "sync_1.0" / "sync.log" self.assertFalse(sync_file.exists()) self.pm.sync_packages(PackageIdentifier.parse_list(["sync_1.0"])) self.assertTrue(sync_file.exists()) self.assertEqual(["MYVALUE"], get_lines(sync_file)) self.pm.sync_packages(PackageIdentifier.parse_list(["sync_1.0"])) self.assertTrue(sync_file.exists()) self.assertEqual(["MYVALUE", "MYVALUE"], get_lines(sync_file)) self.pm.update_user_environment({"MYVAR2": "MYOTHERVALUE"}) self.pm.sync_packages(PackageIdentifier.parse_list(["sync_1.0"])) self.assertTrue(sync_file.exists()) self.assertEqual(["MYVALUE", "MYVALUE", "MYVALUE MYOTHERVALUE"], get_lines(sync_file))
def test_prereq(self): self.leaf_exec(["package", "install"], "pkg-with-prereq_0.1", expected_rc=2) self.leaf_exec(["package", "install"], "pkg-with-prereq_1.0") self.leaf_exec(["package", "install"], "pkg-with-prereq_2.0") self.assertEqual(1, len(get_lines(self.install_folder / "prereq-A_0.1-fail" / "install.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-A_0.1-fail" / "sync.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-A_1.0" / "install.log"))) self.assertEqual(2, len(get_lines(self.install_folder / "prereq-A_1.0" / "sync.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-B_1.0" / "install.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-B_1.0" / "sync.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-B_2.0" / "install.log"))) self.assertEqual(1, len(get_lines(self.install_folder / "prereq-B_2.0" / "sync.log")))
def test_sync(self): sync_file = self.install_folder / "sync_1.0" / "sync.log" self.assertFalse(sync_file.exists()) self.leaf_exec("init") self.leaf_exec(("profile", "create"), "foo") self.leaf_exec(("profile", "config"), "-p", "sync_1.0") self.leaf_exec(("profile", "sync")) self.assertTrue(sync_file.exists()) self.assertEqual(["MYVALUE"], get_lines(sync_file)) self.leaf_exec(("profile", "sync")) self.assertTrue(sync_file.exists()) self.assertEqual(["MYVALUE", "MYVALUE"], get_lines(sync_file)) self.leaf_exec(("package", "sync"), "sync_1.0") self.assertTrue(sync_file.exists()) self.assertEqual(["MYVALUE", "MYVALUE", "MYVALUE"], get_lines(sync_file)) self.leaf_exec(("env", "workspace"), "--set", "MYVAR2=AAA") self.leaf_exec(("profile", "sync")) self.assertTrue(sync_file.exists()) self.assertEqual(["MYVALUE", "MYVALUE", "MYVALUE", "MYVALUE AAA"], get_lines(sync_file)) self.leaf_exec(("env", "profile"), "--set", "MYVAR2=BBB") self.leaf_exec(("profile", "sync")) self.assertTrue(sync_file.exists()) self.assertEqual( ["MYVALUE", "MYVALUE", "MYVALUE", "MYVALUE AAA", "MYVALUE BBB"], get_lines(sync_file)) self.leaf_exec(("env", "profile"), "--set", "MYVAR1=FOO") self.leaf_exec(("profile", "sync")) self.assertTrue(sync_file.exists()) self.assertEqual([ "MYVALUE", "MYVALUE", "MYVALUE", "MYVALUE AAA", "MYVALUE BBB", "MYVALUE BBB" ], get_lines(sync_file))