def test_2(self): """Resolve a package with a dependency, see that their commands are concatenated as expected.""" pkg = VersionedObject("rextest2-2") base = os.path.join(self.packages_path, "rextest", "1.3") base2 = os.path.join(self.packages_path, "rextest2", "2") cmds = [ Setenv('REZ_USED_REQUEST', "rextest2-2"), Setenv('REZ_USED_RESOLVE', "rextest-1.3 rextest2-2"), # rez's rextest vars Setenv('REZ_REXTEST_VERSION', "1.3"), Setenv('REZ_REXTEST_BASE', base), Setenv('REZ_REXTEST_ROOT', base), # rez's rextest2 vars Setenv('REZ_REXTEST2_VERSION', '2'), Setenv('REZ_REXTEST2_BASE', base2), Setenv('REZ_REXTEST2_ROOT', base2), # rextest's commands Setenv('REXTEST_ROOT', base), Setenv('REXTEST_VERSION', "1.3"), Setenv('REXTEST_MAJOR_VERSION', "1"), Setenv('REXTEST_DIRS', "/".join([base, "data"])), Alias('rextest', 'foobar'), # rextext2's commands Appendenv('REXTEST_DIRS', "/".join([base2, "data2"])), Setenv('REXTEST2_REXTEST_VER', '1.3'), Setenv('REXTEST2_REXTEST_BASE', os.path.join(self.packages_path, "rextest", "1.3")) ] self._test_package(pkg, {}, cmds) # first prepend should still override self._test_package(pkg, {"REXTEST_DIRS": "TEST"}, cmds)
def _get_rextest_commands(self, pkg): verstr = str(pkg.version) base = os.path.join(self.packages_path, "rextest", verstr) cmds = [ Setenv('REZ_REXTEST_VERSION', verstr), Setenv('REZ_REXTEST_BASE', base), Setenv('REZ_REXTEST_ROOT', base), Setenv('REXTEST_ROOT', base), Setenv('REXTEST_VERSION', verstr), Setenv('REXTEST_MAJOR_VERSION', str(pkg.version[0])), Setenv('REXTEST_DIRS', "/".join([base, "data"])), Alias('rextest', 'foobar') ] return cmds
def test_1(self): """Test simple use of every available action.""" def _rex(): shebang() setenv("FOO", "foo") setenv("BAH", "bah") getenv("BAH") unsetenv("BAH") unsetenv("NOTEXIST") prependenv("A", "/tmp") prependenv("A", "/data") appendenv("B", "/tmp") appendenv("B", "/data") defined("BAH") undefined("BAH") defined("NOTEXIST") undefined("NOTEXIST") alias("thing", "thang") info("that's interesting") error("oh noes") command("runme --with --args") source("./script.src") self._test(func=_rex, env={}, expected_actions=[ Shebang(), Setenv('FOO', 'foo'), Setenv('BAH', 'bah'), Unsetenv('BAH'), Unsetenv('NOTEXIST'), Setenv('A', '/tmp'), Prependenv('A', '/data'), Setenv('B', '/tmp'), Appendenv('B', '/data'), Alias('thing', 'thang'), Info("that's interesting"), Error('oh noes'), Command('runme --with --args'), Source('./script.src') ], expected_output={ 'FOO': 'foo', 'A': os.pathsep.join(["/data", "/tmp"]), 'B': os.pathsep.join(["/tmp", "/data"]) })
def _get_rextest_commands(self, pkg): verstr = str(pkg.version) base = os.path.join(self.packages_path, "rextest", verstr) major_version = str(pkg.version[0] if len(pkg.version) >= 1 else '') minor_version = str(pkg.version[1] if len(pkg.version) >= 2 else '') patch_version = str(pkg.version[2] if len(pkg.version) >= 3 else '') cmds = [Setenv('REZ_REXTEST_VERSION', verstr), Setenv('REZ_REXTEST_MAJOR_VERSION', major_version), Setenv('REZ_REXTEST_MINOR_VERSION', minor_version), Setenv('REZ_REXTEST_PATCH_VERSION', patch_version), Setenv('REZ_REXTEST_BASE', base), Setenv('REZ_REXTEST_ROOT', base), # from package... Setenv('REXTEST_ROOT', base), Setenv('REXTEST_VERSION', verstr), Setenv('REXTEST_MAJOR_VERSION', str(pkg.version[0])), Setenv('REXTEST_DIRS', "/".join([base, "data"])), Alias('rextest', 'foobar')] return cmds