diff --git a/test/check_activate.bat b/test/check_activate.bat new file mode 100644 index 0000000..686d217 --- /dev/null +++ b/test/check_activate.bat @@ -0,0 +1,19 @@ +echo "initial: %PATH%" + +call "test\here\bad (dir) 1\bin\activate" +echo "activate 1: %PATH%" + +call deactivate-lua +echo "deactivate 1: %PATH%" + +call "test\here\bad (dir) 1\bin\activate" +echo "activate 1 again: %PATH%" + +call "test\here\bad (dir) 1\bin\activate" +echo "reactivate 1: %PATH%" + +call "test\here\bad (dir) 2\bin\activate" +echo "activate 2: %PATH%" + +call deactivate-lua +echo "deactivate 2: %PATH%" diff --git a/test/check_activate.sh b/test/check_activate.sh new file mode 100755 index 0000000..dbc36b1 --- /dev/null +++ b/test/check_activate.sh @@ -0,0 +1,19 @@ +echo "initial: $PATH" + +source "test/here/bad (dir) 1/bin/activate" +echo "activate 1: $PATH" + +deactivate-lua +echo "deactivate 1: $PATH" + +source "test/here/bad (dir) 1/bin/activate" +echo "activate 1 again: $PATH" + +source "test/here/bad (dir) 1/bin/activate" +echo "reactivate 1: $PATH" + +source "test/here/bad (dir) 2/bin/activate" +echo "activate 2: $PATH" + +deactivate-lua +echo "deactivate 2: $PATH" diff --git a/test/cli_test.py b/test/cli_test.py index b670dee..250cd0a 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -43,10 +43,10 @@ class TestCLI(unittest.TestCase): raise AssertionError("Expected to see '{}' in output of command '{}', got output:\n{}".format( expected_output_line, " ".join(args), output)) - def assertHererocksSuccess(self, args, expected_output_lines=None): + def assertHererocksSuccess(self, args, expected_output_lines=None, location="here"): self.assertSuccess([ "coverage", "run", "-a", - "hererocks.py", os.path.join("test", "here")] + args, expected_output_lines, from_prefix=False) + "hererocks.py", os.path.join("test", location)] + args, expected_output_lines, from_prefix=False) def test_install_latest_lua_with_latest_luarocks(self): self.assertHererocksSuccess(["--lua", "latest", "--luarocks", "latest"]) @@ -122,3 +122,21 @@ class TestCLI(unittest.TestCase): self.assertSuccess(["lua", "-v"], ["Lua 5.1.3"]) self.assertHererocksSuccess(["--show"], [ "Lua 5.1", "cloned from https://github.com/lua/lua", "from local sources"]) + + def test_activate_scripts(self): + self.assertHererocksSuccess(["--lua", "5.1"], location=os.path.join("here", "bad (dir) 1")) + self.assertHererocksSuccess(["--lua", "5.2"], location=os.path.join("here", "bad (dir) 2")) + checker = os.path.join("test", "check_activate." + ("bat" if os.name == "nt" else "sh")) + + path = os.getenv("PATH") + path1 = os.path.abspath(os.path.join("test", "here", "bad (dir) 1", "bin")) + path2 = os.path.abspath(os.path.join("test", "here", "bad (dir) 2", "bin")) + self.assertSuccess([checker], [ + "initial: {}".format(path), + "activate 1: {}{}{}".format(path1, os.pathsep, path), + "deactivate 1: {}".format(path), + "activate 1 again: {}{}{}".format(path1, os.pathsep, path), + "reactivate 1: {}{}{}".format(path1, os.pathsep, path), + "activate 2: {}{}{}".format(path2, os.pathsep, path), + "deactivate 2: {}".format(path) + ], from_prefix=False)