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))
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:
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:
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"