Skip to content

Commit

Permalink
Merge pull request #80 from jayvdb/test-windows-paths
Browse files Browse the repository at this point in the history
Test Windows paths in program args
  • Loading branch information
ctrueden authored Jul 22, 2024
2 parents 89d20d1 + 3c2604e commit 35e301f
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,66 @@ def test_classifier(self, run_mock):
self.assertIsNone(stdout)
self.assertIsNone(stderr)

@patch("jgo.jgo._run")
def test_program_arg_path_windows_drive(self, run_mock):
parser = jgo_parser()
argv = [
"-r",
"clojars=https://clojars.org/repo/",
"mvxcvi:cljstyle",
"fix",
"c:/path/to/file.clj",
]

run(parser, argv)
self.assertTrue(run_mock.called)
workspace = run_mock.call_args.args[0]
primary_endpoint: Endpoint = run_mock.call_args.args[1]
jvm_args = run_mock.call_args.args[2]
program_args = run_mock.call_args.args[3]
additional_jars = run_mock.call_args.args[4]
stdout = run_mock.call_args.args[5]
stderr = run_mock.call_args.args[6]
self.assertIsInstance(workspace, str)
self.assertIsInstance(primary_endpoint, Endpoint)
self.assertEqual(primary_endpoint.groupId, "mvxcvi")
self.assertEqual(primary_endpoint.artifactId, "cljstyle")
self.assertEqual(jvm_args, [])
self.assertEqual(program_args, ["fix", "c:/path/to/file.clj"])
self.assertEqual(additional_jars, [])
self.assertIsNone(stdout)
self.assertIsNone(stderr)

@patch("jgo.jgo._run")
def test_program_arg_path_windows_sep(self, run_mock):
parser = jgo_parser()
argv = [
"-r",
"clojars=https://clojars.org/repo/",
"mvxcvi:cljstyle",
"fix",
"c:\\path\\to\\file.clj",
]

run(parser, argv)
self.assertTrue(run_mock.called)
workspace = run_mock.call_args.args[0]
primary_endpoint: Endpoint = run_mock.call_args.args[1]
jvm_args = run_mock.call_args.args[2]
program_args = run_mock.call_args.args[3]
additional_jars = run_mock.call_args.args[4]
stdout = run_mock.call_args.args[5]
stderr = run_mock.call_args.args[6]
self.assertIsInstance(workspace, str)
self.assertIsInstance(primary_endpoint, Endpoint)
self.assertEqual(primary_endpoint.groupId, "mvxcvi")
self.assertEqual(primary_endpoint.artifactId, "cljstyle")
self.assertEqual(jvm_args, [])
self.assertEqual(program_args, ["fix", "c:\\path\\to\\file.clj"])
self.assertEqual(additional_jars, [])
self.assertIsNone(stdout)
self.assertIsNone(stderr)

@patch("jgo.jgo.launch_java")
def test_explicit_main_class(self, launch_java_mock):
parser = jgo_parser()
Expand Down

0 comments on commit 35e301f

Please sign in to comment.