# Path: xmanager/xm/executables.py
# def name_from_path(path: str) -> str:
#   def __attrs_post_init__(self):
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
# class ModuleName(NamedTuple):
# class CommandList(NamedTuple):
# class Dockerfile(job_blocks.ExecutableSpec):
# class PythonContainer(job_blocks.ExecutableSpec):
# class BinaryDependency(abc.ABC):
# class Container(job_blocks.ExecutableSpec):
# class Binary(job_blocks.ExecutableSpec):
# class BazelContainer(job_blocks.ExecutableSpec):
# class BazelBinary(job_blocks.ExecutableSpec):
# 
# Path: xmanager/xm/utils.py
# FLAGS = flags.FLAGS
# ARG_ESCAPER = pattern_matching.match(
#     pattern_matching.Case([ShellSafeArg], lambda v: v.arg),
#     pattern_matching.Case([enum.Enum], lambda v: shlex.quote(str(v.name))),
#     pattern_matching.Case([Any], lambda v: shlex.quote(str(v))),
# )
# class SpecialArg(abc.ABC):
# class ShellSafeArg(SpecialArg):
# def trivial_kwargs_joiner(key: str, value: str) -> str:
# def run_in_asyncio_loop(
#     f: Callable[..., ReturnType]) -> Callable[..., ReturnType]:
#   def decorated(*args, **kwargs) -> ReturnType:
# def find_launch_script_path() -> str:
# def resolve_path_relative_to_launcher(path: str) -> str:


import os
import unittest
from xmanager.xm import executables
from xmanager.xm import utils
  def test_python_container_name(self):
    executable = executables.PythonContainer(
        entrypoint=executables.ModuleName('module'),
        path='/home/user/project/',
    )

    self.assertEqual(executable.name, 'project')

  def test_container_name(self):
    executable = executables.Container(
        image_path='/home/user/project/image.tar')

    self.assertEqual(executable.name, 'image_tar')

  def test_binary_name(self):
    executable = executables.Binary(path='./binary')

    self.assertEqual(executable.name, 'binary')

  def test_bazel_container_name(self):
    executable = executables.BazelContainer(label='//container')

    self.assertEqual(executable.name, 'container')

  def test_bazel_binary_name(self):
    executable = executables.BazelBinary(label=':binary')

    self.assertEqual(executable.name, '_binary')

  def test_dockerfile_defaults(self):

# Path: xmanager/xm/executables.py
# def name_from_path(path: str) -> str:
#   def __attrs_post_init__(self):
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
#   def name(self) -> str:
# class ModuleName(NamedTuple):
# class CommandList(NamedTuple):
# class Dockerfile(job_blocks.ExecutableSpec):
# class PythonContainer(job_blocks.ExecutableSpec):
# class BinaryDependency(abc.ABC):
# class Container(job_blocks.ExecutableSpec):
# class Binary(job_blocks.ExecutableSpec):
# class BazelContainer(job_blocks.ExecutableSpec):
# class BazelBinary(job_blocks.ExecutableSpec):
# 
# Path: xmanager/xm/utils.py
# FLAGS = flags.FLAGS
# ARG_ESCAPER = pattern_matching.match(
#     pattern_matching.Case([ShellSafeArg], lambda v: v.arg),
#     pattern_matching.Case([enum.Enum], lambda v: shlex.quote(str(v.name))),
#     pattern_matching.Case([Any], lambda v: shlex.quote(str(v))),
# )
# class SpecialArg(abc.ABC):
# class ShellSafeArg(SpecialArg):
# def trivial_kwargs_joiner(key: str, value: str) -> str:
# def run_in_asyncio_loop(
#     f: Callable[..., ReturnType]) -> Callable[..., ReturnType]:
#   def decorated(*args, **kwargs) -> ReturnType:
# def find_launch_script_path() -> str:
# def resolve_path_relative_to_launcher(path: str) -> str:


# Path: xmanager/xm/executables_test.py
import os
import unittest
from xmanager.xm import executables
from xmanager.xm import utils

  def test_python_container_name(self):
    executable = executables.PythonContainer(
        entrypoint=executables.ModuleName('module'),
        path='/home/user/project/',
    )

    self.assertEqual(executable.name, 'project')

  def test_container_name(self):
    executable = executables.Container(
        image_path='/home/user/project/image.tar')

    self.assertEqual(executable.name, 'image_tar')

  def test_binary_name(self):
    executable = executables.Binary(path='./binary')

    self.assertEqual(executable.name, 'binary')

  def test_bazel_container_name(self):
    executable = executables.BazelContainer(label='//container')

    self.assertEqual(executable.name, 'container')

  def test_bazel_binary_name(self):
    executable = executables.BazelBinary(label=':binary')

    self.assertEqual(executable.name, '_binary')

  def test_dockerfile_defaults(self):

    root = utils.resolve_path_relative_to_launcher('.')