// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.packaging;

import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.jetbrains.python.fixtures.PyTestCase;
import com.jetbrains.python.packaging.requirement.PyRequirementRelation;
import com.jetbrains.python.packaging.requirement.PyRequirementVersionSpec;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static com.jetbrains.python.packaging.PyRequirementParser.fromLine;
import static com.jetbrains.python.packaging.PyRequirementsKt.pyRequirement;
import static com.jetbrains.python.packaging.PyRequirementsKt.pyRequirementVersionSpec;
import static com.jetbrains.python.packaging.requirement.PyRequirementRelation.*;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;

public class PyRequirementTest extends PyTestCase {

  // ARCHIVE URL
  public void testArchiveUrl() {
    doTest("geoip2", "2.2.0", "https://pypi.python.org/packages/source/g/geoip2/geoip2-2.2.0.tar.gz");
  }

  // PY-14230
  public void testArchiveUrlWithMd5() {
    doTest("geoip2", "2.2.0", "https://pypi.python.org/packages/source/g/geoip2/geoip2-2.2.0.tar.gz#md5=26259d212447bc840400c25a48275fbc");
  }

  // PY-14230
  public void testArchiveUrlWithSha1() {
    doTest("geoip2", "2.2.0", "https://pypi.python.org/packages/source/g/geoip2/geoip2-2.2.0.tar.gz#sha1=26259d212447bc840400c25a48275fbc");
  }

  // PY-14230
  public void testArchiveUrlWithSha224() {
    doTest("geoip2", "2.2.0",
           "https://pypi.python.org/packages/source/g/geoip2/geoip2-2.2.0.tar.gz#sha224=26259d212447bc840400c25a48275fbc");
  }

  // PY-14230
  public void testArchiveUrlWithSha256() {
    doTest("geoip2", "2.2.0",
           "https://pypi.python.org/packages/source/g/geoip2/geoip2-2.2.0.tar.gz#sha256=26259d212447bc840400c25a48275fbc");
  }

  // PY-14230
  public void testArchiveUrlWithSha384() {
    doTest("geoip2", "2.2.0",
           "https://pypi.python.org/packages/source/g/geoip2/geoip2-2.2.0.tar.gz#sha384=26259d212447bc840400c25a48275fbc");
  }

  // PY-14230
  public void testArchiveUrlWithSha512() {
    doTest("geoip2", "2.2.0",
           "https://pypi.python.org/packages/source/g/geoip2/geoip2-2.2.0.tar.gz#sha512=26259d212447bc840400c25a48275fbc");
  }

  // PY-18054
  public void testGithubArchiveUrl() {
    doTest("https://github.com/divio/MyProject1/archive/master.zip?1450634746.0107164");
  }

  // PY-26364
  public void testGitlabArchiveUrl() {
    doTest("https://gitlab.com/mrh1997/MyProject1/repository/master/archive.zip");
  }

  // VCS
  // PY-6328
  public void testGit() {
    doTest("git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("git+git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("git+git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("git+git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("git+git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("git+git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("git+git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("git+git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("git+git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("git+https://git.myproject.org/MyProject#egg=MyProject1");
    doTest("git+https://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("git+https://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("git+https://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("git+https://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("git+https://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("git+https://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("git+https://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("git+ssh://git.myproject.org/MyProject#egg=MyProject1");
    doTest("git+ssh://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("git+ssh://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("git+ssh://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("git+ssh://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("git+ssh://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("git+ssh://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("git+ssh://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("git+ssh://user@git.myproject.org/MyProject#egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/MyProject/#egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("git+user@git.myproject.org:MyProject#egg=MyProject1");
    doTest("git+user@git.myproject.org:MyProject/#egg=MyProject1");
    doTest("git+user@git.myproject.org:MyProject.git#egg=MyProject1");
    doTest("git+user@git.myproject.org:MyProject.git/#egg=MyProject1");
    doTest("git+user@git.myproject.org:/path/MyProject#egg=MyProject1");
    doTest("git+user@git.myproject.org:/path/MyProject/#egg=MyProject1");
    doTest("git+user@git.myproject.org:/path/MyProject.git#egg=MyProject1");
    doTest("git+user@git.myproject.org:/path/MyProject.git/#egg=MyProject1");
  }

  // PY-19544
  public void testGitWithSubdirectory() {
    doTest("git://git.myproject.org/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git://git.myproject.org/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git://git.myproject.org/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git://git.myproject.org/MyProject.git/#egg=MyProject1&subdirectory=clients/python");
    doTest("git://git.myproject.org/path/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git://git.myproject.org/path/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git://git.myproject.org/path/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git://git.myproject.org/path/MyProject.git/#egg=MyProject1&subdirectory=clients/python");

    doTest("git+git://git.myproject.org/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+git://git.myproject.org/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+git://git.myproject.org/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+git://git.myproject.org/MyProject.git/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+git://git.myproject.org/path/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+git://git.myproject.org/path/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+git://git.myproject.org/path/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+git://git.myproject.org/path/MyProject.git/#egg=MyProject1&subdirectory=clients/python");

    doTest("git+https://git.myproject.org/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+https://git.myproject.org/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+https://git.myproject.org/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+https://git.myproject.org/MyProject.git/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+https://git.myproject.org/path/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+https://git.myproject.org/path/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+https://git.myproject.org/path/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+https://git.myproject.org/path/MyProject.git/#egg=MyProject1&subdirectory=clients/python");

    doTest("git+ssh://git.myproject.org/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://git.myproject.org/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://git.myproject.org/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://git.myproject.org/MyProject.git/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://git.myproject.org/path/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://git.myproject.org/path/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://git.myproject.org/path/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://git.myproject.org/path/MyProject.git/#egg=MyProject1&subdirectory=clients/python");

    doTest("git+ssh://user@git.myproject.org/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://user@git.myproject.org/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://user@git.myproject.org/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://user@git.myproject.org/MyProject.git/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://user@git.myproject.org/path/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://user@git.myproject.org/path/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://user@git.myproject.org/path/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+ssh://user@git.myproject.org/path/MyProject.git/#egg=MyProject1&subdirectory=clients/python");

    doTest("git+user@git.myproject.org:MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+user@git.myproject.org:MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+user@git.myproject.org:MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+user@git.myproject.org:MyProject.git/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+user@git.myproject.org:/path/MyProject#egg=MyProject1&subdirectory=clients/python");
    doTest("git+user@git.myproject.org:/path/MyProject/#egg=MyProject1&subdirectory=clients/python");
    doTest("git+user@git.myproject.org:/path/MyProject.git#egg=MyProject1&subdirectory=clients/python");
    doTest("git+user@git.myproject.org:/path/MyProject.git/#egg=MyProject1&subdirectory=clients/python");

    doTest("git://git.myproject.org/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git://git.myproject.org/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git://git.myproject.org/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git://git.myproject.org/MyProject.git/#subdirectory=clients/python&egg=MyProject1");
    doTest("git://git.myproject.org/path/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git://git.myproject.org/path/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git://git.myproject.org/path/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git://git.myproject.org/path/MyProject.git/#subdirectory=clients/python&egg=MyProject1");

    doTest("git+git://git.myproject.org/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+git://git.myproject.org/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+git://git.myproject.org/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+git://git.myproject.org/MyProject.git/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+git://git.myproject.org/path/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+git://git.myproject.org/path/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+git://git.myproject.org/path/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+git://git.myproject.org/path/MyProject.git/#subdirectory=clients/python&egg=MyProject1");

    doTest("git+https://git.myproject.org/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+https://git.myproject.org/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+https://git.myproject.org/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+https://git.myproject.org/MyProject.git/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+https://git.myproject.org/path/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+https://git.myproject.org/path/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+https://git.myproject.org/path/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+https://git.myproject.org/path/MyProject.git/#subdirectory=clients/python&egg=MyProject1");

    doTest("git+ssh://git.myproject.org/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://git.myproject.org/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://git.myproject.org/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://git.myproject.org/MyProject.git/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://git.myproject.org/path/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://git.myproject.org/path/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://git.myproject.org/path/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://git.myproject.org/path/MyProject.git/#subdirectory=clients/python&egg=MyProject1");

    doTest("git+ssh://user@git.myproject.org/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/MyProject.git/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/path/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/path/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/path/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+ssh://user@git.myproject.org/path/MyProject.git/#subdirectory=clients/python&egg=MyProject1");

    doTest("git+user@git.myproject.org:MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+user@git.myproject.org:MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+user@git.myproject.org:MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+user@git.myproject.org:MyProject.git/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+user@git.myproject.org:/path/MyProject#subdirectory=clients/python&egg=MyProject1");
    doTest("git+user@git.myproject.org:/path/MyProject/#subdirectory=clients/python&egg=MyProject1");
    doTest("git+user@git.myproject.org:/path/MyProject.git#subdirectory=clients/python&egg=MyProject1");
    doTest("git+user@git.myproject.org:/path/MyProject.git/#subdirectory=clients/python&egg=MyProject1");
  }

  public void testEditableGit() {
    doTest("-e git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("-e git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("-e git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("-e git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("-e git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("-e git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("-e git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("-e git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("-e git+git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("-e git+git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("-e git+git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("-e git+git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("-e git+git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("-e git+git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("-e git+git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("-e git+git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("-e git+https://git.myproject.org/MyProject#egg=MyProject1");
    doTest("-e git+https://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("-e git+https://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("-e git+https://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("-e git+https://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("-e git+https://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("-e git+https://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("-e git+https://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("-e git+ssh://git.myproject.org/MyProject#egg=MyProject1");
    doTest("-e git+ssh://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("-e git+ssh://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("-e git+ssh://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("-e git+ssh://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("-e git+ssh://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("-e git+ssh://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("-e git+ssh://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("-e git+ssh://user@git.myproject.org/MyProject#egg=MyProject1");
    doTest("-e git+ssh://user@git.myproject.org/MyProject/#egg=MyProject1");
    doTest("-e git+ssh://user@git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("-e git+ssh://user@git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("-e git+ssh://user@git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("-e git+ssh://user@git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("-e git+ssh://user@git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("-e git+ssh://user@git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("-e git+user@git.myproject.org:MyProject#egg=MyProject1");
    doTest("-e git+user@git.myproject.org:MyProject/#egg=MyProject1");
    doTest("-e git+user@git.myproject.org:MyProject.git#egg=MyProject1");
    doTest("-e git+user@git.myproject.org:MyProject.git/#egg=MyProject1");
    doTest("-e git+user@git.myproject.org:/path/MyProject#egg=MyProject1");
    doTest("-e git+user@git.myproject.org:/path/MyProject/#egg=MyProject1");
    doTest("-e git+user@git.myproject.org:/path/MyProject.git#egg=MyProject1");
    doTest("-e git+user@git.myproject.org:/path/MyProject.git/#egg=MyProject1");

    doTest("--editable git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--editable git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--editable git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--editable git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--editable git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--editable git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--editable git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--editable git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--editable git+git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--editable git+git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--editable git+git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--editable git+git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--editable git+git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--editable git+git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--editable git+git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--editable git+git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--editable git+https://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--editable git+https://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--editable git+https://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--editable git+https://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--editable git+https://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--editable git+https://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--editable git+https://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--editable git+https://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--editable git+ssh://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--editable git+ssh://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--editable git+ssh://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--editable git+ssh://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--editable git+ssh://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--editable git+ssh://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--editable git+ssh://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--editable git+ssh://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--editable git+ssh://user@git.myproject.org/MyProject#egg=MyProject1");
    doTest("--editable git+ssh://user@git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--editable git+ssh://user@git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--editable git+ssh://user@git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--editable git+ssh://user@git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--editable git+ssh://user@git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--editable git+ssh://user@git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--editable git+ssh://user@git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--editable git+user@git.myproject.org:MyProject#egg=MyProject1");
    doTest("--editable git+user@git.myproject.org:MyProject/#egg=MyProject1");
    doTest("--editable git+user@git.myproject.org:MyProject.git#egg=MyProject1");
    doTest("--editable git+user@git.myproject.org:MyProject.git/#egg=MyProject1");
    doTest("--editable git+user@git.myproject.org:/path/MyProject#egg=MyProject1");
    doTest("--editable git+user@git.myproject.org:/path/MyProject/#egg=MyProject1");
    doTest("--editable git+user@git.myproject.org:/path/MyProject.git#egg=MyProject1");
    doTest("--editable git+user@git.myproject.org:/path/MyProject.git/#egg=MyProject1");
  }

  public void testEditableWithSrcGit() {
    doTest("--src ./mysrc/src -e git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src -e git+git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src -e git+https://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+https://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+https://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+https://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+https://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+https://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+https://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+https://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src -e git+ssh://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src -e git+ssh://user@git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://user@git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://user@git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://user@git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://user@git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://user@git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://user@git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+ssh://user@git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src -e git+user@git.myproject.org:MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+user@git.myproject.org:MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+user@git.myproject.org:MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+user@git.myproject.org:MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+user@git.myproject.org:/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+user@git.myproject.org:/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+user@git.myproject.org:/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src -e git+user@git.myproject.org:/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src --editable git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src --editable git+git://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+git://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+git://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+git://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+git://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+git://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+git://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+git://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src --editable git+https://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+https://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+https://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+https://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+https://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+https://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+https://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+https://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src --editable git+ssh://git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://git.myproject.org/path/MyProject.git/#egg=MyProject1");

    doTest("--src ./mysrc/src --editable git+ssh://user@git.myproject.org/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://user@git.myproject.org/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://user@git.myproject.org/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://user@git.myproject.org/MyProject.git/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://user@git.myproject.org/path/MyProject#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://user@git.myproject.org/path/MyProject/#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://user@git.myproject.org/path/MyProject.git#egg=MyProject1");
    doTest("--src ./mysrc/src --editable git+ssh://user@git.myproject.org/path/MyProject.git/#egg=MyProject1");

