# Path: px/px_commandline.py
# LINUX_KERNEL_PROC = re.compile(u"^\\[[^/ ]+/?[^/ ]+\\]$")
# OSX_PARENTHESIZED_PROC = re.compile(u"^\\([^()]+\\)$")
# PERL_BIN = re.compile(u"^perl[.0-9]*$")
#     IGNORE_SWITCHES = [
#         "-b",
#         "-bb",
#         "-B",
#         "-d",
#         "-E",
#         "-i",
#         "-O",
#         "-OO",
#         "-R",
#         "-s",
#         "-S",
#         "-t",
#         "-tt",
#         "-u",
#         "-v",
#         "-Werror",
#         "-x",
#         "-3",
#     ]
# def to_array(commandline):
# def is_human_friendly(command):
# def get_app_name_prefix(commandline):
# def try_clarify_electron(commandline):
# def get_command(commandline):
# def get_python_command(commandline):
# def get_sudo_command(commandline):
# def prettify_fully_qualified_java_class(class_name):
# def get_java_command(commandline):
# def get_generic_script_command(commandline, ignore_switches=[]):


import os
from px import px_commandline
    assert px_commandline.get_command("java -dahej SomeClass") == "SomeClass"

    # Tests for invalid command lines
    assert px_commandline.get_command("java -cp /a/b/c") == "java"
    assert px_commandline.get_command("java  ") == "java"
    assert px_commandline.get_command("java -jar") == "java"
    assert px_commandline.get_command("java -jar    ") == "java"

    # FIXME: Add test for classpath containing spaces? I say this should be
    # postponed until we have a real world use case for that.
    pass


def test_get_command_java_gradled():
    commandline = (
        "/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java "
        + "-XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m "
        + "-Dfile.encoding=UTF-8 -Duser.country=SE -Duser.language=sv -Duser.variant -cp "
        + "/Users/johan/.gradle/wrapper/dists/gradle-2.8-all/gradle-2.8/lib/gradle-launcher-2.8.jar"
        + " org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.8"
    )
    assert px_commandline.get_command(commandline) == "GradleDaemon"


def test_get_command_java_teamcity():
    commandline = (
        "/usr/lib/jvm/jdk-8-oracle-x64/jre/bin/java "
        + "-Djava.util.logging.config.file=/teamcity/conf/logging.properties "
        + "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager "
        + "-Dsun.net.inetaddr.ttl=60 -server -Xms31g -Xmx31g "

# Path: px/px_commandline.py
# LINUX_KERNEL_PROC = re.compile(u"^\\[[^/ ]+/?[^/ ]+\\]$")
# OSX_PARENTHESIZED_PROC = re.compile(u"^\\([^()]+\\)$")
# PERL_BIN = re.compile(u"^perl[.0-9]*$")
#     IGNORE_SWITCHES = [
#         "-b",
#         "-bb",
#         "-B",
#         "-d",
#         "-E",
#         "-i",
#         "-O",
#         "-OO",
#         "-R",
#         "-s",
#         "-S",
#         "-t",
#         "-tt",
#         "-u",
#         "-v",
#         "-Werror",
#         "-x",
#         "-3",
#     ]
# def to_array(commandline):
# def is_human_friendly(command):
# def get_app_name_prefix(commandline):
# def try_clarify_electron(commandline):
# def get_command(commandline):
# def get_python_command(commandline):
# def get_sudo_command(commandline):
# def prettify_fully_qualified_java_class(class_name):
# def get_java_command(commandline):
# def get_generic_script_command(commandline, ignore_switches=[]):


# Path: tests/px_commandline_test.py
import os
from px import px_commandline

    assert px_commandline.get_command("java -dahej SomeClass") == "SomeClass"

    # Tests for invalid command lines
    assert px_commandline.get_command("java -cp /a/b/c") == "java"
    assert px_commandline.get_command("java  ") == "java"
    assert px_commandline.get_command("java -jar") == "java"
    assert px_commandline.get_command("java -jar    ") == "java"

    # FIXME: Add test for classpath containing spaces? I say this should be
    # postponed until we have a real world use case for that.
    pass


def test_get_command_java_gradled():
    commandline = (
        "/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java "
        + "-XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m "
        + "-Dfile.encoding=UTF-8 -Duser.country=SE -Duser.language=sv -Duser.variant -cp "
        + "/Users/johan/.gradle/wrapper/dists/gradle-2.8-all/gradle-2.8/lib/gradle-launcher-2.8.jar"
        + " org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.8"
    )
    assert px_commandline.get_command(commandline) == "GradleDaemon"


def test_get_command_java_teamcity():
    commandline = (
        "/usr/lib/jvm/jdk-8-oracle-x64/jre/bin/java "
        + "-Djava.util.logging.config.file=/teamcity/conf/logging.properties "
        + "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager "
        + "-Dsun.net.inetaddr.ttl=60 -server -Xms31g -Xmx31g "

        + "-Dteamcity.configuration.path=../conf/teamcity-startup.properties "