コード例 #1
0
ファイル: subuser-test.py プロジェクト: ruipgpinheiro/subuser
if subuserlib.docker.getExecutable():
  if not "--skip-codetests" in sys.argv:
    from subuserlib.classes.docker.dockerDaemon import DockerDaemon
    import subuserlib.classes.docker.dockerDaemon
    from subuserlib.classes.fileStructure import BasicFileStructure
    dockerDaemon = DockerDaemon(MockUser())
    testDockerfileNames = [
     "Dockerfile-arch-python3",
     "Dockerfile-debian-python2",
    ]
    for testDockerfileName in testDockerfileNames:
      with io.open(os.path.join(subuserlib.paths.getSubuserDir(),"test",testDockerfileName),encoding="utf-8",mode="r") as dockerfile:
        dockerfileContents = dockerfile.read()
      try:
        subuserDir = BasicFileStructure(subuserlib.paths.getSubuserDir())
        id = dockerDaemon.build(repositoryFileStructure=subuserDir,relativeBuildContextPath="./",useCache=True,dockerfile=dockerfileContents)
        if dockerDaemon.execute(["run","-it","--volume",subuserlib.paths.getSubuserDir()+":/root/subuser:ro",id,"/root/subuser/logic/subuser","test"]) != 0:
          raise Exception()
      except Exception as e:
        print(subuserlib.terminalColors.FAIL+"Tests failed!"+subuserlib.terminalColors.ENDC)
        print(str(e))
        if not "--no-fail" in sys.argv:
          exit(1)
  if "--x11-bridge" in sys.argv:
    pid = os.fork()
    if pid:
      counter = "a"
    else:
      counter = "b"
    for i in range(1,6):
      print(counter+" "+str(i))
コード例 #2
0
ファイル: test.py プロジェクト: peter1000/subuser
  def getRegistry(self):
    return MockRegistry()

if subuserlib.docker.getDockerExecutable():
  from subuserlib.classes.docker.dockerDaemon import DockerDaemon
  import subuserlib.classes.docker.dockerDaemon
  dockerDaemon = DockerDaemon(MockUser())
  testDockerfileNames = [
   "Dockerfile-debian-python2",
   "Dockerfile-arch-python3",
  ]
  for testDockerfileName in testDockerfileNames:
    with io.open(os.path.join(subuserlib.basicPaths.getSubuserDir(),"test",testDockerfileName),encoding="utf-8",mode="r") as dockerfile:
      dockerfileContents = dockerfile.read()
    try:
      dockerDaemon.build(directoryWithDockerfile=subuserlib.basicPaths.getSubuserDir(),useCache=True,dockerfile=dockerfileContents)
    except subuserlib.classes.docker.dockerDaemon.ImageBuildException as e:
      print("Tests failed!")
      print(str(e))
      exit(1)
  exit()

import subuserlib.test

subuserlib.test.testing = True

import subuserlib.docker,sys,doctest,subprocess,os,subuserlib.paths

if not "--travis" in sys.argv:
  subuserDir = "/root/subuser"
else:
コード例 #3
0
ファイル: subuser-test.py プロジェクト: kenkeiras/subuser
     dockerDaemon = DockerDaemon(MockUser())
     testDockerfileNames = [
         "Dockerfile-arch-python3",
         "Dockerfile-debian-python2",
     ]
     for testDockerfileName in testDockerfileNames:
         with io.open(os.path.join(subuserlib.paths.getSubuserDir(), "test",
                                   testDockerfileName),
                      encoding="utf-8",
                      mode="r") as dockerfile:
             dockerfileContents = dockerfile.read()
         try:
             subuserDir = BasicFileStructure(
                 subuserlib.paths.getSubuserDir())
             id = dockerDaemon.build(repositoryFileStructure=subuserDir,
                                     relativeBuildContextPath="./",
                                     useCache=True,
                                     dockerfile=dockerfileContents)
             passedOnArgs = set(["--diff"])
             if dockerDaemon.execute([
                     "run", "-it", "--volume",
                     subuserlib.paths.getSubuserDir() + ":/root/subuser:ro",
                     id, "/root/subuser/logic/subuser", "test"
             ] + list(passedOnArgs.intersection(set(sys.argv)))) != 0:
                 raise Exception()
         except Exception as e:
             print(subuserlib.terminalColors.FAIL + "Tests failed!" +
                   subuserlib.terminalColors.ENDC)
             print(str(e))
             if not "--no-fail" in sys.argv:
                 exit(1)
 if "--x11-bridge" in sys.argv:
コード例 #4
0
    from subuserlib.classes.docker.dockerDaemon import DockerDaemon
    import subuserlib.classes.docker.dockerDaemon
    dockerDaemon = DockerDaemon(MockUser())
    testDockerfileNames = [
        "Dockerfile-debian-python2",
        "Dockerfile-arch-python3",
    ]
    for testDockerfileName in testDockerfileNames:
        with io.open(os.path.join(subuserlib.basicPaths.getSubuserDir(),
                                  "test", testDockerfileName),
                     encoding="utf-8",
                     mode="r") as dockerfile:
            dockerfileContents = dockerfile.read()
        try:
            dockerDaemon.build(
                directoryWithDockerfile=subuserlib.basicPaths.getSubuserDir(),
                useCache=True,
                dockerfile=dockerfileContents)
        except subuserlib.classes.docker.dockerDaemon.ImageBuildException as e:
            print("Tests failed!")
            print(str(e))
            exit(1)
    exit()

import subuserlib.test

subuserlib.test.testing = True

import subuserlib.docker, sys, doctest, subprocess, os, subuserlib.paths

if not "--travis" in sys.argv:
    subuserDir = "/root/subuser"