diff --git a/.circleci/config.yml b/.circleci/config.yml index 39c6e29..0ceed38 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,234 +1,40 @@ version: 2 jobs: - build: - docker: - - image: busybox - working_directory: /home/circleci/image-builder - steps: - - run: echo doing nothing. - - ########################### - #### ubuntu-14.04-XXL ##### - ########################### - ubuntu-14.04-XXL: - machine: - docker_layer_caching: true - working_directory: /home/circleci/image-builder - environment: - IMAGE_REPO: circleci/build-image - TARGET: ubuntu-14.04-XXL - _TARGET: ubuntu-14_04-XXL - steps: - - checkout - - run: echo -n "$TARGET-$CIRCLE_BUILD_NUM-$(git rev-parse --short HEAD)" > _tag - - run: echo "Building $IMAGE_REPO:$(cat _tag)" - - run: - command: | - docker build \ - $NO_CACHE \ - --build-arg IMAGE_TAG=$(cat _tag) \ - -t $IMAGE_REPO:$(cat _tag) \ - -f targets/$TARGET/Dockerfile \ - . - - - run: docker rm --force $TARGET-test || true - - - run: - command: | - docker run -d -v /home/circleci/image-builder/tests:/home/ubuntu/tests \ - -p 12345:22 --name $TARGET-test \ - $IMAGE_REPO:$(cat _tag) - - sleep 20 - - - run: docker cp tests/insecure-ssh-key.pub $TARGET-test:/home/ubuntu/.ssh/authorized_keys - - - run: docker exec -it $TARGET-test bash -c "chown ubuntu:ubuntu /home/ubuntu/.ssh/authorized_keys" - - - run: chmod 600 tests/insecure-ssh-key; - - - run: ssh -i tests/insecure-ssh-key -p 12345 ubuntu@localhost bats /home/ubuntu/tests/unit/$TARGET - - - run: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - - - run: | - for i in 1 2 3; do - docker push $IMAGE_REPO:$(cat _tag) - if [ $? -eq 0 ]; then - exit 0 - fi - echo "Retrying...." - done - exit 1 - - - run: docker run $IMAGE_REPO:$(cat _tag) sudo -H -i -u ubuntu /opt/circleci/bin/pkg-versions.sh | jq . > versions-$_TARGET.json - - - run: curl -o versions.json.before https://circleci.com/docs/environments/$TARGET.json - - - run: diff -uw versions.json.before versions-$_TARGET.json > versions-$_TARGET.diff || true - - - store_artifacts: - path: versions-ubuntu-14_04-XXL.diff - destination: versions-ubuntu-14.04-XXL.diff - - - store_artifacts: - path: versions-ubuntu-14_04-XXL.json - destination: versions-ubuntu-14.04-XXL.json - - - deploy: - command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; then - # Streaming to awscli because disk space is not enough in the machine VM - ./docker-export $IMAGE_REPO:$(cat _tag) | aws s3 cp - s3://circle-downloads/build-image-$(cat _tag).tar.gz --acl public-read - aws s3 cp s3://circle-downloads/build-image-$(cat _tag).tar.gz s3://lxc-images/build-image-$(cat _tag).tar.gz --acl public-read - aws s3 cp s3://circle-downloads/build-image-$(cat _tag).tar.gz s3://lxc-images-us-east-2/build-image-$(cat _tag).tar.gz --acl public-read --region us-east-2 - aws s3 cp s3://circle-downloads/build-image-$(cat _tag).tar.gz s3://lxc-images-us-west-2/build-image-$(cat _tag).tar.gz --acl public-read --region us-west-2 - fi - - ########################### - #### ubuntu-14.04-XXL-upstart ##### - ########################### - ubuntu-14.04-XXL-upstart: - machine: - docker_layer_caching: true - working_directory: /home/circleci/image-builder - environment: - IMAGE_REPO: circleci/build-image - TARGET: ubuntu-14.04-XXL-upstart - _TARGET: ubuntu-14_04-XXL-upstart - steps: - - checkout - - run: echo -n "$TARGET-$CIRCLE_BUILD_NUM-$(git rev-parse --short HEAD)" > _tag - - run: echo "Building $IMAGE_REPO:$(cat _tag)" - - run: - command: | - docker build \ - $NO_CACHE \ - --build-arg IMAGE_TAG=$(cat _tag) \ - -t $IMAGE_REPO:$(cat _tag) \ - -f targets/$TARGET/Dockerfile \ - . - - - run: docker rm --force $TARGET-test || true - - - run: - command: | - docker run -d -v /home/circleci/image-builder/tests:/home/ubuntu/tests \ - -p 12345:22 --name $TARGET-test \ - $IMAGE_REPO:$(cat _tag) - - sleep 10 - - - run: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - - - run: | - for i in 1 2 3; do - docker push $IMAGE_REPO:$(cat _tag) - if [ $? -eq 0 ]; then - exit 0 - fi - echo "Retrying...." - done - exit 1 - - ################################## - #### ubuntu-14.04-enterprise ##### - ################################## - ubuntu-14.04-enterprise: + this_wont_work: machine: - docker_layer_caching: true - working_directory: /home/circleci/image-builder + image: ubuntu-1604:201903-01 environment: - IMAGE_REPO: circleci/build-image - TARGET: ubuntu-14.04-enterprise + # some random deps + DEPS: "git bc python-pip python-setuptools wget sudo ssh curl binutils jq" steps: - - checkout - - run: echo -n "$TARGET-$CIRCLE_BUILD_NUM-$(git rev-parse --short HEAD)" > _tag - - run: echo "Building $IMAGE_REPO:$(cat _tag)" - run: + name: Initialize Builder command: | - docker build \ - $NO_CACHE \ - --build-arg IMAGE_TAG=$(cat _tag) \ - -t $IMAGE_REPO:$(cat _tag) \ - -f targets/$TARGET/Dockerfile \ - . - - - run: docker rm --force $TARGET-test || true - - - run: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - - - run: | - for i in 1 2 3; do - docker push $IMAGE_REPO:$(cat _tag) - if [ $? -eq 0 ]; then - exit 0 - fi - echo "Retrying...." - done - exit 1 - - - run: docker run $IMAGE_REPO:$(cat _tag) sudo -H -i -u ubuntu /opt/circleci/bin/pkg-versions.sh | jq . > versions-$TARGET.json - - - run: curl -o versions.json.before https://circleci.com/docs/environments/$TARGET.json - - - run: diff -uw versions.json.before versions-$TARGET.json > versions-$TARGET.diff || true - - - store_artifacts: - path: versions-ubuntu-14.04-enterprise.diff - destination: versions-ubuntu-14.04-enterprise.diff - - - store_artifacts: - path: versions-ubuntu-14.04-enterprise.json - destination: versions-ubuntu-14.04-enterprise.json - - ###################################### - #### ubuntu-14.04-XXL-enterprise ##### - ###################################### - ubuntu-14.04-XXL-enterprise: - machine: - docker_layer_caching: true - working_directory: /home/circleci/image-builder - environment: - IMAGE_REPO: circleci/build-image - TARGET: ubuntu-14.04-XXL-enterprise - steps: + sudo apt-get update + sudo apt-get install -y --no-install-recommends ${DEPS} + # Install Docker 19.03 or higher to use buildx for cross platform builds. + sudo apt-get remove docker docker-engine docker.io containerd runc + sudo apt-get install --no-install-recommends apt-transport-https ca-certificates curl gnupg-agent software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + sudo apt-get update + sudo apt-get install --no-install-recommends docker-ce docker-ce-cli containerd.io + sudo apt-cache madison docker-ce + # Enable experimental mode for Docker CLI and Docker engine to enable buildx + # support. This is needed for PPC cross build natively within docker. + sudo mkdir -p /home/circleci/.docker + echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json + echo '{"experimental": "enabled"}' | sudo tee /home/circleci/.docker/config.json + sudo service docker restart + docker version - checkout - - run: echo -n "$TARGET-$CIRCLE_BUILD_NUM-$(git rev-parse --short HEAD)" > _tag - - run: echo "Building $IMAGE_REPO:$(cat _tag)" - run: + name: Build command: | - docker build \ - $NO_CACHE \ - --build-arg IMAGE_TAG=$(cat _tag) \ - -t $IMAGE_REPO:$(cat _tag) \ - -f targets/$TARGET/Dockerfile \ - . - - - run: docker rm --force $TARGET-test || true - - - run: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - - - run: | - for i in 1 2 3; do - docker push $IMAGE_REPO:$(cat _tag) - if [ $? -eq 0 ]; then - exit 0 - fi - echo "Retrying...." - done - exit 1 - - - run: docker run $IMAGE_REPO:$(cat _tag) sudo -H -i -u ubuntu /opt/circleci/bin/pkg-versions.sh | jq . > versions-$TARGET.json - - - run: curl -o versions.json.before https://circleci.com/docs/environments/$TARGET.json - - - run: diff -uw versions.json.before versions-$TARGET.json > versions-$TARGET.diff || true - - - store_artifacts: - path: versions-ubuntu-14.04-XXL-enterprise.diff - destination: versions-ubuntu-14.04-XXL-enterprise.diff - - - store_artifacts: - path: versions-ubuntu-14.04-XXL-enterprise.json - destination: versions-ubuntu-14.04-XXL-enterprise.json + echo "this should not work" + sudo docker buildx build --platform linux/ppc64le -t my-image --no-cache . +workflows: + version: 2 + build: + jobs: + - this_wont_work \ No newline at end of file diff --git a/.circleci/trigger-build.sh b/.circleci/trigger-build.sh deleted file mode 100644 index 85dac3f..0000000 --- a/.circleci/trigger-build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -e - -trigger-job() { - local job - curl -X POST --header "Content-Type: application/json" -d '{}' "http://dev.circlehost:8080/api/v1.1/project/github/$repo/tree/$branch?circle-token=$CIRCLE_TOKEN" -} diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 7315423..0000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -docker/image.tar diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 9248207..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -provision.sh -.vagrant -bats.log diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29..0000000 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..31fc96d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM ppc64le/centos:7 + +RUN echo "help me obi-wan, I can't compile and I desparately want to" \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index fabc77c..0000000 --- a/Makefile +++ /dev/null @@ -1,178 +0,0 @@ -SHELL := /bin/bash -IMAGE_REPO = circleci/build-image -SHA = $(shell git rev-parse --short HEAD) -VERSION = $(CIRCLE_BUILD_NUM)-$(SHA) -NO_CACHE = - -define docker-push-with-retry - for i in 1 2 3; do docker push $(1); if [ $$? -eq 0 ]; then exit 0; fi; echo "Retrying...."; done; exit 1; -endef - -ifeq ($(no_cache), true) - NO_CACHE = --no-cache -endif - -### ubuntu-14.04-XXL -# This build image is used on circleci.com Ubuntu 14.04 fleet. -# This is the fattest image that we manage: many versions of various programming languages -# and services such as MySQL or Redis are installed. -### -build-ubuntu-14.04-XXL: -ifndef NO_CACHE - docker-cache-shim pull ${IMAGE_REPO} || true -endif - echo "Building Docker image ubuntu-14.04-XXL-$(VERSION)" - docker build $(NO_CACHE) --build-arg IMAGE_TAG=ubuntu-14.04-XXL-$(VERSION) \ - -t $(IMAGE_REPO):ubuntu-14.04-XXL-$(VERSION) \ - -f targets/ubuntu-14.04-XXL/Dockerfile \ - . - -push-ubuntu-14.04-XXL: - docker-cache-shim push ${IMAGE_REPO}:ubuntu-14.04-XXL-$(VERSION) - $(call docker-push-with-retry,$(IMAGE_REPO):ubuntu-14.04-XXL-$(VERSION)) - -dump-version-ubuntu-14.04-XXL: - docker run $(IMAGE_REPO):ubuntu-14.04-XXL-$(VERSION) sudo -H -i -u ubuntu /opt/circleci/bin/pkg-versions.sh | jq . > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XXL.json; true - curl -o versions.json.before https://circleci.com/docs/environments/trusty.json - diff -uw versions.json.before $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XXL.json > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XXL.diff; true - -test-ubuntu-14.04-XXL: - docker run -d -v ~/image-builder/tests:/home/ubuntu/tests -p 12345:22 --name ubuntu-14.04-XXL-test $(IMAGE_REPO):ubuntu-14.04-XXL-$(VERSION) - sleep 10 - docker cp tests/insecure-ssh-key.pub ubuntu-14.04-XXL-test:/home/ubuntu/.ssh/authorized_keys - sudo lxc-attach -n $$(docker inspect --format "{{.Id}}" ubuntu-14.04-XXL-test) -- bash -c "chown ubuntu:ubuntu /home/ubuntu/.ssh/authorized_keys" - chmod 600 tests/insecure-ssh-key; ssh -i tests/insecure-ssh-key -p 12345 ubuntu@localhost bats tests/unit/ubuntu-14.04-XXL - -deploy-ubuntu-14.04-XXL: - ./docker-export $(IMAGE_REPO):ubuntu-14.04-XXL-$(VERSION) > build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz - aws s3 cp ./build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz s3://circle-downloads/build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz --acl public-read - aws s3 cp s3://circle-downloads/build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz s3://lxc-images/build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz --acl public-read - aws s3 cp s3://circle-downloads/build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz s3://lxc-images-us-east-2/build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz --acl public-read - aws s3 cp s3://circle-downloads/build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz s3://lxc-images-us-west-2/build-image-ubuntu-14.04-XXL-$(VERSION).tar.gz --acl public-read - -ubuntu-14.04-XXL: build-ubuntu-14.04-XXL push-ubuntu-14.04-XXL dump-version-ubuntu-14.04-XXL test-ubuntu-14.04-XXL - -### ubuntu-14.04-XXL-enterprise -# This build image is for CircleCI Enterprise customer. The image is very similar to ubuntu-14.04-XXL. -# The only difference is that this image has official Docker installed. -### -build-ubuntu-14.04-XXL-enterprise: -ifndef NO_CACHE - docker-cache-shim pull ${IMAGE_REPO} || true -endif - echo "Building Docker image ubuntu-14.04-XXL-enterprise-$(VERSION)" - docker build $(NO_CACHE) --build-arg IMAGE_TAG=ubuntu-14.04-XXL-enterprise-$(VERSION) \ - -t $(IMAGE_REPO):ubuntu-14.04-XXL-enterprise-$(VERSION) \ - -f targets/ubuntu-14.04-XXL-enterprise/Dockerfile \ - . - -push-ubuntu-14.04-XXL-enterprise: - docker-cache-shim push ${IMAGE_REPO}:ubuntu-14.04-XXL-enterprise-$(VERSION) - $(call docker-push-with-retry,$(IMAGE_REPO):ubuntu-14.04-XXL-enterprise-$(VERSION)) - -dump-version-ubuntu-14.04-XXL-enterprise: - docker run $(IMAGE_REPO):ubuntu-14.04-XXL-enterprise-$(VERSION) sudo -H -i -u ubuntu /opt/circleci/bin/pkg-versions.sh | jq . > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XXL-enterprise.json; true - curl -o versions.json.before https://circleci.com/docs/environments/trusty.json - diff -uw versions.json.before $(CIRCLE_ARTIFACTS)/versions-enterprise.json > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XXL-enterprise.diff; true - -test-ubuntu-14.04-XXL-enterprise: - exit 0 - -deploy-ubuntu-14.04-XXL-enterprise: - ./docker-export $(IMAGE_REPO):ubuntu-14.04-XXL-enterprise-$(VERSION) > build-image-ubuntu-14.04-XXL-enterprise-$(VERSION).tar.gz - ./scripts/release-LXC-container ubuntu-14.04-XXL-enterprise-$(VERSION) ./build-image-ubuntu-14.04-XXL-enterprise-$(VERSION).tar.gz - -ubuntu-14.04-XXL-enterprise: build-ubuntu-14.04-XXL-enterprise push-ubuntu-14.04-XXL-enterprise dump-version-ubuntu-14.04-XXL-enterprise - -### ubuntu-14.04-XL -# This image is designed to be used on Picard, our alpha build environment with network services -# provided through the docker composing mechanism. -# The images matches the content of Ubuntu 14.04 XXL except network services. -### -build-ubuntu-14.04-XL: -ifndef NO_CACHE - docker-cache-shim pull ${IMAGE_REPO} || true -endif - echo "Building Docker image ubuntu-14.04-XL-$(VERSION)" - docker build $(NO_CACHE) --build-arg IMAGE_TAG=ubuntu-14.04-XL-$(VERSION) \ - -t $(IMAGE_REPO):ubuntu-14.04-XL-$(VERSION) \ - -f targets/ubuntu-14.04-XL/Dockerfile \ - . - -push-ubuntu-14.04-XL: - docker-cache-shim push ${IMAGE_REPO}:ubuntu-14.04-XL-$(VERSION) - $(call docker-push-with-retry,$(IMAGE_REPO):ubuntu-14.04-XL-$(VERSION)) - -dump-version-ubuntu-14.04-XL: - docker run $(IMAGE_REPO):ubuntu-14.04-XL-$(VERSION) sudo -H -i -u ubuntu /opt/circleci/bin/pkg-versions.sh | jq . > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XL.json; true - curl -o versions.json.before https://circleci.com/docs/environments/trusty.json - diff -uw versions.json.before $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XL.json > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XL.diff; true - -test-ubuntu-14.04-XL: - docker run -w /home/ubuntu -v ~/image-builder/tests:/home/ubuntu/tests --name ubuntu-14.04-XL-test $(IMAGE_REPO):ubuntu-14.04-XL-$(VERSION) bash -l -c "bats /home/ubuntu/tests/unit/ubuntu-14.04-XL" - -deploy-ubuntu-14.04-XL: - exit 0 - -ubuntu-14.04-XL: build-ubuntu-14.04-XL push-ubuntu-14.04-XL dump-version-ubuntu-14.04-XL test-ubuntu-14.04-XL - -### ubuntu-14.04-enterprise -# This is the standard ubuntu-14.04 image for use on enterprise. It is similar to the 14.04-enterprise image, -# but has fewer things installed to make installing CCIE faster. -### -build-ubuntu-14.04-enterprise: -ifndef NO_CACHE - docker-cache-shim pull ${IMAGE_REPO} -endif - echo "Building Docker image ubuntu-14.04-enterprise-$(VERSION)" - docker build $(NO_CACHE) --build-arg IMAGE_TAG=ubuntu-14.04-enterprise-$(VERSION) \ - -t $(IMAGE_REPO):ubuntu-14.04-enterprise-$(VERSION) \ - -f targets/ubuntu-14.04-enterprise/Dockerfile \ - . - -push-ubuntu-14.04-enterprise: - docker-cache-shim push ${IMAGE_REPO}:ubuntu-14.04-enterprise-$(VERSION) - $(call docker-push-with-retry,$(IMAGE_REPO):ubuntu-14.04-enterprise-$(VERSION)) - -dump-version-ubuntu-14.04-enterprise: - docker run $(IMAGE_REPO):ubuntu-14.04-enterprise-$(VERSION) sudo -H -i -u ubuntu /opt/circleci/bin/pkg-versions.sh | jq . > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-enterprise.json; true - curl -o versions.json.before https://circleci.com/docs/environments/trusty.json - diff -uw versions.json.before $(CIRCLE_ARTIFACTS)/versions-enterprise.json > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-enterprise.diff; true - -test-ubuntu-14.04-enterprise: - exit 0 - -deploy-ubuntu-14.04-enterprise: - ./docker-export $(IMAGE_REPO):ubuntu-14.04-enterprise-$(VERSION) > build-image-ubuntu-14.04-enterprise-$(VERSION).tar.gz - ./scripts/release-LXC-container ubuntu-14.04-enterprise-$(VERSION) ./build-image-ubuntu-14.04-enterprise-$(VERSION).tar.gz - -ubuntu-14.04-enterprise: build-ubuntu-14.04-enterprise push-ubuntu-14.04-enterprise dump-version-ubuntu-14.04-enterprise - -### ubuntu-14.04-XXL-upstart -# This image behaves like a VM, with upstart being PID 1. Actions default to running as root -# and services (e.g. postgres, redis) are allowed without requiring to use another images. -# The images matches the content of Ubuntu 14.04 XXL. -### -build-ubuntu-14.04-XXL-upstart: - echo "Building Docker image ubuntu-14.04-XXL-upstart-$(VERSION)" - docker build $(NO_CACHE) --build-arg IMAGE_TAG=ubuntu-14.04-XXL-upstart-$(VERSION) \ - -t $(IMAGE_REPO):ubuntu-14.04-XXL-upstart-$(VERSION) \ - -f targets/ubuntu-14.04-XXL-upstart/Dockerfile \ - . - -push-ubuntu-14.04-XXL-upstart: - $(call docker-push-with-retry,$(IMAGE_REPO):ubuntu-14.04-XXL-upstart-$(VERSION)) - -dump-version-ubuntu-14.04-XXL-upstart: - docker run $(IMAGE_REPO):ubuntu-14.04-XXL-upstart-$(VERSION) sudo -H -i -u ubuntu /opt/circleci/bin/pkg-versions.sh | jq . > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XXL-upstart.json; true - curl -o versions.json.before https://circleci.com/docs/environments/trusty.json - diff -uw versions.json.before $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XXL-upstart.json > $(CIRCLE_ARTIFACTS)/versions-ubuntu-14.04-XXL-upstart.diff; true - -test-ubuntu-14.04-XXL-upstart: - # Tests are done when building ubuntu-14.04-XXL base image - exit 0 - -deploy-ubuntu-14.04-XXL-upstart: - exit 0 - -ubuntu-14.04-XXL-upstart: build-ubuntu-14.04-XXL-upstart push-ubuntu-14.04-XXL-upstart dump-version-ubuntu-14.04-XXL-upstart test-ubuntu-14.04-XXL-upstart diff --git a/README.md b/README.md deleted file mode 100644 index 1128f05..0000000 --- a/README.md +++ /dev/null @@ -1,205 +0,0 @@ -# CircleCI Image Builder - -`image-builder` is a repo that CircleCI is using to build various build images. This repo -is also for customers of CircleCI Enterprise to build custom build images. - -The repo uses Docker for building containers. The instructions assumes basic familiarity with -Docker. [Docker docs](https://docs.docker.com/) is a good resource to get started - -The following are brief explanations of build images that CircleCI builds by using image-builder. - -### Ubuntu 14.04 Enterprise - -**Description** - -This image is used as the default Trusty image on new installations of [CircleCI Enterprise](https://circleci.com/enterprise/). If you launch your builders with our `init-trusty-builder` script, or use the docker based installation, this is the default image you use. - -**Docker image tag** - -`circleci/build-image:ubuntu-14.04-enterprise-` - -### Ubuntu 14.04 XXL - -**Description** - -This image is used to provide Ubuntu Trusty build container support on [circleci.com](https://circleci.com). The image is the fattest image: many versions of popular programming languages as well as services are pre-installed. - -**List of installed software** - -https://circleci.com/docs/build-image-trusty/ - -**Docker image tag** - -`circleci/build-image:ubuntu-14.04-XXL-` - -### Ubuntu 14.04 XXL Enterprise - -**Description** - -This image is maintained for customers of [CircleCI Enterprise](https://circleci.com/enterprise/). The image is very similar to Ubuntu 14.04 XXL image but one difference: vanilla Docker is preinstalled in the image while patched version of Docker is installed in Ubuntu 14.04 XXL. This is because customers of CircleCI Enterprise can run build containers in privileged mode. - -**List of installed software** - -https://circleci.com/docs/build-image-trusty/ - -Note: only Docker version is different. We install the latest version of Docker. - -**Docker image tag** - -`circleci/build-image:ubuntu-14.04-XXL-enterprise-` - -## How to trigger a build/job - -`image-builder` builds are currently running on [CircleCI 2.0!!](https://circleci.com/beta-access/) and each build image can be -built by running a corresponding job. - -If you have the permission to trigger `image-build` build, then you can trigger a build by using `trigger-job.sh` - -``` -Example: - -./trigger-job.sh ubuntu-14.04-XXL my-test-branch -``` - -Run `./trigger-job.sh --help` for more information. - -# Building custom image - -This section is written for customers of [CircleCI Enterprise](https://circleci.com/enterprise/) who wants to build a custom image by using image-builder. Although Enterprise customers can use any tools in the wild to build a custom image, we highly recommend to using image-builder. This makes sure that Enterprise customers run builds on build images that CircleCI has a better support. - -## Building a container - -There are multiple workflow for building a container, and it depends on the level of customizations: - -### Building a container image with minor tweak, e.g. adding a new package, python version - -If you want to tweak containers to simply add new package or new customizations, you can -use our published containers as your base. - -For doing so, you can create a Dockerfile with the appropriate customizations: - -``` -FROM circleci/build-image:latest - -# You can use some basic tools, using the `circleci-install` helper function -# for tools, CircleCI supports -RUN circleci-install ruby 2.2.1 -RUN circleci-install scala - -# You can add custom files -ADD my-custom-root-ca.crt /usr/local/share/ca-certificates/my-custom-root-ca.crt -RUN update-ca-certificates -``` - -And then you can build it as you would typically do (i.e. `docker build -t my-container:0.3 .`). - -Another common tweak is removing packages/tools that you don't use. For example, if you don't have -Android projects, you should remove the lines that install Android SDKs from the Dockerfile. -We encourage you to install only what you need because having a smaller container image will give you many benefits such as faster container start up time. - -With this workflow, you will be basing your container on CircleCI published container image, -speeding up creation process. When CircleCI publishes new container image, you can rebuild -your image and Docker will pick up the latest published version. - -### Building a container with substantial changes - -If you need to customize the image by starting from a clean slate, and/or -require significant changes, e.g. different MySQL version, or MariaDB rather -than MySQL, then the recommended path is to fork the repo and apply your -changes, then build the Docker image. - -Please note, that this repo uses `circleci/ubuntu-server` as the base image. -It uses the official Ubuntu Server image (rather than Ubuntu Core, the default -ubuntu in DockerHub), tweaks slightly so Upstart can work with Docker. - -It's recommended that you fork this repo rather than start from scratch for the following benefits: - -* Ensure that CircleCI specific required customizations (e.g. xvfb) is correctly applied -* Have a mechanism to pick up later tweaks and improvements by merging the repo - rather than merging them manually later -* Reuse the custom provisioning framework that we are building to ease installation -* Have a mechanism to push your changes/tweaks back to us - -**Please note, our infrastructure currently assumes that `mysql` and `postgres` are installed. Even if you do not use them, please include them in your image** - -### Super advanced mode: Using Chef/Ansible/etc - -If you have a significant infrastructure using custom provisioners, e.g. -Chef/Ansible/SaltStack, please reach out to us private. The exact instructions -are beyond the scope of this documentation. - -In a very high level, we would recommend using [Packer](https://www.packer.io) -and [Packer's Docker Builder](https://www.packer.io/docs/builders/docker.html). - -## Testing the container - -So you built the container successfully! Congrats. How can you test it? - -You can use the common Docker techniques for launching a container and connecting to it. - -The workflow, I adopt is the following: - -```bash -host $ # build the image and name it `example-image` -host $ docker build -t example-image . -[...] -host $ # Start it - but enable ssh and mount a sample test project -host $ docker run -d \ - -p 22 -v ~/.ssh/id_rsa.pub:/home/ubuntu/.ssh/authorized_keys \ # To allow for ssh - -v hello-world-project:/home/ubuntu/hello-world-project \ # mount a sample project - --name example-image-tester \ - example-image -5b43b9fd24dd046a389dc2bbc2e84925c011910cfdd2de6cf638dd245f074831 -host $ # Now ssh into the container. This depends whether you are using Docker natively or through docker-machine -host $ # With native docker -host $ CONTAINER_SSH_PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}' example-image-tester) -host $ # If using docker-machine, need to connect to the docker-machine ip address -host $ CONTAINER_SSH_HOST=$(docker-machine ip default) # or set to 127.0.0.1 if using Docker natively on a Linux box -host $ -host $ ssh -o StrictHostKeyChecking=no -p $CONTAINER_SSH_PORT ubuntu@${CONTAINER_SSH_HOST} -docker $ -docker $ # now you are in Docker and the build - run any tests you need -docker $ cd example-image-test -docker $ # Run any custom test steps you need, e.g. for a node project it will be -docker $ npm install -docker $ npm test -docker $ -docker $ $ also can run any sanity checks, e.g. ensure postgres is running -ubuntu@22b220709b03:~$ psql -psql (9.4.5) -Type "help" for help. - -ubuntu=# ;; psql is running -ubuntu=# ;; psql is running -ubuntu-# \quit -``` -## Hooking up CircleCI to use the container - -Once you gain confidence in the image you just created, you can start pushing it to new builds. -You must configure CircleCI Enterprise builders to point to the container -image. You can do so, by passing additional environment variable in your -launch configuration: `CIRCLE_CONTAINER_IMAGE_URI`. - - -### Docker-based build containers -If you are using the [Single-Box install](https://circleci.com/docs/enterprise/single-box/) or a [clustered install using Docker](https://circleci.com/docs/enterprise/docker-install/), then you can simply set the `CIRCLE_CONTAINER_IMAGE_URI` env var as documented [here](https://circleci.com/docs/enterprise/docker-builder-config/) to e.g. `docker://my-hub-account/my-image:my-tag` after pushing to public Docker Hub. (You can also use any other registry accessable to your docker daemon.) - -### LXC-based build containers -If you are using LXC-based builders, you will need to follow these instructions to export the container image to an LXC format and expose it via an http or S3 uri (e.g. -`https://example.com/container_0.0.1.tar.gz` or -`s3://example/container_0.0.1.tar.gz`). - -Assuming you have the official aws-cli client, you can export the container and -upload it to a bucket of your choice. Ideally, it's located in the same region -as the builders, and you can reuse the bucket that got created for the CCIE installation -': - -(_note: this uses the included `docker-export`, which is different than `docker export`_) -```bash -$ ./docker-export example-image > example-image_0.0.1.tar.gz -$ aws s3 cp ./example-image_0.0.1.tar.gz s3://circleci-enterprise-bucket/containers/example-image_0.0.1.tar.gz -``` - -Once uploaded, attempt to start a new builder configured with -`CIRCLE_CONTAINER_IMAGE_URI=s3://circleci-enterprise-bucket/containers/example-image_0.0.1.tar.gz`. -Try running new builds on it. Once it's all good, update the AutoScalingGroup -Launch configuration to use the environment variable as well. diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 0d3dc53..0000000 --- a/circle.yml +++ /dev/null @@ -1,43 +0,0 @@ -machine: - environment: - IMAGE_REPO: "circleci/build-image" - BUILD_TARGET: $(cd $CIRCLE_PROJECT_REPONAME && git log --format=%B -n 1 | grep build-targets | sed 's/build-targets//' | tr -d ' ') - - pre: - - echo 'no_cache() { git log --format=%B -n 1 | grep -q "no cache"; }' >> ~/.circlerc - - git clone git@github.com:kimh/docker-cache-shim.git && cd docker-cache-shim && sudo ./install.sh - - post: - - sudo curl -L -o /usr/bin/docker 'https://s3.amazonaws.com/circle-downloads/docker-1.9.1-circleci' - - sudo service docker start - -dependencies: - override: - # Fail early if no build targets - - make --dry-run ${BUILD_TARGET:-notarget} - - - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - - - ? | - if $(no_cache); then - make no_cache=true build-$BUILD_TARGET - else - make build-$BUILD_TARGET - fi - : - timeout: 7200 - - - make push-$BUILD_TARGET: - timeout: 7200 - -test: - override: - - make test-$BUILD_TARGET - - make dump-version-$BUILD_TARGET - -deployment: - production: - branch: master - commands: - - for TARGET in $(echo $BUILD_TARGET); do make deploy-${TARGET}; done: - timeout: 3600 diff --git a/circleci-install b/circleci-install deleted file mode 100755 index 8488b76..0000000 --- a/circleci-install +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -[ -n "$CIRCLECI_USER" ] || export CIRCLECI_USER=ubuntu -[ -n "$RUN_APT_UPDATE" ] || export RUN_APT_UPDATE=false - -export CIRCLECI_HOME=/home/${CIRCLECI_USER} -export CIRCLECI_PKG_DIR=/opt/circleci - -if ! [ -d $CIRCLECI_PKG_DIR ]; then - mkdir -p $CIRCLECI_PKG_DIR - chown -R $CIRCLECI_USER:$CIRCLECI_USER $CIRCLECI_PKG_DIR -fi - -function as_user() { - sudo -H -u ${CIRCLECI_USER} $@ -} -export -f as_user - -function maybe_run_apt_update() { - if [ $RUN_APT_UPDATE = "true" ]; then - apt-get update - fi -} -export -f maybe_run_apt_update - -[[ $SCRIPTS_PATH ]] || export SCRIPTS_PATH=/opt/circleci-provision-scripts - -set -a -set -e - -if [ "$VERBOSE" = "true" ]; then - echo "enabling debug mode...." - set -x -fi - -export SHELLOPTS - -for n in $SCRIPTS_PATH/*.sh -do - source $n -done - -install_$@ diff --git a/circleci-provision-scripts/android-ndk.sh b/circleci-provision-scripts/android-ndk.sh deleted file mode 100755 index 38875b4..0000000 --- a/circleci-provision-scripts/android-ndk.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -function install_ndk() { - NDK_VERSION=r10d - TMP_NDK=/tmp/ndk - DIR=android-ndk-$NDK_VERSION - FILE=$DIR-linux-x86_64.bin - - mkdir -p $TMP_NDK - curl -L -o $TMP_NDK/$FILE https://dl.google.com/android/ndk/$FILE - - pushd $TMP_NDK - chmod a+x $FILE - ./$FILE - mv $DIR /usr/local/android-ndk - popd - - echo 'export "ANDROID_NDK=/usr/local/android-ndk"' >> ${CIRCLECI_HOME}/.circlerc - rm -rf $TMP_NDK -} - -# I'm not sure how many users actually use fb-adb, so disabling for now. -#function install_fb_adb() { -# FB_ADB_VERSION=1.2.0 -# TMP_FB_ADB=/tmp/fb_adb -# FILE=fb-adb-$FB_ADB_VERSION.tar.gz -# -# mkdir -p $TMP_FB_ADB -# curl -L -o $TMP_FB_ADB/$FILE https://s3.amazonaws.com/circle-downloads/$FILE -# -# pushd $TMP_FB_ADB -# tar xzf $FILE -# cd fb-adb -# ./autogen.sh -# mkdir build && cd build -# source ${CIRCLECI_HOME}/.circlerc -# "../configure" -# make install -# popd -# -# rm -rf $TMP_FB_ADB -#} - -function install_android_ndk() { - [[ -e /usr/local/android-ndk ]] || install_ndk -} diff --git a/circleci-provision-scripts/android-sdk.sh b/circleci-provision-scripts/android-sdk.sh deleted file mode 100755 index f8e4b2e..0000000 --- a/circleci-provision-scripts/android-sdk.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash - -function install_circle_android_helper() { - cat <<'EOF' > /usr/local/bin/circle-android -#!/usr/bin/env bash - -spinstr='|/-\' -spin_index=0 - -spin_until () { - while ! $@ - do - spin_index=$(expr $(expr $spin_index + 1) % 4) - printf "\r${spinstr:spin_index:1}" - sleep 0.5 - done - printf "\r" -} - -adb_shell_getprop () { - adb shell getprop $1 | tr -d [:space:] # delete the whitespace -} - -device_actually_ready () { - # https://devmaze.wordpress.com/2011/12/12/starting-and-stopping-android-emulators/ - [ "$(adb_shell_getprop init.svc.bootanim)" = "stopped" ] -} - -if [ "$1" == "wait-for-boot" ] -then - # wait for the device to respond to shell commands - spin_until adb shell true 2> /dev/null - # wait for the emulator to be completely finished booting. - # adb wait-for-device is not sufficient for this. - spin_until device_actually_ready -else - echo "$0, a collection of tools for CI with android." - echo "" - echo "Usage:" - echo " $0 wait-for-boot - wait for a device to fully boot." - echo " (adb wait-for-device only waits for it to be ready for shell access)." -fi - -EOF - - chmod +x /usr/local/bin/circle-android -} - -function install_sdk_package() { - PACKAGE=$1 - - echo ">>> Installing SDK Package: $PACKAGE" - (cat <<'EOF' -source ~/.circlerc -echo "y" | android update sdk --no-ui --all --filter $PACKAGE -EOF - ) | as_user PACKAGE=$PACKAGE bash - - if [[ "$PACKAGE" =~ ^sys-img-armeabi-v7a-android-[0-9][0-9]$ ]]; then - AVD_VERSION=$(echo $PACKAGE | sed 's/sys-img-armeabi-v7a-android-//') - create_avd $AVD_VERSION - fi -} - -function create_avd() { - VERSION=$1 - AVD_TARGET=android$VERSION - IMG_TARGET=android-$VERSION - AVD_NAME=circleci-$AVD_TARGET - IMG_NAME=sys-img-armeabi-v7a-$IMG_TARGET - - echo ">>> Creating AVD $AVD_NAME" - (cat <<'EOF' -source ~/.circlerc -echo "y" | android update sdk --no-ui --all --filter $IMG_NAME -echo "no" | android create avd -n $AVD_NAME -t $IMG_TARGET --abi "default/armeabi-v7a" -EOF - ) | as_user VERSION=$VERSION AVD_NAME=$AVD_NAME AVD_TARGET=$AVD_TARGET IMG_NAME=$IMG_NAME IMG_TARGET=$IMG_TARGET bash -} - -function install_sdk(){ - SDK_VERSION="r24.4.1" - TMP_SDK=/tmp/sdk - FILE=android-sdk_${SDK_VERSION}-linux.tgz - - mkdir -p $TMP_SDK - sudo apt-get install -y openjdk-7-jdk lib32stdc++6 lib32z1 - curl -L -o $TMP_SDK/$FILE https://dl.google.com/android/$FILE - tar --no-same-owner -zxf $TMP_SDK/$FILE -C /usr/local - echo 'export PATH=/usr/local/android-sdk-linux/tools:$PATH' >> ${CIRCLECI_HOME}/.circlerc - echo 'export PATH=/usr/local/android-sdk-linux/platform-tools:$PATH' >> ${CIRCLECI_HOME}/.circlerc - echo 'export ANDROID_HOME=/usr/local/android-sdk-linux' >> ${CIRCLECI_HOME}/.circlerc - echo 'export ADB_INSTALL_TIMEOUT=10' >> ${CIRCLECI_HOME}/.circlerc - chown -R $CIRCLECI_USER:$CIRCLECI_USER /usr/local/android-sdk-linux - rm -rf $TMP_SDK -} - -function install_android_sdk() { - SDK_PACKAGE=$1 - [[ -e /usr/local/android-sdk-linux ]] || install_sdk - [[ -e /usr/local/bin/circle-android ]] || install_circle_android_helper - - install_sdk_package $SDK_PACKAGE -} diff --git a/circleci-provision-scripts/awscli.sh b/circleci-provision-scripts/awscli.sh deleted file mode 100644 index a7c8e7d..0000000 --- a/circleci-provision-scripts/awscli.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -function install_awscli() { - pushd /tmp - curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" - unzip awscli-bundle.zip - ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws - rm -rf awscli-bundle* - popd -} diff --git a/circleci-provision-scripts/base.sh b/circleci-provision-scripts/base.sh deleted file mode 100755 index 1001584..0000000 --- a/circleci-provision-scripts/base.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash - -function install_base_requirements() { - echo "Setting Timezone & Locale to Etc/UTC & C.UTF-8" - - ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime - locale-gen C.UTF-8 || true - update-locale LANG=en_US.UTF-8 - export LANG=C.UTF-8 - - echo "export LANG=C.UTF-8" > ${CIRCLECI_HOME}/.bashrc - - echo ">>> Make Apt non interactive" - - echo 'force-confnew' >> /etc/dpkg/dpkg.cfg - - (cat <<'EOF' -// the /etc/apt/apt.conf file for the slave AMI - -// Auto "-y" for apt-get -APT { - Get { - Assume-Yes "true"; - force-yes "true"; - }; -}; - -// Disable HTTP pipelining, S3 doesn't support it properly. -Acquire { - http { - Pipeline-Depth 0; - } -} - -// Don't ask to update -DPkg { - Options { - "--force-confnew"; - }; -}; -EOF -) > /etc/apt/apt.conf - - echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep - export DEBIAN_FRONTEND=noninteractive - - apt-get update -y - apt-get install -y software-properties-common - apt-add-repository ppa:git-core/ppa - apt-get update -y - - - # Install base packages - apt-get install $(tr '\n' ' ' <>> Installing casperjs' - - cd "/usr/local" - git clone "http://github.com/n1k0/casperjs.git" - cd casperjs - git checkout "tags/1.0.2" - ln -sf "`pwd`/bin/casperjs" "/usr/local/bin/casperjs" -} diff --git a/circleci-provision-scripts/chrome.sh b/circleci-provision-scripts/chrome.sh deleted file mode 100755 index 138b966..0000000 --- a/circleci-provision-scripts/chrome.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -function install_chrome_browser() { - echo '>>> Installing Chrome' - - local url="https://s3.amazonaws.com/circle-downloads/google-chrome-stable_54.0.2840.100-1_amd64.deb" - local deb_path="/tmp/google-chrome.deb" - - curl --output $deb_path $url - - dpkg -i $deb_path || apt-get -f install - - # Disable sandboxing - it conflicts with unprivileged lxc containers - sed -i 's|HERE/chrome"|HERE/chrome" --disable-setuid-sandbox --enable-logging --no-sandbox|g' \ - "/opt/google/chrome/google-chrome" -} - - -# Chrome Driver - -function install_chromedriver() { - CHROME_DRIVER_VERSION=2.27 - curl -L -o /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip - unzip -p /tmp/chromedriver.zip > /usr/local/bin/chromedriver - chmod +x /usr/local/bin/chromedriver - rm -rf /tmp/chromedriver.zip -} - -function install_chrome() { - install_chrome_browser - install_chromedriver -} diff --git a/circleci-provision-scripts/circleci-specific.sh b/circleci-provision-scripts/circleci-specific.sh deleted file mode 100755 index 645ae14..0000000 --- a/circleci-provision-scripts/circleci-specific.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -function install_circleci_specific() { - # CircleCI specific commands - - echo '>>> Installing CircleCI Specific things' - - echo 'source ~/.bashrc &>/dev/null' >> ${CIRCLECI_HOME}/.bash_profile - echo 'source ~/.circlerc &>/dev/null' > ${CIRCLECI_HOME}/.bashrc - - chown $CIRCLECI_USER:$CIRCLECI_USER ${CIRCLECI_HOME}/.bash_profile - chown $CIRCLECI_USER:$CIRCLECI_USER ${CIRCLECI_HOME}/.bashrc - - (cat <<'EOF' -export GIT_ASKPASS=echo -export SSH_ASKPASS=false -export PATH=~/bin:$PATH -export CIRCLECI_PKG_DIR="/opt/circleci" -EOF -) | as_user tee ${CIRCLECI_HOME}/.circlerc - - as_user mkdir -p ${CIRCLECI_HOME}/bin - - # Configure SSH so it can talk to servers OK - - cat <<'EOF' > /etc/ssh/ssh_config -Host * - StrictHostKeyChecking no - HashKnownHosts no - SendEnv LANG LC_* -EOF - - # Some optimizations for the sshd daemon - sed -i 's/PasswordAuthentication yes/PasswordAuthoentication no/g' /etc/ssh/sshd_config - - cat <<'EOF' >> /etc/ssh/sshd_config -UseDns no -MaxStartups 1000 -MaxSessions 1000 -PermitTunnel yes -AddressFamily inet -EOF - - # Setup xvfb - - apt-get install xvfb xfwm4 - - sed -i 's/^exit 0/nohup Xvfb :99 -screen 0 1280x1024x24 \&\nsleep 2\nDISPLAY=:99.0 xfwm4 --daemon\nexit 0/g' /etc/rc.local - - echo 'export DISPLAY=:99' >> $CIRCLECI_HOME/.circlerc - - # Avoid GPG signatures errors - gpg --keyserver pgp.mit.edu --recv-keys 749D6EEC0353B12C - gpg --export --armor 749D6EEC0353B12C | sudo apt-key add - - gpg --keyserver pgp.mit.edu --recv-keys F76221572C52609D - gpg --export --armor F76221572C52609D | sudo apt-key add - - - # A tweak to make selenium tests stable - # https://github.com/SeleniumHQ/docker-selenium/issues/87 - echo 'export DBUS_SESSION_BUS_ADDRESS=/dev/null' >> $CIRCLECI_HOME/.circlerc -} diff --git a/circleci-provision-scripts/cleanup.sh b/circleci-provision-scripts/cleanup.sh deleted file mode 100644 index e69de29..0000000 diff --git a/circleci-provision-scripts/clojure.sh b/circleci-provision-scripts/clojure.sh deleted file mode 100755 index 1736d3e..0000000 --- a/circleci-provision-scripts/clojure.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -function install_clojure() { - LEIN_VERSION=2.7.1 - LEIN_URL=https://raw.github.com/technomancy/leiningen/${LEIN_VERSION}/bin/lein - LEIN_BIN=/usr/local/bin/lein - - curl -L -o $LEIN_BIN $LEIN_URL - chmod +x $LEIN_BIN - - (cat <<'EOF' -# Force dependencies to download -lein -v -EOF - ) | as_user bash -} diff --git a/circleci-provision-scripts/curl.sh b/circleci-provision-scripts/curl.sh deleted file mode 100644 index 04c1d62..0000000 --- a/circleci-provision-scripts/curl.sh +++ /dev/null @@ -1,26 +0,0 @@ -function install_curl_7_56() { - local build_dir=/tmp/curl - apt-get install libssl-dev # Needed for ssl support for curl - apt-get build-dep curl - - # Get latest (as of Feb 25, 2016) libcurl - mkdir $build_dir - cd $build_dir - wget http://curl.haxx.se/download/curl-7.56.1.tar.bz2 - tar -xvjf curl-7.56.1.tar.bz2 - cd curl-7.56.1 - - # The usual steps for building an app from source - # ./configure - # ./make - # sudo make install - ./configure - make - make install - - # Resolve any issues of C-level lib - # location caches ("shared library cache") - ldconfig - - rm -rf $build_dir -} diff --git a/circleci-provision-scripts/docker.sh b/circleci-provision-scripts/docker.sh deleted file mode 100755 index 231e6d8..0000000 --- a/circleci-provision-scripts/docker.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -function install_docker() { - echo '>>>> Installing Docker' - - # Pin Docker version to 10.x since 11 brings breaking changes - echo "deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list - apt-get update - apt-get install docker-engine=1.10.3-0~trusty - - # Devicemapper files are huge if got created - we don't use device mapper anyway - rm -rf /var/lib/docker/devicemapper/devicemapper/data - rm -rf /var/lib/docker/devicemapper/devicemapper/metadata - - # CirclecI Docker customizations - sed -i 's|^limit|#limit|g' /etc/init/docker.conf - usermod -a -G docker ${CIRCLECI_USER} - - # Docker will be running inside a container (lxc or privileged docker) - # Internally, docker checks container env-var to condition some apparmor profile activities that don't work within lxc - echo 'env container=yes' >> /etc/init/docker.conf - - # Don't start Docker by default - echo manual >> /etc/init/docker.conf -} - -function install_circleci_docker() { - echo '>>> Install CircleCI Docker fork that runs on user namespaces' - - # Install LXC and btrfs-tools - apt-get -y install lxc btrfs-tools - - # DNS forwarding doesn't work without this line which causes container unable to resolve DNS - sed -i 's|10.0.3|10.0.4|g' /etc/default/lxc-net - - # Divert plain docker - sudo dpkg-divert --add --rename --divert /usr/bin/docker.plain /usr/bin/docker - - # Replace with CircleCI's patched docker - sudo curl -L -o /usr/bin/docker.circleci 'https://s3.amazonaws.com/circle-downloads/docker-1.9.1-circleci' - sudo chmod 0755 /usr/bin/docker.circleci - - # --userland-proxy=false: Docker's userland proxy is broken. Don't use it. - echo 'DOCKER_OPTS="-s btrfs -e lxc -D --userland-proxy=false"' > /etc/default/docker - - sudo ln -s /usr/bin/docker.circleci /usr/bin/docker -} - -function install_docker_compose() { - echo '>>>> Installing Docker compose' - - curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose - chmod +x /usr/local/bin/docker-compose -} diff --git a/circleci-provision-scripts/firefox.sh b/circleci-provision-scripts/firefox.sh deleted file mode 100755 index 5eefae5..0000000 --- a/circleci-provision-scripts/firefox.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -function install_firefox() { - echo '>>> Installing Firefox' - - # If you are upgrading to any version newer than 47.0.1, you must check the compatibility with - # selenium. See https://github.com/SeleniumHQ/selenium/issues/2559#issuecomment-237079591 - local url="https://s3.amazonaws.com/circle-downloads/firefox-mozilla-build_47.0.1-0ubuntu1_amd64.deb" - local deb_path="/tmp/firefox.deb" - - curl --output $deb_path $url - - dpkg -i $deb_path || apt-get -f install -} - -function install_firefox_version() { - VERSION="$1" - echo ">>> Installing Firefox $VERSION" - curl -L -o "/tmp/firefox-$VERSION.tar.bz2" "https://download-installer.cdn.mozilla.net/pub/firefox/releases/$VERSION/linux-x86_64/en-US/firefox-$VERSION.tar.bz2" - tar -jxf "/tmp/firefox-$VERSION.tar.bz2" -C "/tmp/" - sudo mv "/tmp/firefox" "/opt/firefox-$VERSION" - sudo ln -sf "/opt/firefox-$VERSION/firefox" "/usr/bin/firefox" - hash -r - firefox --version -} diff --git a/circleci-provision-scripts/gcloud.sh b/circleci-provision-scripts/gcloud.sh deleted file mode 100755 index 18bebe9..0000000 --- a/circleci-provision-scripts/gcloud.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -function install_gcloud() { - # Using sudo inside `as_user bash` is confusing but this is needed becase - # gcloud installation script needs to instal .config/gcloud dir under user's $HOME directory. - (cat <<'EOF' -sudo bash -c 'curl "https://sdk.cloud.google.com" | CLOUDSDK_CORE_DISABLE_PROMPTS=1 CLOUDSDK_INSTALL_DIR=/opt bash' -EOF - ) | as_user bash - chown -R $CIRCLECI_USER:$CIRCLECI_USER "/opt/google-cloud-sdk" - chown -R $CIRCLECI_USER:$CIRCLECI_USER ${CIRCLECI_HOME}/.config - - echo 'export PATH=/opt/google-cloud-sdk/bin:$PATH' >> ${CIRCLECI_HOME}/.circlerc - - if [ -e /home/ubuntu/.config ]; then - chown -R ubuntu /home/ubuntu/.config - fi -} diff --git a/circleci-provision-scripts/git-lfs.sh b/circleci-provision-scripts/git-lfs.sh deleted file mode 100644 index 95d3837..0000000 --- a/circleci-provision-scripts/git-lfs.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -function install_git-lfs() { - local version=$1 - - add-apt-repository ppa:git-core/ppa -y - curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash - - apt-get install git-lfs=$version - - # Disable git-lfs pulling lfs files automatically - echo 'GIT_LFS_SKIP_SMUDGE=1' >> /etc/environment -} diff --git a/circleci-provision-scripts/go.sh b/circleci-provision-scripts/go.sh deleted file mode 100755 index f8853f9..0000000 --- a/circleci-provision-scripts/go.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -function install_golang() { - GO_VERSION=$1 - - echo ">>> Installing Go ${GO_VERSION}" - - URL=http://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz - - curl -sSL -o /tmp/go.tar.gz $URL - tar -xz -f /tmp/go.tar.gz -C /usr/local - - # Workaround an issue with go install wanting to write to goroot - # in old versions - chown ${CIRCLECI_USER}:${CIRCLECI_USER} /usr/local/go - - echo '>> Setting up gopath' - - as_user mkdir -p ${CIRCLECI_HOME}/.go_workspace - - echo 'export PATH=~/.go_workspace/bin:/usr/local/go/bin:$PATH' >> ${CIRCLECI_HOME}/.circlerc - echo 'export GOPATH=~/.go_workspace:/usr/local/go_workspace' >> ${CIRCLECI_HOME}/.circlerc - - rm -rf /tmp/go.tar.gz -} diff --git a/circleci-provision-scripts/haskell.sh b/circleci-provision-scripts/haskell.sh deleted file mode 100644 index 65e48f6..0000000 --- a/circleci-provision-scripts/haskell.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -function install_ghc() { - local version=$1 - local install_path="/opt/ghc/$version" - - local ppa="ppa:hvr/ghc" - local ppa_file="/etc/apt/sources.list.d/hvr-ghc-trusty.list" - - local happy_version="1.19.5" - local alex_version="3.1.7" - local cabal_version="1.24" - - if ! [ -e $ppa_file ]; then - apt-add-repository $ppa - apt-get update - fi - - install_ghc_tool happy $happy_version - install_ghc_tool alex $alex_version - install_cabal $cabal_version - - apt-get install ghc-$version - - echo "export PATH=$install_path/bin"':$PATH' >> ${CIRCLECI_HOME}/.circlerc -} - -function install_stack() { - curl -sSL https://get.haskellstack.org/ | sh - echo "export PATH=~/.local/bin"':$PATH' >> ${CIRCLECI_HOME}/.circlerc -} - -function install_ghc_tool() { - local name=$1 - local version=$2 - local install_path="/opt/$name/$version" - - if ! [ -e $install_path ]; then - apt-get install $name-$version - echo "export PATH=$install_path/bin"':$PATH' >> ${CIRCLECI_HOME}/.circlerc - fi -} - -function install_cabal() { - local version=$1 - local install_path="/opt/cabal/$version" - local cabal_config="${CIRCLECI_HOME}/.cabal/config" - - if ! [ -e $install_path ]; then - apt-get install cabal-install-$version - echo "export PATH=$install_path/bin"':$PATH' >> ${CIRCLECI_HOME}/.circlerc - - $install_path/bin/cabal update - - (cat <<'EOF' -$install_path/bin/cabal update -EOF - ) | as_user install_path=$install_path bash - - sed -i 's/jobs: $ncpus/-- jobs:$ncpus/' $cabal_config - echo 'jobs: 2' >> $cabal_config - fi -} diff --git a/circleci-provision-scripts/heroku.sh b/circleci-provision-scripts/heroku.sh deleted file mode 100755 index 4f624b0..0000000 --- a/circleci-provision-scripts/heroku.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -function install_heroku() { - echo '>>> Installing heroku' - - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh - - chown -R $CIRCLECI_USER:$CIRCLECI_USER ${CIRCLECI_HOME}/.config - - # Run once to bootstrap heroku cli - (cat <<'EOF' -heroku --version -EOF - ) | as_user bash - - if [ -e /home/ubuntu/.config ]; then - chown -R ubuntu /home/ubuntu/.config - fi -} diff --git a/circleci-provision-scripts/java.sh b/circleci-provision-scripts/java.sh deleted file mode 100755 index beb3e71..0000000 --- a/circleci-provision-scripts/java.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash - -function set_default_version() { - # Set jdk1.8.0 to the default version - update-alternatives --set "java" "/usr/lib/jvm/jdk1.8.0/bin/java" - update-alternatives --set "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" - update-alternatives --set "javaws" "/usr/lib/jvm/jdk1.8.0/bin/javaws" - update-alternatives --set "javadoc" "/usr/lib/jvm/jdk1.8.0/bin/javadoc" -} - -function _install_oraclejdk() { - local VERSION=$1 - local RELEASE=$2 - - local FILE="jdk-${VERSION}u${RELEASE}-linux-x64.tar.gz" - local URL="https://circle-downloads.s3.amazonaws.com/$FILE" - local JAVA_TMP=/tmp/java - local JDK="jdk1.${VERSION}.0_${RELEASE}" - local INSTALL_PATH="/usr/lib/jvm/jdk1.${VERSION}.0" - - mkdir -p $JAVA_TMP - pushd $JAVA_TMP - - curl -L -O $URL - tar zxf $FILE - mkdir -p /usr/lib/jvm - mv ./$JDK $INSTALL_PATH - - update-alternatives --install "/usr/bin/java" "java" "${INSTALL_PATH}/bin/java" $VERSION - update-alternatives --install "/usr/bin/javac" "javac" "${INSTALL_PATH}/bin/javac" $VERSION - update-alternatives --install "/usr/bin/javaws" "javaws" "${INSTALL_PATH}/bin/javaws" $VERSION - update-alternatives --install "/usr/bin/javadoc" "javadoc" "${INSTALL_PATH}/bin/javadoc" $VERSION - - popd - - rm -rf $JAVA_TMP -} - -function install_oraclejdk7() { - echo '>>> Installing Oracle Java 7' - - _install_oraclejdk 7 181 -} - -function install_oraclejdk8() { - echo '>>> Installing Oracle Java 8' - - _install_oraclejdk 8 102 - set_default_version -} - -function install_oraclejdk9() { - echo '>>> Installing Oracle Java 9' - - add-apt-repository --yes ppa:webupd8team/java - apt-get update - - echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections - apt-get install oracle-java9-installer - - set_default_version -} - -function _install_openjdk() { - - local version=$1 - local package="openjdk-$version-jdk" - - add-apt-repository -y ppa:openjdk-r/ppa - apt-get update - apt-get install $package -} - -function install_openjdk7() { - _install_openjdk 7 -} - -function install_openjdk8() { - _install_openjdk 8 -} - -function install_java() { - local VERSION=$1 - - install_$VERSION - - [[ -e /usr/local/apache-maven/bin/mvn ]] || install_maven - [[ -e /usr/local/gradle-1.10 ]] || install_gradle - type ant &>/dev/null || apt-get install ant -} - - -function install_maven() { - echo '>>> Installing Maven' - - # Install Maven - MAVEN_VERSION=3.2.5 - curl -sSL -o /tmp/maven.tar.gz http://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz - tar -xz -C /usr/local -f /tmp/maven.tar.gz - ln -sf /usr/local/apache-maven-${MAVEN_VERSION} /usr/local/apache-maven - rm -rf /tmp/maven.tar.gz - - as_user mkdir -p ${CIRCLECI_HOME}/.m2 - - echo 'export M2_HOME=/usr/local/apache-maven' >> ${CIRCLECI_HOME}/.circlerc - echo 'export MAVEN_OPTS=-Xmx2048m' >> ${CIRCLECI_HOME}/.circlerc - echo 'export PATH=$M2_HOME/bin:$PATH' >> ${CIRCLECI_HOME}/.circlerc -} - -function install_gradle() { - echo '>>> Installing Gradle' - - GRADLE_VERSION=1.10 - URL=http://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip - - - curl -sSL -o /tmp/gradle.zip $URL - unzip -d /usr/local /tmp/gradle.zip - - echo 'export PATH=$PATH:/usr/local/gradle-1.10/bin' >> ${CIRCLECI_HOME}/.circlerc - rm -rf /tmp/gradle.zip -} diff --git a/circleci-provision-scripts/misc.sh b/circleci-provision-scripts/misc.sh deleted file mode 100755 index 32ce3df..0000000 --- a/circleci-provision-scripts/misc.sh +++ /dev/null @@ -1,119 +0,0 @@ -#/bin/bash - -function install_redis() { - apt-get install redis-server - # disable init.d script for redis - update-rc.d redis-server disable - rm /etc/init.d/redis-server - # manage redis with upsatart. needs to be explicitly started with 'sudo start redis-server' - printf 'description "redis server"\nstop on shutdown\nexec sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf\nrespawn' > /etc/init/redis-server.conf - # prevent redis-server from forking and daemonizing itself so upstart can respawn it - sed -i "s|daemonize yes|daemonize no|g" /etc/redis/redis.conf -} - -function install_memcached() { - apt-get install memcached libmemcache-dev -} - -function install_rabbitmq() { - apt-get install rabbitmq-server -} - -function install_beanstalkd() { - apt-get install beanstalkd -} - -function install_neo4j() { - # 2.3.3 is the last version that works with Java7 and later release needs Java8 - local version="2.3.3" - wget -O - http://debian.neo4j.org/neotechnology.gpg.key | apt-key add - - echo 'deb http://debian.neo4j.org/repo stable/' > /etc/apt/sources.list.d/neo4j.list - apt-get update - apt-get install neo4j=$version - - # Disable auth - sed -i "s|dbms.security.auth_enabled=true|dbms.security.auth_enabled=false|g" /etc/neo4j/neo4j-server.properties - - # Memory limitation - echo 'wrapper.java.maxmemory=1536' >> /etc/neo4j/neo4j-wrapper.conf -} - -function install_elasticsearch() { - local CONFIG_FILE=/etc/elasticsearch/elasticsearch.yml - - pushd tmp - wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.2.deb - dpkg -i elasticsearch-1.7.2.deb - popd - - echo 'index.number_of_shards: 1' >> $CONFIG_FILE - echo 'index.number_of_replicas: 0' >> $CONFIG_FILE - # Because Getting Permission Denied error - sudo sed -i 's/sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT/true/' /etc/init.d/elasticsearch -} - -function install_cassandra() { - local VERSION=34 - echo "deb http://www.apache.org/dist/cassandra/debian ${VERSION}x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list - - apt-get update - apt-get install cassandra - - # Supressing ulimit error because of the lack of permission - sed -i 's/ulimit/#ulimit/' /etc/init.d/cassandra - - # Putting resource restriction - sed -i 's/system_memory_in_mb=.*/system_memory_in_mb=2048/' /etc/cassandra/cassandra-env.sh - sed -i 's/system_cpu_cores=.*/system_cpu_cores=1/' /etc/cassandra/cassandra-env.sh - sed -i 's/JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}"/JVM_OPTS="$JVM_OPTS -Xms256M"/' /etc/cassandra/cassandra-env.sh -} - -function install_riak() { - local VERSION=2.1.3 - - curl -s https://packagecloud.io/install/repositories/basho/riak/script.deb.sh | sudo bash - sudo apt-get install riak=${VERSION}-1 -} - -function install_couchdb() { - add-apt-repository ppa:couchdb/stable - apt-get update - apt-get install couchdb -} - -function install_sysadmin() { - apt-get install htop -} - -function install_devtools() { - apt-get install $(tr '\n' ' ' <>>> Install Mongo $VERSION' - - # From http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ - - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 - echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/${MONGO_MAJOR} multiverse" \ - | tee /etc/apt/sources.list.d/mongodb-org-${MONGO_MAJOR}.list - apt-get update - - apt-get install -y \ - --no-install-recommends \ - ca-certificates curl \ - numactl \ - mongodb-org=$MONGO_VERSION \ - mongodb-org-server=$MONGO_VERSION \ - mongodb-org-shell=$MONGO_VERSION \ - mongodb-org-mongos=$MONGO_VERSION \ - mongodb-org-tools=$MONGO_VERSION - - rm -rf /var/lib/mongodb \ - mv /etc/mongod.conf /etc/mongod.conf.orig - - # Customize mongo more - echo 'noprealloc = true' >> /etc/mongod.conf - echo 'nojournal = true' >> /etc/mongod.conf - echo 'smallfiles = true' >> /etc/mongod.conf - - mkdir -p /data/db && chown -R mongodb:mongodb /data/db - - rm -rf /var/lib/mongodb/journal/prealloc.* - rm -rf /var/lib/mongodb/journal/j.* -} diff --git a/circleci-provision-scripts/mysql.sh b/circleci-provision-scripts/mysql.sh deleted file mode 100755 index 30718ad..0000000 --- a/circleci-provision-scripts/mysql.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -function configure_mysql() { - cat <> /etc/mysql/my.cnf -[client] -default-character-set=utf8 - -[mysql] -default-character-set=utf8 - - -[mysqld] -collation-server = utf8_unicode_ci -init-connect='SET NAMES utf8' -character-set-server = utf8 -innodb_flush_log_at_trx_commit=2 -sync_binlog=0 -innodb_use_native_aio=0 -EOF - - # start MySQL manually - sudo -u mysql mysqld & - MYSQL_PID=$! - sleep 5 - - ## Add users and such - echo "CREATE USER '${CIRCLECI_USER}'@'localhost'" | mysql -u root - echo "GRANT ALL PRIVILEGES ON *.* TO '${CIRCLECI_USER}'@'localhost' WITH GRANT OPTION" | mysql -u root - echo "CREATE USER 'circle'@'localhost'" | mysql -u root - echo "GRANT ALL PRIVILEGES ON *.* TO 'circle'@'localhost' WITH GRANT OPTION" | mysql -u root - echo "FLUSH PRIVILEGES" | mysql -u root - echo "CREATE DATABASE circle_test" | mysql -u root - - kill $MYSQL_PID -} - -function install_mysql_56() { - { - echo mysql-community-server mysql-community-server/data-dir select ''; - echo mysql-community-server mysql-community-server/root-pass password ''; - echo mysql-community-server mysql-community-server/re-root-pass password ''; - echo mysql-community-server mysql-community-server/remove-test-db select false; - } | debconf-set-selections - - DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server-5.6 libmysqld-dev - - configure_mysql -} - -function install_mysql_57() { - apt-key adv --keyserver pgp.mit.edu --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5 - - curl -LO http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb - - { - echo mysql-apt-config mysql-apt-config/unsupported-platform select abort - echo mysql-apt-config mysql-apt-config/repo-codename select trusty - echo mysql-apt-config mysql-apt-config/select-tools select - echo mysql-apt-config mysql-apt-config/repo-distro select ubuntu - echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 - echo mysql-apt-config mysql-apt-config/select-product select Apply - - echo mysql-community-server mysql-community-server/data-dir select ''; - echo mysql-community-server mysql-community-server/remove-test-db select false; - echo mysql-community-server mysql-community-server/re-root-pass password "" - echo mysql-community-server mysql-community-server/root-pass password "" - } | debconf-set-selections - - DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config_0.6.0-1_all.deb - - apt-get update - - apt-get -y install mysql-server libmysqld-dev - - # root password is set only for socket but not for network during the installation. - # See: https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/ - sudo -u mysql mysqld & - sleep 5 - mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';" - sleep 5 - pkill -9 mysqld - - configure_mysql -} diff --git a/circleci-provision-scripts/nodejs.sh b/circleci-provision-scripts/nodejs.sh deleted file mode 100755 index 6611df6..0000000 --- a/circleci-provision-scripts/nodejs.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash - -function install_nvm() { - echo '>>> Installing NodeJS NVM' - apt-get install build-essential libssl-dev make python g++ curl libssl-dev - - echo 'Install NVM' - (cat <<'EOF' -curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | NVM_DIR=$CIRCLECI_PKG_DIR/.nvm bash -echo "export NVM_DIR=$CIRCLECI_PKG_DIR/.nvm" >> ~/.circlerc -echo 'source $NVM_DIR/nvm.sh' >> ~/.circlerc -EOF - ) | as_user CIRCLECI_PKG_DIR=$CIRCLECI_PKG_DIR bash - - if [ -n "$USE_PRECOMPILE" ]; then - patch_nvm - - # Preparing for hooking up packaged NodeJS into nvm directories - (cat <<'EOF' -mkdir $CIRCLECI_PKG_DIR/nodejs -EOF - ) | as_user CIRCLECI_PKG_DIR=$CIRCLECI_PKG_DIR bash - fi -} - -function patch_nvm() { - # This is a kind of hack to prevent 'nvm is not compatible with the npm config "prefix" option' error - # when you run `nvm use vX.Y.Z`. We get this error because nvm expects nodejs to be installed under $NVM_DIR - # but we actually install under /opt/circleci/. - sed -i 's/NVM_DELETE_PREFIX=0/NVM_DELETE_PREFIX=1/' $CIRCLECI_PKG_DIR/.nvm/nvm.sh - - # We want nvm to install versions under $CIRCLECI_PKG_DIR/nodejs where we install precompiled nodejs - sed -i 's|\$NVM_DIR/versions/node|$CIRCLECI_PKG_DIR/nodejs|' $CIRCLECI_PKG_DIR/.nvm/nvm.sh - - # nvm uses sed to convert implicit version to explict version: e.g. 6 -> v6.1.1 - # https://github.com/creationix/nvm/blob/a55130627516519c21d9449b2daa773ae72325d2/nvm.sh#L767 - sed -i 's|\(s#^$NVM_DIR/##;\)|\1\ns#^\$CIRCLECI_PKG_DIR/nodejs/##;|' $CIRCLECI_PKG_DIR/.nvm/nvm.sh -} - -function install_yarn() { - local version=$1 - - (cat <>> Installing PhantomJS' - - local BIN=/usr/local/bin/phantomjs - - curl --output $BIN https://s3.amazonaws.com/circle-downloads/phantomjs-2.1.1 - chmod +x $BIN -} diff --git a/circleci-provision-scripts/php.sh b/circleci-provision-scripts/php.sh deleted file mode 100755 index 2c75bfd..0000000 --- a/circleci-provision-scripts/php.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash - -function install_phpenv(){ - PHP_TMP=/tmp/php - - apt-get install -y libpng12-dev re2c m4 libxslt1-dev libjpeg-dev libxml2-dev libtidy-dev libmcrypt-dev libreadline-dev libmagic-dev libssl-dev libcurl4-openssl-dev libfreetype6-dev libapache2-mod-php5 - - # bison 2.7 is the latest version that php supports - mkdir -p $PHP_TMP - curl -L -o $PHP_TMP/libbison-dev_2.7.1.dfsg-1_amd64.deb http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb - curl -L -o $PHP_TMP/bison_2.7.1.dfsg-1_amd64.deb http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb - dpkg -i $PHP_TMP/libbison-dev_2.7.1.dfsg-1_amd64.deb - dpkg -i $PHP_TMP/bison_2.7.1.dfsg-1_amd64.deb - - echo '>>> Installing php-env and php-build' - (cat <<'EOF' -# Because of https://github.com/phpenv/phpenv/issues/43 I can't install from git directly -curl -L https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh | bash -mv ~/.phpenv $CIRCLECI_PKG_DIR -git clone https://github.com/php-build/php-build.git $CIRCLECI_PKG_DIR/.phpenv/plugins/php-build -echo "export PHPENV_ROOT=$CIRCLECI_PKG_DIR/.phpenv" >> ~/.circlerc -echo 'export PATH=$PHPENV_ROOT/bin:$PATH' >> ~/.circlerc -echo 'eval "$(phpenv init -)"' >> ~/.circlerc -EOF - ) | as_user CIRCLECI_PKG_DIR=$CIRCLECI_PKG_DIR bash - - if [ -n "$USE_PRECOMPILE" ]; then - # Preparing for hooking up packaged Python into pyenv directories - (cat <<'EOF' -mkdir $CIRCLECI_PKG_DIR/php -ln -s $CIRCLECI_PKG_DIR/php $CIRCLECI_PKG_DIR/.phpenv/versions -EOF - ) | as_user CIRCLECI_PKG_DIR=$CIRCLECI_PKG_DIR bash - fi - - rm -rf $PHP_TMP -} - -function install_composer() { - curl -sS https://getcomposer.org/installer | /usr/bin/php - mv composer.phar /usr/local/bin/composer - chmod a+x /usr/local/bin/composer - echo 'export PATH=~/.composer/vendor/bin:$PATH' >> ${CIRCLECI_HOME}/.circlerc -} - -# Most PHP projects should use Composer and phpunit is installed under vendor/ directory -# so, this global phpunit shouldn't be needed but just in case. -# Note: the current version of phpunit only supports PHP 7, so if you are using PHP 5 -# this phpunit doesn't work -function install_phpunit() { - wget https://phar.phpunit.de/phpunit.phar - chmod +x phpunit.phar - mv phpunit.phar /usr/local/bin/phpunit -} - -function install_php_version_phpenv() { - PHP_VERSION=$1 - echo ">>> Installing php $PHP_VERSION" - - (cat <<'EOF' -source ~/.circlerc -phpenv install $PHP_VERSION -EOF - ) | as_user PHP_VERSION=$PHP_VERSION bash -} - -function install_php_version_precompile() { - local PHP_VERSION=$1 - echo ">>> Installing php $PHP_VERSION" - - maybe_run_apt_update - apt-get install circleci-php-$PHP_VERSION - chown -R $CIRCLECI_USER:$CIRCLECI_USER $CIRCLECI_PKG_DIR/php/$PHP_VERSION -} - -function install_php_version() { - local VERSION=$1 - - if [ -n "$USE_PRECOMPILE" ]; then - install_php_version_precompile $VERSION - else - install_php_version_phpenv $VERSION - fi -} - -function install_php() { - local VERSION=$1 - - [[ -e $CIRCLECI_PKG_DIR/.phpenv ]] || install_phpenv - type composer &>/dev/null || install_composer - type phpunit &>/dev/null || install_phpunit - install_php_version $VERSION -} diff --git a/circleci-provision-scripts/postgres.sh b/circleci-provision-scripts/postgres.sh deleted file mode 100755 index 931c937..0000000 --- a/circleci-provision-scripts/postgres.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash - -# Temporarly disable errexit to avoid a strange test error during make. -set +o errexit - -function disable_96() { - # Both Postgresql 9.5 and 9.6 were installed and running - # but running 9.6 is not done by intention. It's installed - # as dependecies of postgis. - # Running two versions of Postgresql made customers confused but we can't simply remove - # 9.6 because some customers already depend on it. - # So, we disable 9.6 by default but can be easilby enabled if necessary. - - # Postgresql startup script detects all version under it's directory, so we need to - # mv all 9.6 related stuff to different directories - mkdir /usr/lib/postgresql-9.6 - mkdir /etc/postgresql-9.6 - - mv /usr/lib/postgresql/9.6 /usr/lib/postgresql-9.6/9.6 - mv /etc/postgresql/9.6 /etc/postgresql-9.6/9.6 -} - -function install_postgres_ext_postgis() { - local VERSION=3.5.0 - local FILE=geos-${VERSION}.tar.bz2 - local DIR=geos-${VERSION} - local URL=http://download.osgeo.org/geos/${FILE} - - apt-get install ruby-dev swig swig2.0 postgis postgresql-9.5-postgis-2.2 - - # Install GEOS - pushd /tmp - wget $URL - tar -jxf $FILE - cd $DIR - ./configure --enable-ruby "--prefix=/usr" - - make &> "/tmp/goes.log" - make install - - popd - - rm -rf /tmp/$FILE /tmp/$DIR - - export VERSION=3.5.0 - export FILE=geos-${VERSION}.tar.bz2 - export DIR=geos-${VERSION} - export URL=http://download.osgeo.org/geos/${FILE} - - disable_96 -} - -function install_postgres() { - POSTGRES_VERSION=9.5 - - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - - - echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list - - apt-get update - apt-get install -y postgresql-$POSTGRES_VERSION postgresql-contrib-$POSTGRES_VERSION libpq-dev - - # Configure Postgres - - (cat <<'EOF' -listen_addresses = '*' - -# Pstgres 9.4 introduced some dynamic shared memory changes that are incompatible with containers -# Let us disable it for now: https://github.com/aptible/docker-postgresql/issues/14 -dynamic_shared_memory_type = none - -# Add settings for extensions here -# optimizations from http://rhaas.blogspot.com/2010/06/postgresql-as-in-memory-only-database_24.html -fsync=off -synchronous_commit=off -full_page_writes=off -bgwriter_lru_maxpages=0 - -EOF -) >> /etc/postgresql/$POSTGRES_VERSION/main/postgresql.conf - - - # Permissions - (cat <<'EOF' -local all all trust -host all all 127.0.0.1/32 trust -host all all ::1/128 trust - -# To allow for Docker connections -host all all 0.0.0.0/0 trust - -EOF - ) > /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf - - sudo service postgresql restart - - - # Create databases - sudo -u postgres psql -c "create role ${CIRCLECI_USER} with superuser login" - sudo -u postgres psql -c "create role root with superuser login" - sudo -u postgres createdb ${CIRCLECI_USER} - sudo -u postgres createdb circle_test - sudo -u postgres psql -c 'CREATE EXTENSION hstore;' ${CIRCLECI_USER} - sudo -u postgres psql -c 'CREATE EXTENSION hstore;' circle_test - - - # Allow password-less sudo to postgres user - echo "${CIRCLECI_USER} ALL=(postgres) NOPASSWD:ALL" > /etc/sudoers.d/10-postgres -} diff --git a/circleci-provision-scripts/python.sh b/circleci-provision-scripts/python.sh deleted file mode 100755 index 2aba510..0000000 --- a/circleci-provision-scripts/python.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash - -function install_pyenv() { - echo '>>> Installing Python' - - # FROM https://github.com/yyuu/pyenv/wiki/Common-build-problems - apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ - libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev - - # Installing system pip because sometimes our app uses `pyenv global system`. e.g. CodeDeploy - apt-get install python-pip - - echo 'Installing pyenv' - (cat <<'EOF' -git clone https://github.com/yyuu/pyenv.git $CIRCLECI_PKG_DIR/.pyenv -echo "export PYENV_ROOT=$CIRCLECI_PKG_DIR/.pyenv" >> ~/.circlerc -echo 'export PATH=$PYENV_ROOT/bin:$PATH' >> ~/.circlerc -echo 'eval "$(pyenv init -)"' >> ~/.circlerc -EOF - ) | as_user CIRCLECI_PKG_DIR=$CIRCLECI_PKG_DIR bash - - if [ -n "$USE_PRECOMPILE" ]; then - # Preparing for hooking up packaged Python into pyenv directories - (cat <<'EOF' -mkdir $CIRCLECI_PKG_DIR/python -ln -s $CIRCLECI_PKG_DIR/python $CIRCLECI_PKG_DIR/.pyenv/versions -EOF - ) | as_user CIRCLECI_PKG_DIR=$CIRCLECI_PKG_DIR bash - fi -} - -function install_python_version_pyenv() { - PYTHON_VERSION=$1 - (cat <<'EOF' -source ~/.circlerc -pyenv install $PYTHON_VERSION -pyenv global $PYTHON_VERSION -pyenv rehash -pip install -U virtualenv -pip install -U nose -pip install -U pep8 -EOF - ) | as_user PYTHON_VERSION=$PYTHON_VERSION bash -} - -function install_python_version_precompile() { - local PYTHON_VERSION=$1 - - maybe_run_apt_update - apt-get install circleci-python-$PYTHON_VERSION - chown -R $CIRCLECI_USER:$CIRCLECI_USER $CIRCLECI_PKG_DIR/python/$PYTHON_VERSION -} - -function set_python_default() { - local PYTHON_VERSION=$1 - (cat <<'EOF' -source ~/.circlerc -pyenv global $PYTHON_VERSION -pyenv rehash -EOF - ) | as_user PYTHON_VERSION=$PYTHON_VERSION bash -} - -function install_python_version() { - local VERSION=$1 - - if [ -n "$USE_PRECOMPILE" ]; then - install_python_version_precompile $VERSION - else - install_python_version_pyenv $VERSION - fi -} - -function install_python() { - local VERSION=$1 - [[ -e $CIRCLECI_PKG_DIR/.pyenv ]] || install_pyenv - install_python_version $1 -} diff --git a/circleci-provision-scripts/qt.sh b/circleci-provision-scripts/qt.sh deleted file mode 100755 index 901ba20..0000000 --- a/circleci-provision-scripts/qt.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -function install_qt() { - apt-get -y install qt5-default qt5-qmake qtbase5-dev libqt5webkit5-dev - - # Installing Qt 5.5 under /opt/qt55 to coexist with previous version - # To use qt 55, run - # - # source /opt/qt55/bin/qt55-env.sh - # - # To persist the version, run - # - # echo 'source /opt/qt55/bin/qt55-env.sh' >> ${CIRCLECI_HOME}/.circlerc - add-apt-repository -y ppa:beineri/opt-qt551-trusty - apt-get update - apt-get install qt55base qt55webkit -} diff --git a/circleci-provision-scripts/ruby.sh b/circleci-provision-scripts/ruby.sh deleted file mode 100755 index 336cf60..0000000 --- a/circleci-provision-scripts/ruby.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash - -function install_rvm() { - echo '>>> Installing RVM and Ruby' - - apt-get install libmagickwand-dev - - as_user gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 - curl -sSL https://get.rvm.io | as_user bash -s stable --path $CIRCLECI_PKG_DIR/.rvm - - echo "[[ -s '$CIRCLECI_PKG_DIR/.rvm/scripts/rvm' ]] && . $CIRCLECI_PKG_DIR/.rvm/scripts/rvm # Load RVM function" | as_user tee -a ${CIRCLECI_HOME}/.circlerc - - # Setting up user rmvrc - - (cat <<'EOF' -export rvm_gemset_create_on_use_flag=1 -export rvm_install_on_use_flag=1 -export rvm_trust_rvmrcs_flag=1 -export rvm_verify_downloads_flag=1 -EOF - ) | as_user tee ${CIRCLECI_HOME}/.rvmrc - - # Setting up default gemrc - (cat <<'EOF' -:sources: -- https://rubygems.org -gem: --no-ri --no-rdoc -EOF - ) | as_user tee ${CIRCLECI_HOME}/.gemrc - - (cat <<'EOF' -source ~/.circlerc -rvm rvmrc warning ignore allGemfiles -EOF - ) | as_user bash - - if [ -n "$USE_PRECOMPILE" ]; then - # Preparing for hooking up packaged Ruby into rvm directories - - (cat <<'EOF' -mkdir $CIRCLECI_PKG_DIR/ruby -rm -r $CIRCLECI_PKG_DIR/.rvm/rubies -ln -s $CIRCLECI_PKG_DIR/ruby $CIRCLECI_PKG_DIR/.rvm/rubies -EOF - ) | as_user CIRCLECI_PKG_DIR=$CIRCLECI_PKG_DIR bash - fi - - # Make sure bundler is installed in all versions - (cat <<'EOF' -source ~/.circlerc -echo 'bundler' >> $rvm_path/gemsets/default.gems -EOF - ) | as_user bash -} - -function install_ruby_version_rvm() { - INSTALL_RUBY_VERSION=$1 - RUBYGEMS_MAJOR_RUBY_VERSION=${2:-2} - (cat <<'EOF' -echo Installing Ruby version: $INSTALL_RUBY_VERSION -source ~/.circlerc -rvm use $INSTALL_RUBY_VERSION -# TODO: Avoid this for jruby -rvm rubygems latest-${RUBYGEMS_MAJOR_RUBY_VERSION} -rvm @global do gem install bundler -v 1.9.5 -# For projects without gemfiles -rvm @global do gem install rspec -EOF - ) | as_user INSTALL_RUBY_VERSION=$INSTALL_RUBY_VERSION RUBYGEMS_MAJOR_RUBY_VERSION=$RUBYGEMS_MAJOR_RUBY_VERSION bash -} - -function install_ruby_version_precompile() { - local INSTALL_RUBY_VERSION=$1 - local GEM_VERSION="2.6.11" - local BUNDLER_VERSION="1.14.6" - echo ">>> Installing Ruby $INSTALL_RUBY_VERSION" - - maybe_run_apt_update - apt-get install circleci-ruby-$INSTALL_RUBY_VERSION - chown -R $CIRCLECI_USER:$CIRCLECI_USER $CIRCLECI_PKG_DIR/ruby/ruby-$INSTALL_RUBY_VERSION - - (cat <<'EOF' -echo Installing Ruby version: $INSTALL_RUBY_VERSION -source ~/.circlerc -rvm use $INSTALL_RUBY_VERSION -gem install rubygems-update -v "~> $GEM_VERSION" && gem update --system -gem uninstall bundler --all -gem install bundler -v "~> $BUNDLER_VERSION" -EOF - ) | as_user INSTALL_RUBY_VERSION=$INSTALL_RUBY_VERSION GEM_VERSION=$GEM_VERSION BUNDLER_VERSION=$BUNDLER_VERSION bash -} - -function install_ruby_version() { - local VERSION=$1 - - if [ -n "$USE_PRECOMPILE" ]; then - install_ruby_version_precompile $VERSION - else - install_ruby_version_rvm $VERSION - fi -} - -function install_ruby() { - local VERSION=$1 - - [[ -e $CIRCLECI_PKG_DIR/.rvm ]] || install_rvm - install_ruby_version $VERSION -} diff --git a/circleci-provision-scripts/scala.sh b/circleci-provision-scripts/scala.sh deleted file mode 100755 index 61f3bc1..0000000 --- a/circleci-provision-scripts/scala.sh +++ /dev/null @@ -1,26 +0,0 @@ -function install_scala() { - - wget https://dl.bintray.com/sbt/debian/sbt-0.13.9.deb - dpkg -i sbt-0.13.9.deb - rm sbt-0.13.9.deb - - (cat <<'EOF' -# Run sbt once to download dependencies. -# SBT_OPTS="-XX:MaxMetaspaceSize=384M" sbt -v -SBT_LAUNCH_VERSIONS="0.13.5 0.13.6 0.13.7 0.13.8 0.13.9 0.13.10 0.13.11 0.13.12 0.13.13 0.13.14 0.13.15" -for VER in $(echo $SBT_LAUNCH_VERSIONS); do - -SBT_DIR=~/.sbt/.lib/${VER} -SBT_JAR=$SBT_DIR/sbt-launch.jar -SBT_URL="http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/${VER}/sbt-launch.jar" - -mkdir -p $SBT_DIR -curl -L -o $SBT_JAR $SBT_URL - -done -EOF - ) | as_user bash -} - -## TODO -# ) | as_user SBT_LAUNCH_VERSIONS="${SBT_LAUNCH_VERSIONS}" bash diff --git a/circleci-provision-scripts/sqlite.sh b/circleci-provision-scripts/sqlite.sh deleted file mode 100644 index 9d9b326..0000000 --- a/circleci-provision-scripts/sqlite.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -function install_sqlite3_15() { - local version="linux-x86-3150200" - local package="sqlite-tools-${version}.zip" - local bin_path="/usr/local/bin/sqlite3-15" - - pushd /tmp - curl -o sqlite3.zip http://www.sqlite.org/2016/$package - unzip sqlite3.zip - cd sqlite-tools-${version} - cp sqlite3 $bin_path - chmod +x $bin_path - rm ../sqlite3.zip - popd -} diff --git a/docker-export b/docker-export deleted file mode 100755 index 5594ef3..0000000 --- a/docker-export +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - - -set -e - -echoerr() { echo "$@" 1>&2; } - -function usage() { - echoerr "Utility for exporting Docker container filesystems" - echoerr "Usage: $0 > tarball.tar.gz" - echoerr " e.g. $0 test-container:0.0.1 > test-container_0.0.1.tar.gz" - exit 1 -} - -if [ $# -ne 1 ] -then - echoerr 'Missing docker image name' - usage -fi - -[ ! -t 1 ] || { - echoerr 'missing file redirection. Refusing to pipe to terminal' - usage -} - -IMAGE_ID=$1 - -( - docker run --rm=true "${IMAGE_ID}" \ - tar --create --gzip --one-file-system \ - --exclude='/tmp/*' --exclude='.dockerinit' --exclude='.dockerenv' \ - --transform 's|^|rootfs/|S' \ - -f - / /dev -) -echoerr "Image exported: ${IMAGE_ID}" -exit 0 diff --git a/scripts/circle-android b/scripts/circle-android deleted file mode 100755 index c415ac5..0000000 --- a/scripts/circle-android +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -spinstr='|/-\' -spin_index=0 - -spin_until () { - while ! $@ - do - spin_index=$(expr $(expr $spin_index + 1) % 4) - printf "\r${spinstr:spin_index:1}" - sleep 0.5 - done - printf "\r" -} - -adb_shell_getprop () { - adb shell getprop $1 | tr -d [:space:] # delete the whitespace -} - -device_actually_ready () { - # https://devmaze.wordpress.com/2011/12/12/starting-and-stopping-android-emulators/ - [ "$(adb_shell_getprop init.svc.bootanim)" = "stopped" ] -} - -if [ "$1" == "wait-for-boot" ] -then - # wait for the device to respond to shell commands - spin_until adb shell true 2> /dev/null - # wait for the emulator to be completely finished booting. - # adb wait-for-device is not sufficient for this. - spin_until device_actually_ready -else - echo "$0, a collection of tools for CI with android." - echo "" - echo "Usage:" - echo " $0 wait-for-boot - wait for a device to fully boot." - echo " (adb wait-for-device only waits for it to be ready for shell access)." -fi - diff --git a/scripts/release-LXC-container b/scripts/release-LXC-container deleted file mode 100755 index 5602c2a..0000000 --- a/scripts/release-LXC-container +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -## This is an internal script for releasing an image created with image-builder -## as an LXC images for customers using the LXC based version of CCIE. -## If you are building a custom image, you can simple use docker-export and -## upload the image to any url accessible from your builder machine. - -function usage { - echo "Usage: $0 [--region ]" - exit 1 -} - -if ! [ $# -eq 2 ] -then - if ! ([ $# -eq 4 ] && [ $3 == "--region" ]) - then - usage - exit 1 - fi -fi - -NAME=$1 -FILE=$2 -CHOSEN_REGION=$4 - -ROOT_DIR="$(git rev-parse --show-toplevel)" - -MAIN_REGION=us-east-1 - -OTHER_SUPPORTED_REGIONS=( - ap-northeast-1 - ap-northeast-2 - ap-southeast-1 - ap-southeast-2 - eu-central-1 - eu-west-1 - sa-east-1 - us-west-1 - us-west-2 -) - -function retry { - n=$1 - shift - for i in $(seq $n); do - "$@" && break - echo retrying "$@" ... - done -} - -function s3_url { - REGION=$1 - echo "s3://circleci-enterprise-assets-$REGION/containers/$NAME.tar.gz" -} - -function publish_container { - REGION=$1 - echo publishing container to $REGION - retry 3 \ - aws s3 cp $FILE $(s3_url $REGION) \ - --acl public-read \ - --region $REGION - echo done publishing container to $REGION -} - -function copy_container { - SRC_REGION=$1 - DEST_REGION=$2 - retry 3 \ - aws s3 cp $(s3_url $SRC_REGION) $(s3_url $DEST_REGION) \ - --acl public-read \ - --source-region $SRC_REGION \ - --region $DEST_REGION -} - -if [[ -n $CHOSEN_REGION ]] -then - publish_container $CHOSEN_REGION -else - publish_container $MAIN_REGION - echo copying container to the following regions: - for REGION in ${OTHER_SUPPORTED_REGIONS[@]} - do - echo $REGION - copy_container $MAIN_REGION $REGION & - sleep 0.1 - done - - echo waiting on all containers - wait - echo done copying all containers -fi diff --git a/scripts/wait-for-cassandra.sh b/scripts/wait-for-cassandra.sh deleted file mode 100755 index d16e4e6..0000000 --- a/scripts/wait-for-cassandra.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -echo "describe cluster;" > /tmp/dc -for i in 1 2 3 4 5; do - echo Attempt $i - if nodetool status | grep "^UN"; then - exit 0 - else - sleep 10 - fi -done - -echo "" -echo "Cassandra failed to start!!" -echo "" -echo "------ Cassandra info -------" -bash -x -c "ps ax | grep -i cassandra" -bash -x -c "sudo lsof -i4TCP:9042" -echo "" -exit 1 diff --git a/targets/ubuntu-14.04-XL/Dockerfile b/targets/ubuntu-14.04-XL/Dockerfile deleted file mode 100644 index eea7109..0000000 --- a/targets/ubuntu-14.04-XL/Dockerfile +++ /dev/null @@ -1,125 +0,0 @@ -FROM circleci/ubuntu-server:trusty-latest - -ENV VERBOSE true - -ADD circleci-install /usr/local/bin/circleci-install -ADD circleci-provision-scripts/base.sh circleci-provision-scripts/circleci-specific.sh /opt/circleci-provision-scripts/ -RUN circleci-install base_requirements && circleci-install circleci_specific - -# Installing java early beacuse a few things have the dependency to java (i.g. cassandra) -ADD circleci-provision-scripts/java.sh /opt/circleci-provision-scripts/java.sh -RUN circleci-install java oraclejdk8 && circleci-install java openjdk8 - -# Browsers -ADD circleci-provision-scripts/firefox.sh circleci-provision-scripts/chrome.sh circleci-provision-scripts/phantomjs.sh /opt/circleci-provision-scripts/ -RUN circleci-install firefox && circleci-install chrome && circleci-install phantomjs - -# Android -# Android -ADD circleci-provision-scripts/android-sdk.sh /opt/circleci-provision-scripts/android-sdk.sh -RUN circleci-install android_sdk platform-tools -RUN circleci-install android_sdk extra-android-support -RUN for package in android-25 android-24 android-23 android-22; do circleci-install android_sdk $package; done -RUN for package in sys-img-armeabi-v7a-android-24 sys-img-armeabi-v7a-android-22; do circleci-install android_sdk $package; done -RUN for package in build-tools-25.0.1 build-tools-25.0.0 build-tools-24.0.3 build-tools-24.0.2 build-tools-24.0.1 build-tools-24.0.0 build-tools-23.0.3 build-tools-23.0.2 build-tools-22.0.1; do circleci-install android_sdk $package; done -RUN for package in android_sdk extra-android-m2repository android_sdk extra-google-m2repository android_sdk extra-google-google_play_services android_sdk addon-google_apis-google-23 android_sdk addon-google_apis-google-22; do circleci-install android_sdk $package; done - -# Qt -ADD circleci-provision-scripts/qt.sh /opt/circleci-provision-scripts/qt.sh -RUN circleci-install qt - -# Install deployment tools -ADD circleci-provision-scripts/awscli.sh circleci-provision-scripts/gcloud.sh circleci-provision-scripts/heroku.sh /opt/circleci-provision-scripts/ -RUN for package in awscli gcloud heroku; do circleci-install $package; done - -# Languages -ARG use_precompile=true -ENV USE_PRECOMPILE=$use_precompile RUN_APT_UPDATE=true -RUN curl -s https://packagecloud.io/install/repositories/circleci/trusty/script.deb.sh | sudo bash -ADD circleci-provision-scripts/python.sh /opt/circleci-provision-scripts/python.sh -RUN circleci-install python 2.7.10 -RUN circleci-install python 2.7.11 -RUN circleci-install python 2.7.12 -RUN circleci-install python 3.1.4 -RUN circleci-install python 3.1.5 -RUN circleci-install python 3.2.5 -RUN circleci-install python 3.2.6 -RUN circleci-install python 3.3.5 -RUN circleci-install python 3.3.6 -RUN circleci-install python 3.4.3 -RUN circleci-install python 3.4.4 -RUN circleci-install python 3.5.1 -RUN circleci-install python 3.5.2 -RUN circleci-install python pypy-1.9 -RUN circleci-install python pypy-2.6.1 -RUN circleci-install python pypy-4.0.1 -RUN sudo -H -i -u ubuntu pyenv global 2.7.11 - -ADD circleci-provision-scripts/nodejs.sh /opt/circleci-provision-scripts/nodejs.sh -RUN circleci-install nodejs 0.12.9 -RUN circleci-install nodejs 4.0.0 -RUN circleci-install nodejs 4.1.2 -RUN circleci-install nodejs 4.2.6 -RUN circleci-install nodejs 4.3.0 -RUN circleci-install nodejs 4.5.0 -RUN circleci-install nodejs 5.0.0 -RUN circleci-install nodejs 5.1.1 -RUN circleci-install nodejs 5.2.0 -RUN circleci-install nodejs 5.3.0 -RUN circleci-install nodejs 5.4.1 -RUN circleci-install nodejs 5.5.0 -RUN circleci-install nodejs 5.6.0 -RUN circleci-install nodejs 5.7.0 -RUN circleci-install nodejs 6.1.0 -RUN sudo -H -i -u ubuntu nvm alias default 4.2.6 - -ADD circleci-provision-scripts/go.sh /opt/circleci-provision-scripts/go.sh -RUN circleci-install golang 1.6.2 - -ADD circleci-provision-scripts/ruby.sh /opt/circleci-provision-scripts/ruby.sh -RUN circleci-install ruby 2.1.8 -RUN circleci-install ruby 2.1.9 -RUN circleci-install ruby 2.2.4 -RUN circleci-install ruby 2.2.5 -RUN circleci-install ruby 2.3.0 -RUN circleci-install ruby 2.3.1 -RUN sudo -H -i -u ubuntu rvm use 2.2.4 --default - -ADD circleci-provision-scripts/php.sh /opt/circleci-provision-scripts/php.sh -RUN circleci-install php 5.5.31 -RUN circleci-install php 5.5.32 -RUN circleci-install php 5.5.36 -RUN circleci-install php 5.6.17 -RUN circleci-install php 5.6.18 -RUN circleci-install php 5.6.22 -RUN circleci-install php 7.0.4 -RUN circleci-install php 7.0.7 -RUN circleci-install php 7.0.11 -RUN circleci-install php 7.1.0 -RUN sudo -H -i -u ubuntu phpenv global 5.6.17 - -ADD circleci-provision-scripts/clojure.sh /opt/circleci-provision-scripts/clojure.sh -RUN circleci-install clojure - -ADD circleci-provision-scripts/scala.sh /opt/circleci-provision-scripts/scala.sh -RUN circleci-install scala - -ADD circleci-provision-scripts/haskell.sh /opt/circleci-provision-scripts/haskell.sh -RUN circleci-install ghc 8.0.1 - -# Add rest of provisioning files -- add at end to avoid cache invalidation -ADD circleci-provision-scripts /opt/circleci-provision-scripts - -# We need Dockerfile because unit test parses Dockerfile to make sure all versions are installed -ADD targets/ubuntu-14.04-XL/Dockerfile /opt/circleci/Dockerfile - -ARG IMAGE_TAG -RUN echo $IMAGE_TAG > /opt/circleci/image_version - -ADD targets/ubuntu-14.04-XL/pkg-versions.sh /opt/circleci/bin/pkg-versions.sh - -USER ubuntu - -CMD ["/bin/bash"] - -LABEL circleci.user="ubuntu" diff --git a/targets/ubuntu-14.04-XL/pkg-versions.sh b/targets/ubuntu-14.04-XL/pkg-versions.sh deleted file mode 100755 index ac6449f..0000000 --- a/targets/ubuntu-14.04-XL/pkg-versions.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash - -col() { - c=$1 - cut -d ' ' -f ${c} -} - -quotify() { - cat - | sed -e s/^/\"/ | sed s/$/\"/ -} - -commatize() { - cat - | sed -e s/$/\,/ -} - -flatten() { - cat - | tr "\n" " " -} - -trailing_last_comma() { - cat - | sed -e '$ s/,\s*$//g' -} - -all_ruby() { - ls $CIRCLECI_PKG_DIR/ruby/ | grep -v default | quotify | commatize | flatten | trailing_last_comma -} - -all_python() { - ls $CIRCLECI_PKG_DIR/python/ | quotify | commatize | flatten | trailing_last_comma -} - -all_nodejs() { - ls $CIRCLECI_PKG_DIR/nodejs/ | quotify | commatize | flatten | trailing_last_comma -} - -all_php() { - ls $CIRCLECI_PKG_DIR/php/ | quotify | commatize | flatten | trailing_last_comma -} - -all_java() { - # Exclude symbolic links - ls -l /usr/lib/jvm | grep -v -- "->" | grep -v total | awk '{print $9}' | quotify | commatize | flatten | trailing_last_comma -} - -all_ghc() { - ls /opt/ghc/ | quotify | commatize | flatten | trailing_last_comma -} - -all_sbt() { - ls /home/ubuntu/.sbt/.lib/ | quotify | commatize | flatten | trailing_last_comma -} - -cat<&1 | col 2)", - "all": [ - $(all_python) - ], - "pip": "$(pip --version | col 2)", - "virtualenv": "$(virtualenv --version)" - }, - "nodejs": { - "default": "$(node --version | head -1 | sed 's/^v//')", - "all": [ - $(all_nodejs) - ], - "npm": "$(npm --version)", - "nvm": "$(. $CIRCLECI_PKG_DIR/.nvm/nvm.sh && nvm --version)" - }, - "php": { - "default": "$(php --version | head -1 | col 2)", - "all": [ - $(all_php) - ] - }, - "java": { - "default": "$(java -version 2>&1 | head -1 | col 3 | sed 's/"//g')", - "all": [ - $(all_java) - ] - }, - "clojure": { - "lein": "$(lein --version | col 2)" - }, - "haskell": { - "all": [ - $(all_ghc) - ], - "cabal": "$(cabal --version | head -1 | col 3)", - "alex": "$(alex --version | col 3 | trailing_last_comma)", - "happy": "$(happy --version | head -1 | col 3)" - }, - "scala": { - "all": [ - $(all_sbt) - ] - }, - "git": "$(git --version | col 3)", - "gcc": "$(gcc --version | head -n1 | col 4)", - "g++": "$(g++ --version | head -n1 | col 4)", - "cc": "$(cc --version | head -1 | col 4)", - "c++": "$(c++ --version | head -1 | col 4)", - "make": "$(make --version | head -1 | col 3)", - "maven": "$(mvn --version | head -1 | col 3)", - "ant": "$(ant -version | col 4)", - "go": "$(go version | col 3 | sed 's/^go//')", - "gradle": "$(gradle --version | grep Gradle | col 2)", - "phantomjs": "$(phantomjs --version)", - "heroku-toolbelt": "$(heroku version | grep toolbelt | col 1 | sed 's|.*/||')", - "gcloud": "$(/opt/google-cloud-sdk/bin/gcloud version | grep "Google Cloud SDK" | col 4)", - "aws-cli": "$(aws --version 2>&1 | col 1 | sed 's|.*/||')", - "android": { - "build-tool": "$(grep 'Pkg.Revision=' $ANDROID_HOME/tools/source.properties | sed 's/Pkg.Revision=//')", - "build-tools": [ - $(ls $ANDROID_HOME/build-tools | quotify | commatize | trailing_last_comma) - ], - "platforms": [ - $(ls $ANDROID_HOME/platforms | quotify | commatize | trailing_last_comma) - ], - "emulator-images": [ - $(ls $ANDROID_HOME/system-images/ | sed 's/android/sys-img-armeabi-v7-android/g' | quotify | commatize | trailing_last_comma) - ], - "add-ons": [ - $(ls $ANDROID_HOME/add-ons | quotify | commatize | trailing_last_comma) - ], - "android-extra": [ - $(ls $ANDROID_HOME/extras/android | quotify | commatize | trailing_last_comma) - ], - "google-extra": [ - $(ls $ANDROID_HOME/extras/google | quotify | commatize | trailing_last_comma) - ] - } - }, - "all": { - $(dpkg -l | grep -e '^ii' | awk '{printf "\"%s\": \"%s\",\n", $2,$3}' | trailing_last_comma) - } -} -EOF diff --git a/targets/ubuntu-14.04-XXL-enterprise/Dockerfile b/targets/ubuntu-14.04-XXL-enterprise/Dockerfile deleted file mode 100644 index b58f244..0000000 --- a/targets/ubuntu-14.04-XXL-enterprise/Dockerfile +++ /dev/null @@ -1,145 +0,0 @@ -FROM circleci/ubuntu-server:trusty-latest - -ENV VERBOSE true - -# Avoid any installation scripts interact with upstart -# So divert now, but undivert at the end -# You shouldn't change the line unless you understand the consequence -RUN echo 'exit 101' > /usr/sbin/policy-rc.d \ - && chmod +x /usr/sbin/policy-rc.d \ - && dpkg-divert --local --rename --add /sbin/initctl \ - && ln -s /bin/true /sbin/initctl - -ADD circleci-install /usr/local/bin/circleci-install -ADD circleci-provision-scripts/base.sh circleci-provision-scripts/circleci-specific.sh /opt/circleci-provision-scripts/ -RUN circleci-install base_requirements && circleci-install circleci_specific - -# Databases -ADD circleci-provision-scripts/mysql.sh circleci-provision-scripts/mongo.sh circleci-provision-scripts/postgres.sh /opt/circleci-provision-scripts/ -RUN for package in mysql_57 mongo postgres postgres_ext_postgis; do circleci-install $package; done - -# Installing java early beacuse a few things have the dependency to java (i.g. cassandra) -ADD circleci-provision-scripts/java.sh /opt/circleci-provision-scripts/java.sh -RUN circleci-install java oraclejdk8 && circleci-install java openjdk8 - -ADD circleci-provision-scripts/misc.sh /opt/circleci-provision-scripts/misc.sh -RUN for package in sysadmin devtools jq redis memcached rabbitmq neo4j elasticsearch beanstalkd cassandra riak couchdb; do circleci-install $package; done - -# Dislabe services by default -RUN for s in apache2 memcached rabbitmq-server neo4j neo4j-service elasticsearch beanstalkd cassandra riak couchdb; do sysv-rc-conf $s off; done - -# Browsers -ADD circleci-provision-scripts/firefox.sh circleci-provision-scripts/chrome.sh circleci-provision-scripts/phantomjs.sh /opt/circleci-provision-scripts/ -RUN circleci-install firefox && circleci-install chrome && circleci-install phantomjs - -# Android -ADD circleci-provision-scripts/android-sdk.sh /opt/circleci-provision-scripts/android-sdk.sh -RUN circleci-install android_sdk platform-tools -RUN circleci-install android_sdk extra-android-support -RUN for package in android-25 android-24 android-23 android-22; do circleci-install android_sdk $package; done -RUN for package in sys-img-armeabi-v7a-android-24 sys-img-armeabi-v7a-android-22; do circleci-install android_sdk $package; done -RUN for package in build-tools-25.0.1 build-tools-25.0.0 build-tools-24.0.3 build-tools-24.0.2 build-tools-24.0.1 build-tools-24.0.0 build-tools-23.0.3 build-tools-23.0.2 build-tools-22.0.1; do circleci-install android_sdk $package; done -RUN for package in android_sdk extra-android-m2repository android_sdk extra-google-m2repository android_sdk extra-google-google_play_services android_sdk addon-google_apis-google-23 android_sdk addon-google_apis-google-22; do circleci-install android_sdk $package; done - -# Qt -ADD circleci-provision-scripts/qt.sh /opt/circleci-provision-scripts/qt.sh -RUN circleci-install qt - -# Install deployment tools -ADD circleci-provision-scripts/awscli.sh circleci-provision-scripts/gcloud.sh circleci-provision-scripts/heroku.sh /opt/circleci-provision-scripts/ -RUN for package in awscli gcloud heroku; do circleci-install $package; done - -# Languages -ARG use_precompile=true -ENV USE_PRECOMPILE=$use_precompile RUN_APT_UPDATE=true -RUN curl -s https://packagecloud.io/install/repositories/circleci/trusty/script.deb.sh | sudo bash -ADD circleci-provision-scripts/python.sh /opt/circleci-provision-scripts/python.sh -RUN circleci-install python 2.7.10 -RUN circleci-install python 2.7.11 -RUN circleci-install python 2.7.12 -RUN circleci-install python 3.1.4 -RUN circleci-install python 3.1.5 -RUN circleci-install python 3.2.5 -RUN circleci-install python 3.2.6 -RUN circleci-install python 3.3.5 -RUN circleci-install python 3.3.6 -RUN circleci-install python 3.4.3 -RUN circleci-install python 3.4.4 -RUN circleci-install python 3.5.1 -RUN circleci-install python 3.5.2 -RUN circleci-install python pypy-1.9 -RUN circleci-install python pypy-2.6.1 -RUN circleci-install python pypy-4.0.1 -RUN sudo -H -i -u ubuntu pyenv global 2.7.11 - -ADD circleci-provision-scripts/nodejs.sh /opt/circleci-provision-scripts/nodejs.sh -RUN circleci-install nodejs 0.12.9 -RUN circleci-install nodejs 4.0.0 -RUN circleci-install nodejs 4.1.2 -RUN circleci-install nodejs 4.2.6 -RUN circleci-install nodejs 4.3.0 -RUN circleci-install nodejs 4.5.0 -RUN circleci-install nodejs 5.0.0 -RUN circleci-install nodejs 5.1.1 -RUN circleci-install nodejs 5.2.0 -RUN circleci-install nodejs 5.3.0 -RUN circleci-install nodejs 5.4.1 -RUN circleci-install nodejs 5.5.0 -RUN circleci-install nodejs 5.6.0 -RUN circleci-install nodejs 5.7.0 -RUN circleci-install nodejs 6.1.0 -RUN sudo -H -i -u ubuntu nvm alias default 4.2.6 - -ADD circleci-provision-scripts/go.sh /opt/circleci-provision-scripts/go.sh -RUN circleci-install golang 1.6.2 - -ADD circleci-provision-scripts/ruby.sh /opt/circleci-provision-scripts/ruby.sh -RUN circleci-install ruby 2.1.8 -RUN circleci-install ruby 2.1.9 -RUN circleci-install ruby 2.2.4 -RUN circleci-install ruby 2.2.5 -RUN circleci-install ruby 2.3.0 -RUN circleci-install ruby 2.3.1 -RUN sudo -H -i -u ubuntu rvm use 2.2.4 --default - -ADD circleci-provision-scripts/php.sh /opt/circleci-provision-scripts/php.sh -RUN circleci-install php 5.5.31 -RUN circleci-install php 5.5.32 -RUN circleci-install php 5.5.36 -RUN circleci-install php 5.6.17 -RUN circleci-install php 5.6.18 -RUN circleci-install php 5.6.22 -RUN circleci-install php 7.0.4 -RUN circleci-install php 7.0.7 -RUN circleci-install php 7.0.11 -RUN circleci-install php 7.1.0 -RUN sudo -H -i -u ubuntu phpenv global 5.6.17 - -ADD circleci-provision-scripts/clojure.sh /opt/circleci-provision-scripts/clojure.sh -RUN circleci-install clojure - -ADD circleci-provision-scripts/scala.sh /opt/circleci-provision-scripts/scala.sh -RUN circleci-install scala - -ADD circleci-provision-scripts/haskell.sh /opt/circleci-provision-scripts/haskell.sh -RUN circleci-install ghc 8.0.1 - -ADD circleci-provision-scripts/docker.sh /opt/circleci-provision-scripts/docker.sh -RUN circleci-install docker && circleci-install docker_compose - -# Undivert upstart -# You shouldn't change the line unless you understad the consequence -RUN rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl - -# Add rest of provisioning files -- add at end to avoid cache invalidation -ADD circleci-provision-scripts /opt/circleci-provision-scripts - -# We need Dockerfile because unit test parses Dockerfile to make sure all versions are installed -ADD targets/ubuntu-14.04-XXL-enterprise/Dockerfile /opt/circleci/Dockerfile - -ARG IMAGE_TAG -RUN echo $IMAGE_TAG > /opt/circleci/image_version - -ADD targets/ubuntu-14.04-XXL-enterprise/pkg-versions.sh /opt/circleci/bin/pkg-versions.sh - -LABEL circleci.user="ubuntu" diff --git a/targets/ubuntu-14.04-XXL-enterprise/pkg-versions.sh b/targets/ubuntu-14.04-XXL-enterprise/pkg-versions.sh deleted file mode 100755 index 60bd29f..0000000 --- a/targets/ubuntu-14.04-XXL-enterprise/pkg-versions.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/bash - -col() { - c=$1 - cut -d ' ' -f ${c} -} - -quotify() { - cat - | sed -e s/^/\"/ | sed s/$/\"/ -} - -commatize() { - cat - | sed -e s/$/\,/ -} - -flatten() { - cat - | tr "\n" " " -} - -trailing_last_comma() { - cat - | sed -e '$ s/,\s*$//g' -} - -all_ruby() { - ls $CIRCLECI_PKG_DIR/ruby/ | grep -v default | quotify | commatize | flatten | trailing_last_comma -} - -all_python() { - ls $CIRCLECI_PKG_DIR/python/ | quotify | commatize | flatten | trailing_last_comma -} - -all_nodejs() { - ls $CIRCLECI_PKG_DIR/nodejs/ | quotify | commatize | flatten | trailing_last_comma -} - -all_php() { - ls $CIRCLECI_PKG_DIR/php/ | quotify | commatize | flatten | trailing_last_comma -} - -all_java() { - # Exclude symbolic links - ls -l /usr/lib/jvm | grep -v -- "->" | grep -v total | awk '{print $9}' | quotify | commatize | flatten | trailing_last_comma -} - -all_ghc() { - ls /opt/ghc/ | quotify | commatize | flatten | trailing_last_comma -} - -all_sbt() { - ls /home/ubuntu/.sbt/.lib/ | quotify | commatize | flatten | trailing_last_comma -} - -cat<&1 | col 2)", - "all": [ - $(all_python) - ], - "pip": "$(pip --version | col 2)", - "virtualenv": "$(virtualenv --version)" - }, - "nodejs": { - "default": "$(node --version | head -1 | sed 's/^v//')", - "all": [ - $(all_nodejs) - ], - "npm": "$(npm --version)", - "nvm": "$(. $CIRCLECI_PKG_DIR/.nvm/nvm.sh && nvm --version)" - }, - "php": { - "default": "$(php --version | head -1 | col 2)", - "all": [ - $(all_php) - ] - }, - "java": { - "default": "$(java -version 2>&1 | head -1 | col 3 | sed 's/"//g')", - "all": [ - $(all_java) - ] - }, - "clojure": { - "lein": "$(lein --version | col 2)" - }, - "haskell": { - "all": [ - $(all_ghc) - ], - "cabal": "$(cabal --version | head -1 | col 3)", - "alex": "$(alex --version | col 3 | trailing_last_comma)", - "happy": "$(happy --version | head -1 | col 3)" - }, - "scala": { - "all": [ - $(all_sbt) - ] - }, - "redis": "$(redis-server --version | col 3 | sed 's/^v=//')", - "memcached": "$(memcached -h | head -1 | col 2)", - "git": "$(git --version | col 3)", - "gcc": "$(gcc --version | head -n1 | col 4)", - "g++": "$(g++ --version | head -n1 | col 4)", - "cc": "$(cc --version | head -1 | col 4)", - "c++": "$(c++ --version | head -1 | col 4)", - "make": "$(make --version | head -1 | col 3)", - "maven": "$(mvn --version | head -1 | col 3)", - "ant": "$(ant -version | col 4)", - "apache2": "$(apache2 -version | grep 'Server version' | col 3 | cut -d '/' -f 2)", - "beanstalkd": "$(beanstalkd -v | col 2)", - "cassandra": "$(cassandra -v | tail -1)", - "elasticsearch": "$(/usr/share/elasticsearch/bin/elasticsearch -v | col 2 | sed 's/,//g')", - "neo4j": "$(neo4j-shell --version | col 4)", - "riak": "$(riak version)", - "memcached": "$(memcached -h | head -1 | col 2)", - "couchdb": "$(couchdb -V | head -1 | col 5)", - "geos": "$(geos-config --version)", - "go": "$(go version | col 3 | sed 's/^go//')", - "gradle": "$(gradle --version | grep Gradle | col 2)", - "phantomjs": "$(phantomjs --version)", - "docker": "$(docker --version | col 3 | sed 's/-circleci.*//')", - "docker-compose": "$(docker-compose --version | col 3 | sed 's/,//g')", - "heroku-toolbelt": "$(heroku version | grep toolbelt | col 1 | sed 's|.*/||')", - "gcloud": "$(/opt/google-cloud-sdk/bin/gcloud version | grep "Google Cloud SDK" | col 4)", - "aws-cli": "$(aws --version 2>&1 | col 1 | sed 's|.*/||')", - "android": { - "build-tool": "$(grep 'Pkg.Revision=' $ANDROID_HOME/tools/source.properties | sed 's/Pkg.Revision=//')", - "build-tools": [ - $(ls $ANDROID_HOME/build-tools | quotify | commatize | trailing_last_comma) - ], - "platforms": [ - $(ls $ANDROID_HOME/platforms | quotify | commatize | trailing_last_comma) - ], - "emulator-images": [ - $(ls $ANDROID_HOME/system-images/ | sed 's/android/sys-img-armeabi-v7-android/g' | quotify | commatize | trailing_last_comma) - ], - "add-ons": [ - $(ls $ANDROID_HOME/add-ons | quotify | commatize | trailing_last_comma) - ], - "android-extra": [ - $(ls $ANDROID_HOME/extras/android | quotify | commatize | trailing_last_comma) - ], - "google-extra": [ - $(ls $ANDROID_HOME/extras/google | quotify | commatize | trailing_last_comma) - ] - } - }, - "all": { - $(dpkg -l | grep -e '^ii' | awk '{printf "\"%s\": \"%s\",\n", $2,$3}' | trailing_last_comma) - } -} -EOF diff --git a/targets/ubuntu-14.04-XXL-upstart/Dockerfile b/targets/ubuntu-14.04-XXL-upstart/Dockerfile deleted file mode 100644 index d1a1da7..0000000 --- a/targets/ubuntu-14.04-XXL-upstart/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM circleci/build-image:ubuntu-14.04-XXL-1167-271bbe4 - -ARG IMAGE_TAG - -RUN echo 'source /home/ubuntu/.circlerc &>/dev/null' >> /root/.bashrc - -RUN echo $IMAGE_TAG > /opt/circleci/image_version - -ADD targets/ubuntu-14.04-XXL-upstart/pkg-versions.sh /opt/circleci/bin/pkg-versions.sh - -# Workaround for https://github.com/nimiq/docker-postgresql93/issues/2 -RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private - -USER root - -CMD ["/sbin/init"] - -LABEL com.circleci.user="ubuntu" diff --git a/targets/ubuntu-14.04-XXL-upstart/pkg-versions.sh b/targets/ubuntu-14.04-XXL-upstart/pkg-versions.sh deleted file mode 100755 index 44e02df..0000000 --- a/targets/ubuntu-14.04-XXL-upstart/pkg-versions.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/bash - -col() { - c=$1 - cut -d ' ' -f ${c} -} - -quotify() { - cat - | sed -e s/^/\"/ | sed s/$/\"/ -} - -commatize() { - cat - | sed -e s/$/\,/ -} - -flatten() { - cat - | tr "\n" " " -} - -trailing_last_comma() { - cat - | sed -e '$ s/,\s*$//g' -} - -all_ruby() { - ls $CIRCLECI_PKG_DIR/ruby/ | grep -v default | quotify | commatize | flatten | trailing_last_comma -} - -all_python() { - ls $CIRCLECI_PKG_DIR/python/ | quotify | commatize | flatten | trailing_last_comma -} - -all_nodejs() { - ls $CIRCLECI_PKG_DIR/nodejs/ | quotify | commatize | flatten | trailing_last_comma -} - -all_php() { - ls $CIRCLECI_PKG_DIR/php/ | quotify | commatize | flatten | trailing_last_comma -} - -all_java() { - # Exclude symbolic links - ls -l /usr/lib/jvm | grep -v -- "->" | grep -v total | awk '{print $9}' | quotify | commatize | flatten | trailing_last_comma -} - -all_ghc() { - ls /opt/ghc/ | quotify | commatize | flatten | trailing_last_comma -} - -all_sbt() { - ls /home/ubuntu/.sbt/.lib/ | quotify | commatize | flatten | trailing_last_comma -} - -cat<&1 | col 2)", - "all": [ - $(all_python) - ], - "pip": "$(pip --version | col 2)", - "virtualenv": "$(virtualenv --version)" - }, - "nodejs": { - "default": "$(node --version | head -1 | sed 's/^v//')", - "all": [ - $(all_nodejs) - ], - "npm": "$(npm --version)", - "nvm": "$(. $CIRCLECI_PKG_DIR/.nvm/nvm.sh && nvm --version)" - }, - "php": { - "default": "$(php --version | head -1 | col 2)", - "all": [ - $(all_php) - ] - }, - "java": { - "default": "$(java -version 2>&1 | head -1 | col 3 | sed 's/"//g')", - "all": [ - $(all_java) - ] - }, - "clojure": { - "lein": "$(lein --version | col 2)" - }, - "haskell": { - "all": [ - $(all_ghc) - ], - "cabal": "$(cabal --version | head -1 | col 3)", - "alex": "$(alex --version | col 3 | trailing_last_comma)", - "happy": "$(happy --version | head -1 | col 3)" - }, - "scala": { - "all": [ - $(all_sbt) - ] - }, - "redis": "$(redis-server --version | col 3 | sed 's/^v=//')", - "memcached": "$(memcached -h | head -1 | col 2)", - "git": "$(git --version | col 3)", - "gcc": "$(gcc --version | head -n1 | col 4)", - "g++": "$(g++ --version | head -n1 | col 4)", - "cc": "$(cc --version | head -1 | col 4)", - "c++": "$(c++ --version | head -1 | col 4)", - "make": "$(make --version | head -1 | col 3)", - "maven": "$(mvn --version | head -1 | col 3)", - "ant": "$(ant -version | col 4)", - "apache2": "$(apache2 -version | grep 'Server version' | col 3 | cut -d '/' -f 2)", - "beanstalkd": "$(beanstalkd -v | col 2)", - "cassandra": "$(cassandra -v | tail -1)", - "elasticsearch": "$(/usr/share/elasticsearch/bin/elasticsearch -v | col 2 | sed 's/,//g')", - "neo4j": "$(neo4j-shell --version | col 4)", - "riak": "$(riak version)", - "memcached": "$(memcached -h | head -1 | col 2)", - "couchdb": "$(couchdb -V | head -1 | col 5)", - "geos": "$(geos-config --version)", - "go": "$(go version | col 3 | sed 's/^go//')", - "gradle": "$(gradle --version | grep Gradle | col 2)", - "phantomjs": "$(phantomjs --version)", - "docker": "$(docker --version | col 3 | sed 's/-circleci.*//')", - "docker-compose": "$(docker-compose --version | col 3 | sed 's/,//g')", - "gcloud": "$(/opt/google-cloud-sdk/bin/gcloud version | grep "Google Cloud SDK" | col 4)", - "aws-cli": "$(aws --version 2>&1 | col 1 | sed 's|.*/||')", - "android": { - "build-tool": "$(grep 'Pkg.Revision=' $ANDROID_HOME/tools/source.properties | sed 's/Pkg.Revision=//')", - "build-tools": [ - $(ls $ANDROID_HOME/build-tools | quotify | commatize | trailing_last_comma) - ], - "platforms": [ - $(ls $ANDROID_HOME/platforms | quotify | commatize | trailing_last_comma) - ], - "emulator-images": [ - $(ls $ANDROID_HOME/system-images/ | sed 's/android/sys-img-armeabi-v7-android/g' | quotify | commatize | trailing_last_comma) - ], - "add-ons": [ - $(ls $ANDROID_HOME/add-ons | quotify | commatize | trailing_last_comma) - ], - "android-extra": [ - $(ls $ANDROID_HOME/extras/android | quotify | commatize | trailing_last_comma) - ], - "google-extra": [ - $(ls $ANDROID_HOME/extras/google | quotify | commatize | trailing_last_comma) - ] - } - }, - "all": { - $(dpkg -l | grep -e '^ii' | awk '{printf "\"%s\": \"%s\",\n", $2,$3}' | trailing_last_comma) - } -} -EOF diff --git a/targets/ubuntu-14.04-XXL/Dockerfile b/targets/ubuntu-14.04-XXL/Dockerfile deleted file mode 100644 index f84cb18..0000000 --- a/targets/ubuntu-14.04-XXL/Dockerfile +++ /dev/null @@ -1,170 +0,0 @@ -FROM circleci/ubuntu-server:trusty-latest - -ENV VERBOSE true - -# Avoid any installation scripts interact with upstart -# So divert now, but undivert at the end -# You shouldn't change the line unless you understand the consequence -RUN echo 'exit 101' > /usr/sbin/policy-rc.d \ - && chmod +x /usr/sbin/policy-rc.d \ - && dpkg-divert --local --rename --add /sbin/initctl \ - && ln -s /bin/true /sbin/initctl - -ADD circleci-install /usr/local/bin/circleci-install -ADD circleci-provision-scripts/base.sh circleci-provision-scripts/circleci-specific.sh /opt/circleci-provision-scripts/ -RUN circleci-install base_requirements && circleci-install circleci_specific - -# Installing java early beacuse a few things have the dependency to java (i.g. cassandra) -ADD circleci-provision-scripts/java.sh /opt/circleci-provision-scripts/java.sh -RUN for package in oraclejdk7 oraclejdk8 openjdk7 openjdk8; do circleci-install java $package; done - -# Databases -ADD circleci-provision-scripts/mysql.sh circleci-provision-scripts/mongo.sh circleci-provision-scripts/postgres.sh circleci-provision-scripts/sqlite.sh /opt/circleci-provision-scripts/ -RUN for package in mysql_57 mongo postgres postgres_ext_postgis sqlite3_15; do circleci-install $package; done - -ADD circleci-provision-scripts/misc.sh /opt/circleci-provision-scripts/misc.sh -RUN for package in sysadmin devtools jq redis memcached rabbitmq neo4j elasticsearch beanstalkd cassandra riak couchdb; do circleci-install $package; done - -# Update to the version where recent (as of Oct 2017) vulnerabilities were fixed -ADD circleci-provision-scripts/curl.sh /opt/circleci-provision-scripts/curl.sh -RUN circleci-install curl_7_56 - -# Dislabe services by default -RUN for s in apache2 memcached rabbitmq-server neo4j neo4j-service elasticsearch beanstalkd cassandra riak couchdb; do sysv-rc-conf $s off; done - -# Browsers -ADD circleci-provision-scripts/firefox.sh circleci-provision-scripts/chrome.sh circleci-provision-scripts/phantomjs.sh /opt/circleci-provision-scripts/ -RUN circleci-install firefox && circleci-install chrome && circleci-install phantomjs - -# Android -ADD circleci-provision-scripts/android-sdk.sh /opt/circleci-provision-scripts/android-sdk.sh -RUN circleci-install android_sdk platform-tools -RUN circleci-install android_sdk extra-android-support -RUN for package in android-25 android-24 android-23 android-22; do circleci-install android_sdk $package; done -RUN for package in sys-img-armeabi-v7a-android-24 sys-img-armeabi-v7a-android-22; do circleci-install android_sdk $package; done -RUN for package in build-tools-25.0.1 build-tools-25.0.0 build-tools-24.0.3 build-tools-24.0.2 build-tools-24.0.1 build-tools-24.0.0 build-tools-23.0.3 build-tools-23.0.2 build-tools-22.0.1; do circleci-install android_sdk $package; done -RUN for package in android_sdk extra-android-m2repository android_sdk extra-google-m2repository android_sdk extra-google-google_play_services android_sdk addon-google_apis-google-23 android_sdk addon-google_apis-google-22; do circleci-install android_sdk $package; done - -# Qt -ADD circleci-provision-scripts/qt.sh /opt/circleci-provision-scripts/qt.sh -RUN circleci-install qt - -# Install deployment tools -ADD circleci-provision-scripts/awscli.sh circleci-provision-scripts/gcloud.sh circleci-provision-scripts/heroku.sh /opt/circleci-provision-scripts/ -RUN for package in awscli gcloud heroku; do circleci-install $package; done - -# Languages -ARG use_precompile=true -ENV USE_PRECOMPILE=$use_precompile RUN_APT_UPDATE=true -RUN curl -s https://packagecloud.io/install/repositories/circleci/trusty/script.deb.sh | sudo bash -ADD circleci-provision-scripts/python.sh /opt/circleci-provision-scripts/python.sh -RUN circleci-install python 2.7.10 -RUN circleci-install python 2.7.11 -RUN circleci-install python 2.7.12 -RUN circleci-install python 3.1.4 -RUN circleci-install python 3.1.5 -RUN circleci-install python 3.2.5 -RUN circleci-install python 3.2.6 -RUN circleci-install python 3.3.5 -RUN circleci-install python 3.3.6 -RUN circleci-install python 3.4.3 -RUN circleci-install python 3.4.4 -RUN circleci-install python 3.5.1 -RUN circleci-install python 3.5.2 -RUN circleci-install python 3.5.3 -RUN circleci-install python 3.6.1 -RUN circleci-install python 3.6.2 -RUN circleci-install python pypy-1.9 -RUN circleci-install python pypy-2.6.1 -RUN circleci-install python pypy-4.0.1 -RUN sudo -H -i -u ubuntu pyenv global 2.7.11 - -ADD circleci-provision-scripts/nodejs.sh /opt/circleci-provision-scripts/nodejs.sh -RUN circleci-install nodejs 0.12.9 -RUN circleci-install nodejs 4.0.0 -RUN circleci-install nodejs 4.1.2 -RUN circleci-install nodejs 4.2.6 -RUN circleci-install nodejs 4.3.0 -RUN circleci-install nodejs 4.5.0 -RUN circleci-install nodejs 5.0.0 -RUN circleci-install nodejs 5.1.1 -RUN circleci-install nodejs 5.2.0 -RUN circleci-install nodejs 5.3.0 -RUN circleci-install nodejs 5.4.1 -RUN circleci-install nodejs 5.5.0 -RUN circleci-install nodejs 5.6.0 -RUN circleci-install nodejs 5.7.0 -RUN circleci-install nodejs 6.1.0 -RUN circleci-install nodejs 6.11.4 -RUN circleci-install nodejs 8.1.4 -RUN circleci-install nodejs 8.2.0 -RUN sudo -H -i -u ubuntu nvm alias default 4.2.6 -RUN circleci-install yarn 1.1.0 - -ADD circleci-provision-scripts/go.sh /opt/circleci-provision-scripts/go.sh -RUN circleci-install golang 1.9.1 - -ADD circleci-provision-scripts/ruby.sh /opt/circleci-provision-scripts/ruby.sh -RUN circleci-install ruby 2.1.8 -RUN circleci-install ruby 2.1.9 -RUN circleci-install ruby 2.2.6 -RUN circleci-install ruby 2.2.7 -RUN circleci-install ruby 2.3.4 -RUN circleci-install ruby 2.3.5 -RUN circleci-install ruby 2.4.1 -RUN circleci-install ruby 2.4.2 -RUN sudo -H -i -u ubuntu rvm use 2.2.6 --default - -ADD circleci-provision-scripts/php.sh /opt/circleci-provision-scripts/php.sh -RUN circleci-install php 5.5.31 -RUN circleci-install php 5.5.32 -RUN circleci-install php 5.5.36 -RUN circleci-install php 5.6.17 -RUN circleci-install php 5.6.18 -RUN circleci-install php 5.6.22 -RUN circleci-install php 7.0.7 -RUN circleci-install php 7.0.11 -RUN circleci-install php 7.0.17 -RUN circleci-install php 7.0.20 -RUN circleci-install php 7.0.24 -RUN circleci-install php 7.1.3 -RUN circleci-install php 7.1.6 -RUN circleci-install php 7.1.9 -RUN sudo -H -i -u ubuntu phpenv global 5.6.17 - -ADD circleci-provision-scripts/clojure.sh /opt/circleci-provision-scripts/clojure.sh -RUN circleci-install clojure - -ADD circleci-provision-scripts/scala.sh /opt/circleci-provision-scripts/scala.sh -RUN circleci-install scala - -ADD circleci-provision-scripts/haskell.sh /opt/circleci-provision-scripts/haskell.sh -RUN circleci-install ghc 8.0.2 -RUN circleci-install stack - -ADD circleci-provision-scripts/git-lfs.sh /opt/circleci-provision-scripts/git-lfs.sh -RUN circleci-install git-lfs 1.5.4 - -# Docker have be last - to utilize cache better -ADD circleci-provision-scripts/docker.sh /opt/circleci-provision-scripts/docker.sh -RUN circleci-install docker && circleci-install docker_compose - -# Install CircleCI patched Docker that runs in unpriv container -RUN circleci-install circleci_docker - -# Undivert upstart -# You shouldn't change the line unless you understad the consequence -RUN rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl - -# Add rest of provisioning files -- add at end to avoid cache invalidation -ADD circleci-provision-scripts /opt/circleci-provision-scripts - -# We need Dockerfile because unit test parses Dockerfile to make sure all versions are installed -ADD targets/ubuntu-14.04-XXL/Dockerfile /opt/circleci/Dockerfile - -ARG IMAGE_TAG -RUN echo $IMAGE_TAG > /opt/circleci/image_version - -ADD targets/ubuntu-14.04-XXL/pkg-versions.sh /opt/circleci/bin/pkg-versions.sh - -LABEL circleci.user="ubuntu" diff --git a/targets/ubuntu-14.04-XXL/pkg-versions.sh b/targets/ubuntu-14.04-XXL/pkg-versions.sh deleted file mode 100755 index 6421ae8..0000000 --- a/targets/ubuntu-14.04-XXL/pkg-versions.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!/bin/bash - -col() { - c=$1 - cut -d ' ' -f ${c} -} - -quotify() { - cat - | sed -e s/^/\"/ | sed s/$/\"/ -} - -commatize() { - cat - | sed -e s/$/\,/ -} - -flatten() { - cat - | tr "\n" " " -} - -trailing_last_comma() { - cat - | sed -e '$ s/,\s*$//g' -} - -all_ruby() { - ls $CIRCLECI_PKG_DIR/ruby/ | grep -v default | quotify | commatize | flatten | trailing_last_comma -} - -all_python() { - ls $CIRCLECI_PKG_DIR/python/ | quotify | commatize | flatten | trailing_last_comma -} - -all_nodejs() { - ls $CIRCLECI_PKG_DIR/nodejs/ | quotify | commatize | flatten | trailing_last_comma -} - -all_php() { - ls $CIRCLECI_PKG_DIR/php/ | quotify | commatize | flatten | trailing_last_comma -} - -all_java() { - # Exclude symbolic links - ls -l /usr/lib/jvm | grep -v -- "->" | grep -v total | awk '{print $9}' | quotify | commatize | flatten | trailing_last_comma -} - -all_ghc() { - ls /opt/ghc/ | quotify | commatize | flatten | trailing_last_comma -} - -all_sbt() { - ls /home/ubuntu/.sbt/.lib/ | quotify | commatize | flatten | trailing_last_comma -} - -cat<&1 | col 2)", - "all": [ - $(all_python) - ], - "pip": "$(pip --version | col 2)", - "virtualenv": "$(virtualenv --version)" - }, - "nodejs": { - "default": "$(node --version | head -1 | sed 's/^v//')", - "all": [ - $(all_nodejs) - ], - "npm": "$(npm --version)", - "nvm": "$(. $CIRCLECI_PKG_DIR/.nvm/nvm.sh && nvm --version)", - "yarn": "$(yarn --version)" - }, - "php": { - "default": "$(php --version | head -1 | col 2)", - "all": [ - $(all_php) - ] - }, - "java": { - "default": "$(java -version 2>&1 | head -1 | col 3 | sed 's/"//g')", - "all": [ - $(all_java) - ] - }, - "clojure": { - "lein": "$(lein --version | col 2)" - }, - "haskell": { - "all": [ - $(all_ghc) - ], - "cabal": "$(cabal --version | head -1 | col 3)", - "alex": "$(alex --version | col 3 | trailing_last_comma)", - "happy": "$(happy --version | head -1 | col 3)", - "stack": "$(stack --version | col 2 | trailing_last_comma)" - }, - "scala": { - "all": [ - $(all_sbt) - ] - }, - "redis": "$(redis-server --version | col 3 | sed 's/^v=//')", - "memcached": "$(memcached -h | head -1 | col 2)", - "git": "$(git --version | col 3)", - "git-lfs": "$(git-lfs version | col 1 | sed -e s/git-lfs\\///)", - "gcc": "$(gcc --version | head -n1 | col 4)", - "g++": "$(g++ --version | head -n1 | col 4)", - "cc": "$(cc --version | head -1 | col 4)", - "c++": "$(c++ --version | head -1 | col 4)", - "make": "$(make --version | head -1 | col 3)", - "maven": "$(mvn --version | head -1 | col 3)", - "ant": "$(ant -version | col 4)", - "apache2": "$(apache2 -version | grep 'Server version' | col 3 | cut -d '/' -f 2)", - "beanstalkd": "$(beanstalkd -v | col 2)", - "cassandra": "$(cassandra -v | tail -1)", - "elasticsearch": "$(/usr/share/elasticsearch/bin/elasticsearch -v | col 2 | sed 's/,//g')", - "neo4j": "$(neo4j-shell --version | col 4)", - "riak": "$(riak version)", - "memcached": "$(memcached -h | head -1 | col 2)", - "couchdb": "$(couchdb -V | head -1 | col 5)", - "geos": "$(geos-config --version)", - "go": "$(go version | col 3 | sed 's/^go//')", - "gradle": "$(gradle --version | grep Gradle | col 2)", - "phantomjs": "$(phantomjs --version)", - "docker": "$(docker --version | col 3 | sed 's/-circleci.*//')", - "docker-compose": "$(docker-compose --version | col 3 | sed 's/,//g')", - "gcloud": "$(gcloud version | grep "Google Cloud SDK" | col 4)", - "aws-cli": "$(aws --version 2>&1 | col 1 | sed 's|.*/||')", - "android": { - "build-tool": "$(grep 'Pkg.Revision=' $ANDROID_HOME/tools/source.properties | sed 's/Pkg.Revision=//')", - "build-tools": [ - $(ls $ANDROID_HOME/build-tools | quotify | commatize | trailing_last_comma) - ], - "platforms": [ - $(ls $ANDROID_HOME/platforms | quotify | commatize | trailing_last_comma) - ], - "emulator-images": [ - $(ls $ANDROID_HOME/system-images/ | sed 's/android/sys-img-armeabi-v7-android/g' | quotify | commatize | trailing_last_comma) - ], - "add-ons": [ - $(ls $ANDROID_HOME/add-ons | quotify | commatize | trailing_last_comma) - ], - "android-extra": [ - $(ls $ANDROID_HOME/extras/android | quotify | commatize | trailing_last_comma) - ], - "google-extra": [ - $(ls $ANDROID_HOME/extras/google | quotify | commatize | trailing_last_comma) - ] - } - }, - "all": { - $(dpkg -l | grep -e '^ii' | awk '{printf "\"%s\": \"%s\",\n", $2,$3}' | trailing_last_comma) - } -} -EOF diff --git a/targets/ubuntu-14.04-enterprise/Dockerfile b/targets/ubuntu-14.04-enterprise/Dockerfile deleted file mode 100644 index 329d8e5..0000000 --- a/targets/ubuntu-14.04-enterprise/Dockerfile +++ /dev/null @@ -1,99 +0,0 @@ -FROM circleci/ubuntu-server:trusty-latest - -ENV VERBOSE true - -# Avoid any installation scripts interact with upstart -# So divert now, but undivert at the end -# You shouldn't change the line unless you understand the consequence -RUN echo 'exit 101' > /usr/sbin/policy-rc.d \ - && chmod +x /usr/sbin/policy-rc.d \ - && dpkg-divert --local --rename --add /sbin/initctl \ - && ln -s /bin/true /sbin/initctl - -ADD circleci-install /usr/local/bin/circleci-install -ADD circleci-provision-scripts/base.sh circleci-provision-scripts/circleci-specific.sh /opt/circleci-provision-scripts/ -RUN circleci-install base_requirements && circleci-install circleci_specific - -# Databases -ADD circleci-provision-scripts/mysql.sh circleci-provision-scripts/mongo.sh circleci-provision-scripts/postgres.sh /opt/circleci-provision-scripts/ -RUN for package in mysql_57 mongo postgres postgres_ext_postgis; do circleci-install $package; done - -# Installing java early beacuse a few things have the dependency to java (i.g. cassandra) -ADD circleci-provision-scripts/java.sh /opt/circleci-provision-scripts/java.sh -RUN circleci-install java oraclejdk8 && circleci-install java openjdk8 - -ADD circleci-provision-scripts/misc.sh /opt/circleci-provision-scripts/misc.sh -RUN for package in sysadmin devtools jq redis memcached rabbitmq neo4j elasticsearch beanstalkd cassandra riak couchdb; do circleci-install $package; done - -# Dislabe services by default -RUN for s in apache2 memcached rabbitmq-server neo4j neo4j-service elasticsearch beanstalkd cassandra riak couchdb; do sysv-rc-conf $s off; done - -# Browsers -ADD circleci-provision-scripts/firefox.sh circleci-provision-scripts/chrome.sh circleci-provision-scripts/phantomjs.sh /opt/circleci-provision-scripts/ -RUN circleci-install firefox && circleci-install chrome && circleci-install phantomjs - -# Qt -ADD circleci-provision-scripts/qt.sh /opt/circleci-provision-scripts/qt.sh -RUN circleci-install qt - -# Install deployment tools -ADD circleci-provision-scripts/awscli.sh circleci-provision-scripts/gcloud.sh circleci-provision-scripts/heroku.sh /opt/circleci-provision-scripts/ -RUN for package in awscli gcloud heroku; do circleci-install $package; done - -# Languages -ARG use_precompile=true -ENV USE_PRECOMPILE=$use_precompile RUN_APT_UPDATE=true -RUN curl -s https://packagecloud.io/install/repositories/circleci/trusty/script.deb.sh | sudo bash -ADD circleci-provision-scripts/python.sh /opt/circleci-provision-scripts/python.sh -RUN circleci-install python 2.7.10 -RUN circleci-install python 2.7.11 -RUN circleci-install python 3.4.3 -RUN circleci-install python 3.5.1 -RUN sudo -H -i -u ubuntu pyenv global 2.7.11 - -ADD circleci-provision-scripts/nodejs.sh /opt/circleci-provision-scripts/nodejs.sh -RUN circleci-install nodejs 4.2.6 -RUN circleci-install nodejs 5.5.0 -RUN circleci-install nodejs 6.1.0 -RUN sudo -H -i -u ubuntu nvm alias default 4.2.6 -RUN circleci-install yarn 0.18.1 - -ADD circleci-provision-scripts/go.sh /opt/circleci-provision-scripts/go.sh -RUN circleci-install golang 1.6.2 - -ADD circleci-provision-scripts/ruby.sh /opt/circleci-provision-scripts/ruby.sh -RUN circleci-install ruby 2.2.4 -RUN circleci-install ruby 2.3.0 -RUN circleci-install ruby 2.3.1 -RUN sudo -H -i -u ubuntu rvm use 2.2.4 --default - -ADD circleci-provision-scripts/php.sh /opt/circleci-provision-scripts/php.sh -RUN circleci-install php 5.6.17 -RUN circleci-install php 7.0.4 -RUN sudo -H -i -u ubuntu phpenv global 5.6.17 - -ADD circleci-provision-scripts/clojure.sh /opt/circleci-provision-scripts/clojure.sh -RUN circleci-install clojure - -ADD circleci-provision-scripts/scala.sh /opt/circleci-provision-scripts/scala.sh -RUN circleci-install scala - -ADD circleci-provision-scripts/docker.sh /opt/circleci-provision-scripts/docker.sh -RUN circleci-install docker && circleci-install docker_compose - -# Undivert upstart -# You shouldn't change the line unless you understad the consequence -RUN rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl - -# Add rest of provisioning files -- add at end to avoid cache invalidation -ADD circleci-provision-scripts /opt/circleci-provision-scripts - -# We need Dockerfile because unit test parses Dockerfile to make sure all versions are installed -ADD targets/ubuntu-14.04-enterprise/Dockerfile /opt/circleci/Dockerfile - -ARG IMAGE_TAG -RUN echo $IMAGE_TAG > /opt/circleci/image_version - -ADD targets/ubuntu-14.04-enterprise/pkg-versions.sh /opt/circleci/bin/pkg-versions.sh - -LABEL circleci.user="ubuntu" diff --git a/targets/ubuntu-14.04-enterprise/pkg-versions.sh b/targets/ubuntu-14.04-enterprise/pkg-versions.sh deleted file mode 100755 index 60bd29f..0000000 --- a/targets/ubuntu-14.04-enterprise/pkg-versions.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/bash - -col() { - c=$1 - cut -d ' ' -f ${c} -} - -quotify() { - cat - | sed -e s/^/\"/ | sed s/$/\"/ -} - -commatize() { - cat - | sed -e s/$/\,/ -} - -flatten() { - cat - | tr "\n" " " -} - -trailing_last_comma() { - cat - | sed -e '$ s/,\s*$//g' -} - -all_ruby() { - ls $CIRCLECI_PKG_DIR/ruby/ | grep -v default | quotify | commatize | flatten | trailing_last_comma -} - -all_python() { - ls $CIRCLECI_PKG_DIR/python/ | quotify | commatize | flatten | trailing_last_comma -} - -all_nodejs() { - ls $CIRCLECI_PKG_DIR/nodejs/ | quotify | commatize | flatten | trailing_last_comma -} - -all_php() { - ls $CIRCLECI_PKG_DIR/php/ | quotify | commatize | flatten | trailing_last_comma -} - -all_java() { - # Exclude symbolic links - ls -l /usr/lib/jvm | grep -v -- "->" | grep -v total | awk '{print $9}' | quotify | commatize | flatten | trailing_last_comma -} - -all_ghc() { - ls /opt/ghc/ | quotify | commatize | flatten | trailing_last_comma -} - -all_sbt() { - ls /home/ubuntu/.sbt/.lib/ | quotify | commatize | flatten | trailing_last_comma -} - -cat<&1 | col 2)", - "all": [ - $(all_python) - ], - "pip": "$(pip --version | col 2)", - "virtualenv": "$(virtualenv --version)" - }, - "nodejs": { - "default": "$(node --version | head -1 | sed 's/^v//')", - "all": [ - $(all_nodejs) - ], - "npm": "$(npm --version)", - "nvm": "$(. $CIRCLECI_PKG_DIR/.nvm/nvm.sh && nvm --version)" - }, - "php": { - "default": "$(php --version | head -1 | col 2)", - "all": [ - $(all_php) - ] - }, - "java": { - "default": "$(java -version 2>&1 | head -1 | col 3 | sed 's/"//g')", - "all": [ - $(all_java) - ] - }, - "clojure": { - "lein": "$(lein --version | col 2)" - }, - "haskell": { - "all": [ - $(all_ghc) - ], - "cabal": "$(cabal --version | head -1 | col 3)", - "alex": "$(alex --version | col 3 | trailing_last_comma)", - "happy": "$(happy --version | head -1 | col 3)" - }, - "scala": { - "all": [ - $(all_sbt) - ] - }, - "redis": "$(redis-server --version | col 3 | sed 's/^v=//')", - "memcached": "$(memcached -h | head -1 | col 2)", - "git": "$(git --version | col 3)", - "gcc": "$(gcc --version | head -n1 | col 4)", - "g++": "$(g++ --version | head -n1 | col 4)", - "cc": "$(cc --version | head -1 | col 4)", - "c++": "$(c++ --version | head -1 | col 4)", - "make": "$(make --version | head -1 | col 3)", - "maven": "$(mvn --version | head -1 | col 3)", - "ant": "$(ant -version | col 4)", - "apache2": "$(apache2 -version | grep 'Server version' | col 3 | cut -d '/' -f 2)", - "beanstalkd": "$(beanstalkd -v | col 2)", - "cassandra": "$(cassandra -v | tail -1)", - "elasticsearch": "$(/usr/share/elasticsearch/bin/elasticsearch -v | col 2 | sed 's/,//g')", - "neo4j": "$(neo4j-shell --version | col 4)", - "riak": "$(riak version)", - "memcached": "$(memcached -h | head -1 | col 2)", - "couchdb": "$(couchdb -V | head -1 | col 5)", - "geos": "$(geos-config --version)", - "go": "$(go version | col 3 | sed 's/^go//')", - "gradle": "$(gradle --version | grep Gradle | col 2)", - "phantomjs": "$(phantomjs --version)", - "docker": "$(docker --version | col 3 | sed 's/-circleci.*//')", - "docker-compose": "$(docker-compose --version | col 3 | sed 's/,//g')", - "heroku-toolbelt": "$(heroku version | grep toolbelt | col 1 | sed 's|.*/||')", - "gcloud": "$(/opt/google-cloud-sdk/bin/gcloud version | grep "Google Cloud SDK" | col 4)", - "aws-cli": "$(aws --version 2>&1 | col 1 | sed 's|.*/||')", - "android": { - "build-tool": "$(grep 'Pkg.Revision=' $ANDROID_HOME/tools/source.properties | sed 's/Pkg.Revision=//')", - "build-tools": [ - $(ls $ANDROID_HOME/build-tools | quotify | commatize | trailing_last_comma) - ], - "platforms": [ - $(ls $ANDROID_HOME/platforms | quotify | commatize | trailing_last_comma) - ], - "emulator-images": [ - $(ls $ANDROID_HOME/system-images/ | sed 's/android/sys-img-armeabi-v7-android/g' | quotify | commatize | trailing_last_comma) - ], - "add-ons": [ - $(ls $ANDROID_HOME/add-ons | quotify | commatize | trailing_last_comma) - ], - "android-extra": [ - $(ls $ANDROID_HOME/extras/android | quotify | commatize | trailing_last_comma) - ], - "google-extra": [ - $(ls $ANDROID_HOME/extras/google | quotify | commatize | trailing_last_comma) - ] - } - }, - "all": { - $(dpkg -l | grep -e '^ii' | awk '{printf "\"%s\": \"%s\",\n", $2,$3}' | trailing_last_comma) - } -} -EOF diff --git a/tests/Dockerfile b/tests/Dockerfile deleted file mode 100644 index fd07845..0000000 --- a/tests/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM circleci/build-image:scratch-unprivileged - -ADD insecure-ssh-key.pub /home/ubuntu/.ssh/authorized_keys -RUN chown ubuntu:ubuntu /home/ubuntu/.ssh/authorized_keys && git clone https://github.com/sstephenson/bats.git && cd bats && ./install.sh /usr/local diff --git a/tests/insecure-ssh-key b/tests/insecure-ssh-key deleted file mode 100644 index 692f55b..0000000 --- a/tests/insecure-ssh-key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAsXZmgIgw7KIBHl2Ah/oA/EHviNOzaWbEwsBKDzyR/fLYvtyP -aKd3/EsDzV8bqT8H8I5s/sEZgJvfuZzI/ljxGdoWLlJby9kJ1GzuEXqN8LhcPy0o -naP8ajwz3xRRIDdeTGLMKxAPq3INsInGWDs1/p166wnytrwpsxAUdVTyCqf5St5c -suDMBU6WJj3sl2TYqYmyWw0+2rCcH8lDPyNe01GkqR/xLK1ByRtz0JjTNXrzJrYv -pyCWNWkpiRK4NG71WxRCA3aechioDCknLf2sbqBouUBeack8TRF9lneHEbcjSKra -BNXmZMeJfyzLPg5GuQhgxkaSQ7p8IDi3wDy9JwIDAQABAoIBAHkB00MxmqrAjSK3 -fz05LBLWow8Zy+zDNsfVdqqNEr+nKER9AQzLpPVT8XPItoPhhvhxJcFQyqL3psZa -MnO9Eioem6FaZ13I0PsYi/0/JCpQjBZIJLnZZ/TIuFYU9HyTRKmxdKaofQba7prC -V40yUs8bcwVx8x7Hj2eaP1kCY0j/vZOcGCOA+AlselP8jkgMLYaZ8niqpMVndmxj -Xd8W5VVgMjqbyX4TNPl1Rs53pEgOI7jLZxe75WtUEVMzKDHJL0ALVxP/ZyMtkmto -t1hg5qOBKBdLNpmoQcNa+gS6y736pMZORokXDdC8ruir7/AlKttiMkMSXs9IHhOl -HzMjRIECgYEA5CEudQ6m6o0qdHl2tzgAY90JTlncF5ts08Jx05C+H20O65U0PEbR -H54EsazBliHEmyWyGdPQTnN0kmUyiwvh8K36BYYykK+R/4g4utOuVmD4jt9WQ2OH -988j3p//+77x4xJutKk0OwggiaxzZTsvBnFbLRwOwweTD72Kntn29asCgYEAxySX -Ln7HDyWfkq+r+SCMBTxH+BvKDZUrbPW2VbpgFuh5fZ8pAIz4h6cLBk/YahUqOSrR -H8xUmsIVmzkdVqap+eY8ebhwiR3KRQPr0xhE5I5MZt0x+i7dqW6j2f30kAoMouv5 -h2O2Ecpl7KLRFqh348tQXbSj9HBEfndgWu/5YnUCgYAQ/m/JhIfmnRF2j73KND/D -MKoKziLZF1jqBWgZTIT9LlCYOAsmGlhltI3A9o+NMYLF0+8KgX7Y+TzL0wIK3Z29 -Ihin5LFLmeiUUn93W2F3Sc36RqTUbEuqqCGR6fVVuYmnUq4wgxJC+34BA3mtJtV/ -813JZHetC5lm6MW0w6Pj9QKBgQDEV2AzOE28smSFNGzDAILs+oUeqw9omuUo1Y2D -MnFgxK5b29uKLnMvE9P70idWWC28FWoABu53ctnoo8Q4VbQKriR8Agv6NIPjzbzp -8Oijy2SqmnWW7DQhw/MKj6dbiHzy+OOZyAaPvdUGHXU2+LzTu/YtnVd1PmdZpQs8 -PZPMrQKBgC3/oEYltUs3hTy/1I3Tmr9Kt+ORbrF7TwtcUgHUyTDNekrKbZgB61jv -Y2qzsQUEWjSTwh18pmJQZ/l3cd5KSW02z8wEAzRJmQoW4r/o90HUa+Bk3lfPjlh1 -BHxR4lonxoocb9t0q/28HTHiUhgJaXLdy/iy1jJFcwLag5KLgsFG ------END RSA PRIVATE KEY----- diff --git a/tests/insecure-ssh-key.pub b/tests/insecure-ssh-key.pub deleted file mode 100644 index 0101a1a..0000000 --- a/tests/insecure-ssh-key.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCxdmaAiDDsogEeXYCH+gD8Qe+I07NpZsTCwEoPPJH98ti+3I9op3f8SwPNXxupPwfwjmz+wRmAm9+5nMj+WPEZ2hYuUlvL2QnUbO4Reo3wuFw/LSido/xqPDPfFFEgN15MYswrEA+rcg2wicZYOzX+nXrrCfK2vCmzEBR1VPIKp/lK3lyy4MwFTpYmPeyXZNipibJbDT7asJwfyUM/I17TUaSpH/EsrUHJG3PQmNM1evMmti+nIJY1aSmJErg0bvVbFEIDdp5yGKgMKSct/axuoGi5QF5pyTxNEX2Wd4cRtyNIqtoE1eZkx4l/LMs+Dka5CGDGRpJDunwgOLfAPL0n kimh@Hirokunis-MacBook-Pro.local diff --git a/tests/integration/rails4-starterkit.bats b/tests/integration/rails4-starterkit.bats deleted file mode 100644 index 5e6c720..0000000 --- a/tests/integration/rails4-starterkit.bats +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bats - -setup () { - source /opt/circleci/.rvm/scripts/rvm -} - -machine () { - rvm use 2.1.3 -} - -dependencies () { - export RAILS_ENV=test - export RACK_ENV=test - - for g in growl_notify autotest-fsevent rb-appscript rb-fsevent; do - sed -i.bak "/gem ['\"]$g['\"].*, *$/ N; s/\n *//g; /gem ['\"]$g['\"]/ d" Gemfile - done - - bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 -} - -database () { - mkdir -p config - echo 'test: - adapter: postgresql - encoding: unicode - database: circle_ruby_test - pool: 5 - username: ubuntu - host: localhost -' > config/database.yml -} - -test () { - bundle exec rspec --color --require spec_helper spec --format progress &>> bats.log -} - -@test "rails4-starterkit: test passes" { - cd tests/integration/rails4-starterkit - - machine - dependencies - database - run test - - echo "---------------- output -----------------" - echo $output - echo "---------------- output -----------------" - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/bats-assert/.travis.yml b/tests/unit/bats-assert/.travis.yml deleted file mode 100644 index e56169a..0000000 --- a/tests/unit/bats-assert/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: bash -before_install: - - ./script/install-bats.sh - - git clone --depth 1 https://github.com/ztombol/bats-support ../bats-support -before_script: - - export PATH="${HOME}/.local/bin:${PATH}" -script: - - bats test diff --git a/tests/unit/bats-assert/CHANGELOG.md b/tests/unit/bats-assert/CHANGELOG.md deleted file mode 100644 index 7e326f4..0000000 --- a/tests/unit/bats-assert/CHANGELOG.md +++ /dev/null @@ -1,39 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -This project adheres to [Semantic Versioning](http://semver.org/). - - -## [0.3.0] - 2016-03-22 - -### Removed - -- Move `fail()` to `bats-support` - - -## [0.2.0] - 2016-03-11 - -### Added - -- `refute()` to complement `assert()` -- `npm` support - -### Fixed - -- Not consuming the `--` when stopping option parsing in - `assert_output`, `refute_output`, `assert_line` and `refute_line` - - -## 0.1.0 - 2016-02-16 - -### Added - -- Reporting arbitrary failures with `fail()` -- Generic assertions with `assert()` and `assert_equal()` -- Testing exit status with `assert_success()` and `assert_failure()` -- Testing output with `assert_output()` and `refute_output()` -- Testing individual lines with `assert_line()` and `refute_line()` - - -[0.3.0]: https://github.com/ztombol/bats-assert/compare/v0.2.0...v0.3.0 -[0.2.0]: https://github.com/ztombol/bats-assert/compare/v0.1.0...v0.2.0 diff --git a/tests/unit/bats-assert/LICENSE b/tests/unit/bats-assert/LICENSE deleted file mode 100644 index 670154e..0000000 --- a/tests/unit/bats-assert/LICENSE +++ /dev/null @@ -1,116 +0,0 @@ -CC0 1.0 Universal - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator and -subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for the -purpose of contributing to a commons of creative, cultural and scientific -works ("Commons") that the public can reliably and without fear of later -claims of infringement build upon, modify, incorporate in other works, reuse -and redistribute as freely as possible in any form whatsoever and for any -purposes, including without limitation commercial purposes. These owners may -contribute to the Commons to promote the ideal of a free culture and the -further production of creative, cultural and scientific works, or to gain -reputation or greater distribution for their Work in part through the use and -efforts of others. - -For these and/or other purposes and motivations, and without any expectation -of additional consideration or compensation, the person associating CC0 with a -Work (the "Affirmer"), to the extent that he or she is an owner of Copyright -and Related Rights in the Work, voluntarily elects to apply CC0 to the Work -and publicly distribute the Work under its terms, with knowledge of his or her -Copyright and Related Rights in the Work and the meaning and intended legal -effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not limited -to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, communicate, - and translate a Work; - - ii. moral rights retained by the original author(s) and/or performer(s); - - iii. publicity and privacy rights pertaining to a person's image or likeness - depicted in a Work; - - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - - v. rights protecting the extraction, dissemination, use and reuse of data in - a Work; - - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation thereof, - including any amended or successor version of such directive); and - - vii. other similar, equivalent or corresponding rights throughout the world - based on applicable law or treaty, and any national implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention of, -applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and -unconditionally waives, abandons, and surrenders all of Affirmer's Copyright -and Related Rights and associated claims and causes of action, whether now -known or unknown (including existing as well as future claims and causes of -action), in the Work (i) in all territories worldwide, (ii) for the maximum -duration provided by applicable law or treaty (including future time -extensions), (iii) in any current or future medium and for any number of -copies, and (iv) for any purpose whatsoever, including without limitation -commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes -the Waiver for the benefit of each member of the public at large and to the -detriment of Affirmer's heirs and successors, fully intending that such Waiver -shall not be subject to revocation, rescission, cancellation, termination, or -any other legal or equitable action to disrupt the quiet enjoyment of the Work -by the public as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason be -judged legally invalid or ineffective under applicable law, then the Waiver -shall be preserved to the maximum extent permitted taking into account -Affirmer's express Statement of Purpose. In addition, to the extent the Waiver -is so judged Affirmer hereby grants to each affected person a royalty-free, -non transferable, non sublicensable, non exclusive, irrevocable and -unconditional license to exercise Affirmer's Copyright and Related Rights in -the Work (i) in all territories worldwide, (ii) for the maximum duration -provided by applicable law or treaty (including future time extensions), (iii) -in any current or future medium and for any number of copies, and (iv) for any -purpose whatsoever, including without limitation commercial, advertising or -promotional purposes (the "License"). The License shall be deemed effective as -of the date CC0 was applied by Affirmer to the Work. Should any part of the -License for any reason be judged legally invalid or ineffective under -applicable law, such partial invalidity or ineffectiveness shall not -invalidate the remainder of the License, and in such case Affirmer hereby -affirms that he or she will not (i) exercise any of his or her remaining -Copyright and Related Rights in the Work or (ii) assert any associated claims -and causes of action with respect to the Work, in either case contrary to -Affirmer's express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - - b. Affirmer offers the Work as-is and makes no representations or warranties - of any kind concerning the Work, express, implied, statutory or otherwise, - including without limitation warranties of title, merchantability, fitness - for a particular purpose, non infringement, or the absence of latent or - other defects, accuracy, or the present or absence of errors, whether or not - discoverable, all to the greatest extent permissible under applicable law. - - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without limitation - any person's Copyright and Related Rights in the Work. Further, Affirmer - disclaims responsibility for obtaining any necessary consents, permissions - or other rights required for any use of the Work. - - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to this - CC0 or use of the Work. - -For more information, please see - diff --git a/tests/unit/bats-assert/README.md b/tests/unit/bats-assert/README.md deleted file mode 100644 index 2e60e92..0000000 --- a/tests/unit/bats-assert/README.md +++ /dev/null @@ -1,656 +0,0 @@ -# bats-assert - -[![GitHub license](https://img.shields.io/badge/license-CC0-blue.svg)](https://raw.githubusercontent.com/ztombol/bats-assert/master/LICENSE) -[![GitHub release](https://img.shields.io/github/release/ztombol/bats-assert.svg)](https://github.com/ztombol/bats-assert/releases/latest) -[![Build Status](https://travis-ci.org/ztombol/bats-assert.svg?branch=master)](https://travis-ci.org/ztombol/bats-assert) - -`bats-assert` is a helper library providing common assertions for -[Bats][bats]. - -Assertions are functions that perform a test and output relevant -information on failure to help debugging. They return 1 on failure and 0 -otherwise. Output, [formatted][bats-support-output] for readability, is -sent to the standard error to make assertions usable outside of `@test` -blocks too. - -Assertions testing exit code and output operate on the results of the -most recent invocation of `run`. - -Dependencies: -- [`bats-support`][bats-support] (formerly `bats-core`) - output - formatting - -See the [shared documentation][bats-docs] to learn how to install and -load this library. - - -## Usage - -### `assert` - -Fail if the given expression evaluates to false. - -***Note:*** *The expression must be a simple command. [Compound -commands][bash-comp-cmd], such as `[[`, can be used only when executed -with `bash -c`.* - -```bash -@test 'assert()' { - touch '/var/log/test.log' - assert [ -e '/var/log/test.log' ] -} -``` - -On failure, the failed expression is displayed. - -``` --- assertion failed -- -expression : [ -e /var/log/test.log ] --- -``` - - -### `refute` - -Fail if the given expression evaluates to true. - -***Note:*** *The expression must be a simple command. [Compound -commands][bash-comp-cmd], such as `[[`, can be used only when executed -with `bash -c`.* - -```bash -@test 'refute()' { - rm -f '/var/log/test.log' - refute [ -e '/var/log/test.log' ] -} -``` - -On failure, the successful expression is displayed. - -``` --- assertion succeeded, but it was expected to fail -- -expression : [ -e /var/log/test.log ] --- -``` - - -### `assert_equal` - -Fail if the two parameters, actual and expected value respectively, do -not equal. - -```bash -@test 'assert_equal()' { - assert_equal 'have' 'want' -} -``` - -On failure, the expected and actual values are displayed. - -``` --- values do not equal -- -expected : want -actual : have --- -``` - -If either value is longer than one line both are displayed in -*multi-line* format. - - -### `assert_success` - -Fail if `$status` is not 0. - -```bash -@test 'assert_success() status only' { - run bash -c "echo 'Error!'; exit 1" - assert_success -} -``` - -On failure, `$status` and `$output` are displayed. - -``` --- command failed -- -status : 1 -output : Error! --- -``` - -If `$output` is longer than one line, it is displayed in *multi-line* -format. - - -### `assert_failure` - -Fail if `$status` is 0. - -```bash -@test 'assert_failure() status only' { - run echo 'Success!' - assert_failure -} -``` - -On failure, `$output` is displayed. - -``` --- command succeeded, but it was expected to fail -- -output : Success! --- -``` - -If `$output` is longer than one line, it is displayed in *multi-line* -format. - -#### Expected status - -When one parameter is specified, fail if `$status` does not equal the -expected status specified by the parameter. - -```bash -@test 'assert_failure() with expected status' { - run bash -c "echo 'Error!'; exit 1" - assert_failure 2 -} -``` - -On failure, the expected and actual status, and `$output` are displayed. - -``` --- command failed as expected, but status differs -- -expected : 2 -actual : 1 -output : Error! --- -``` - -If `$output` is longer than one line, it is displayed in *multi-line* -format. - - -### `assert_output` - -This function helps to verify that a command or function produces the -correct output by checking that the specified expected output matches -the actual output. Matching can be literal (default), partial or regular -expression. This function is the logical complement of `refute_output`. - -#### Literal matching - -By default, literal matching is performed. The assertion fails if -`$output` does not equal the expected output. - -```bash -@test 'assert_output()' { - run echo 'have' - assert_output 'want' -} -``` - -The expected output can be specified with a heredoc or standard input as well. - -```bash -@test 'assert_output() with pipe' { - run echo 'have' - echo 'want' | assert_output -} -``` - -On failure, the expected and actual output are displayed. - -``` --- output differs -- -expected : want -actual : have --- -``` - -If either value is longer than one line both are displayed in -*multi-line* format. - -#### Partial matching - -Partial matching can be enabled with the `--partial` option (`-p` for -short). When used, the assertion fails if the expected *substring* is -not found in `$output`. - -```bash -@test 'assert_output() partial matching' { - run echo 'ERROR: no such file or directory' - assert_output --partial 'SUCCESS' -} -``` - -On failure, the substring and the output are displayed. - -``` --- output does not contain substring -- -substring : SUCCESS -output : ERROR: no such file or directory --- -``` - -This option and regular expression matching (`--regexp` or `-e`) are -mutually exclusive. An error is displayed when used simultaneously. - -#### Regular expression matching - -Regular expression matching can be enabled with the `--regexp` option -(`-e` for short). When used, the assertion fails if the *extended -regular expression* does not match `$output`. - -*Note: The anchors `^` and `$` bind to the beginning and the end of the -entire output (not individual lines), respectively.* - -```bash -@test 'assert_output() regular expression matching' { - run echo 'Foobar 0.1.0' - assert_output --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' -} -``` - -On failure, the regular expression and the output are displayed. - -``` --- regular expression does not match output -- -regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ -output : Foobar 0.1.0 --- -``` - -An error is displayed if the specified extended regular expression is -invalid. - -This option and partial matching (`--partial` or `-p`) are mutually -exclusive. An error is displayed when used simultaneously. - - -### `refute_output` - -This function helps to verify that a command or function produces the -correct output by checking that the specified unexpected output does not -match the actual output. Matching can be literal (default), partial or -regular expression. This function is the logical complement of -`assert_output`. - -#### Literal matching - -By default, literal matching is performed. The assertion fails if -`$output` equals the unexpected output. - -```bash -@test 'refute_output()' { - run echo 'want' - refute_output 'want' -} -``` - --The unexpected output can be specified with a heredoc or standard input as well. - -```bash -@test 'refute_output() with pipe' { - run echo 'want' - echo 'want' | refute_output -} -``` - -On failure, the output is displayed. - -``` --- output equals, but it was expected to differ -- -output : want --- -``` - -If output is longer than one line it is displayed in *multi-line* -format. - -#### Partial matching - -Partial matching can be enabled with the `--partial` option (`-p` for -short). When used, the assertion fails if the unexpected *substring* is -found in `$output`. - -```bash -@test 'refute_output() partial matching' { - run echo 'ERROR: no such file or directory' - refute_output --partial 'ERROR' -} -``` - -On failure, the substring and the output are displayed. - -``` --- output should not contain substring -- -substring : ERROR -output : ERROR: no such file or directory --- -``` - -This option and regular expression matching (`--regexp` or `-e`) are -mutually exclusive. An error is displayed when used simultaneously. - -#### Regular expression matching - -Regular expression matching can be enabled with the `--regexp` option -(`-e` for short). When used, the assertion fails if the *extended -regular expression* matches `$output`. - -*Note: The anchors `^` and `$` bind to the beginning and the end of the -entire output (not individual lines), respectively.* - -```bash -@test 'refute_output() regular expression matching' { - run echo 'Foobar v0.1.0' - refute_output --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' -} -``` - -On failure, the regular expression and the output are displayed. - -``` --- regular expression should not match output -- -regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ -output : Foobar v0.1.0 --- -``` - -An error is displayed if the specified extended regular expression is -invalid. - -This option and partial matching (`--partial` or `-p`) are mutually -exclusive. An error is displayed when used simultaneously. - - -### `assert_line` - -Similarly to `assert_output`, this function helps to verify that a -command or function produces the correct output. It checks that the -expected line appears in the output (default) or in a specific line of -it. Matching can be literal (default), partial or regular expression. -This function is the logical complement of `refute_line`. - -***Warning:*** *Due to a [bug in Bats][bats-93], empty lines are -discarded from `${lines[@]}`, causing line indices to change and -preventing testing for empty lines.* - -[bats-93]: https://github.com/sstephenson/bats/pull/93 - -#### Looking for a line in the output - -By default, the entire output is searched for the expected line. The -assertion fails if the expected line is not found in `${lines[@]}`. - -```bash -@test 'assert_line() looking for line' { - run echo $'have-0\nhave-1\nhave-2' - assert_line 'want' -} -``` - -On failure, the expected line and the output are displayed. - -***Warning:*** *The output displayed does not contain empty lines. See -the Warning above for more.* - -``` --- output does not contain line -- -line : want -output (3 lines): - have-0 - have-1 - have-2 --- -``` - -If output is not longer than one line, it is displayed in *two-column* -format. - -#### Matching a specific line - -When the `--index ` option is used (`-n ` for short) , the -expected line is matched only against the line identified by the given -index. The assertion fails if the expected line does not equal -`${lines[]}`. - -```bash -@test 'assert_line() specific line' { - run echo $'have-0\nhave-1\nhave-2' - assert_line --index 1 'want-1' -} -``` - -On failure, the index and the compared lines are displayed. - -``` --- line differs -- -index : 1 -expected : want-1 -actual : have-1 --- -``` - -#### Partial matching - -Partial matching can be enabled with the `--partial` option (`-p` for -short). When used, a match fails if the expected *substring* is not -found in the matched line. - -```bash -@test 'assert_line() partial matching' { - run echo $'have 1\nhave 2\nhave 3' - assert_line --partial 'want' -} -``` - -On failure, the same details are displayed as for literal matching, -except that the substring replaces the expected line. - -``` --- no output line contains substring -- -substring : want -output (3 lines): - have 1 - have 2 - have 3 --- -``` - -This option and regular expression matching (`--regexp` or `-e`) are -mutually exclusive. An error is displayed when used simultaneously. - -#### Regular expression matching - -Regular expression matching can be enabled with the `--regexp` option -(`-e` for short). When used, a match fails if the *extended regular -expression* does not match the line being tested. - -*Note: As expected, the anchors `^` and `$` bind to the beginning and -the end of the matched line, respectively.* - -```bash -@test 'assert_line() regular expression matching' { - run echo $'have-0\nhave-1\nhave-2' - assert_line --index 1 --regexp '^want-[0-9]$' -} -``` - -On failure, the same details are displayed as for literal matching, -except that the regular expression replaces the expected line. - -``` --- regular expression does not match line -- -index : 1 -regexp : ^want-[0-9]$ -line : have-1 --- -``` - -An error is displayed if the specified extended regular expression is -invalid. - -This option and partial matching (`--partial` or `-p`) are mutually -exclusive. An error is displayed when used simultaneously. - - -### `refute_line` - -Similarly to `refute_output`, this function helps to verify that a -command or function produces the correct output. It checks that the -unexpected line does not appear in the output (default) or in a specific -line of it. Matching can be literal (default), partial or regular -expression. This function is the logical complement of `assert_line`. - -***Warning:*** *Due to a [bug in Bats][bats-93], empty lines are -discarded from `${lines[@]}`, causing line indices to change and -preventing testing for empty lines.* - -[bats-93]: https://github.com/sstephenson/bats/pull/93 - -#### Looking for a line in the output - -By default, the entire output is searched for the unexpected line. The -assertion fails if the unexpected line is found in `${lines[@]}`. - -```bash -@test 'refute_line() looking for line' { - run echo $'have-0\nwant\nhave-2' - refute_line 'want' -} -``` - -On failure, the unexpected line, the index of its first match and the -output with the matching line highlighted are displayed. - -***Warning:*** *The output displayed does not contain empty lines. See -the Warning above for more.* - -``` --- line should not be in output -- -line : want -index : 1 -output (3 lines): - have-0 -> want - have-2 --- -``` - -If output is not longer than one line, it is displayed in *two-column* -format. - -#### Matching a specific line - -When the `--index ` option is used (`-n ` for short) , the -unexpected line is matched only against the line identified by the given -index. The assertion fails if the unexpected line equals -`${lines[]}`. - -```bash -@test 'refute_line() specific line' { - run echo $'have-0\nwant-1\nhave-2' - refute_line --index 1 'want-1' -} -``` - -On failure, the index and the unexpected line are displayed. - -``` --- line should differ -- -index : 1 -line : want-1 --- -``` - -#### Partial matching - -Partial matching can be enabled with the `--partial` option (`-p` for -short). When used, a match fails if the unexpected *substring* is found -in the matched line. - -```bash -@test 'refute_line() partial matching' { - run echo $'have 1\nwant 2\nhave 3' - refute_line --partial 'want' -} -``` - -On failure, in addition to the details of literal matching, the -substring is also displayed. When used with `--index ` the -substring replaces the unexpected line. - -``` --- no line should contain substring -- -substring : want -index : 1 -output (3 lines): - have 1 -> want 2 - have 3 --- -``` - -This option and regular expression matching (`--regexp` or `-e`) are -mutually exclusive. An error is displayed when used simultaneously. - -#### Regular expression matching - -Regular expression matching can be enabled with the `--regexp` option -(`-e` for short). When used, a match fails if the *extended regular -expression* matches the line being tested. - -*Note: As expected, the anchors `^` and `$` bind to the beginning and -the end of the matched line, respectively.* - -```bash -@test 'refute_line() regular expression matching' { - run echo $'Foobar v0.1.0\nRelease date: 2015-11-29' - refute_line --index 0 --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' -} -``` - -On failure, in addition to the details of literal matching, the regular -expression is also displayed. When used with `--index ` the regular -expression replaces the unexpected line. - -``` --- regular expression should not match line -- -index : 0 -regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ -line : Foobar v0.1.0 --- -``` - -An error is displayed if the specified extended regular expression is -invalid. - -This option and partial matching (`--partial` or `-p`) are mutually -exclusive. An error is displayed when used simultaneously. - - -## Options - -For functions that have options, `--` disables option parsing for the -remaining arguments to allow using arguments identical to one of the -allowed options. - -```bash -assert_output -- '-p' -``` - -Specifying `--` as an argument is similarly simple. - -```bash -refute_line -- '--' -``` - - - - -[bats]: https://github.com/sstephenson/bats -[bats-support-output]: https://github.com/ztombol/bats-support#output-formatting -[bats-support]: https://github.com/ztombol/bats-support -[bats-docs]: https://github.com/ztombol/bats-docs -[bash-comp-cmd]: https://www.gnu.org/software/bash/manual/bash.html#Compound-Commands diff --git a/tests/unit/bats-assert/load.bash b/tests/unit/bats-assert/load.bash deleted file mode 100644 index ac4a875..0000000 --- a/tests/unit/bats-assert/load.bash +++ /dev/null @@ -1 +0,0 @@ -source "$(dirname "${BASH_SOURCE[0]}")/src/assert.bash" diff --git a/tests/unit/bats-assert/package.json b/tests/unit/bats-assert/package.json deleted file mode 100644 index d81b21c..0000000 --- a/tests/unit/bats-assert/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "bats-assert", - "version": "0.3.0", - "private": true, - "peerDependencies": { - "bats-support": "git+https://github.com/ztombol/bats-support.git#v0.2.0" - } -} diff --git a/tests/unit/bats-assert/script/install-bats.sh b/tests/unit/bats-assert/script/install-bats.sh deleted file mode 100755 index 4c3161a..0000000 --- a/tests/unit/bats-assert/script/install-bats.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -o errexit -set -o xtrace - -git clone --depth 1 https://github.com/sstephenson/bats -cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats diff --git a/tests/unit/bats-assert/src/assert.bash b/tests/unit/bats-assert/src/assert.bash deleted file mode 100644 index 1194753..0000000 --- a/tests/unit/bats-assert/src/assert.bash +++ /dev/null @@ -1,720 +0,0 @@ -# -# bats-assert - Common assertions for Bats -# -# Written in 2016 by Zoltan Tombol -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. -# -# You should have received a copy of the CC0 Public Domain Dedication -# along with this software. If not, see -# . -# - -# -# assert.bash -# ----------- -# -# Assertions are functions that perform a test and output relevant -# information on failure to help debugging. They return 1 on failure -# and 0 otherwise. -# -# All output is formatted for readability using the functions of -# `output.bash' and sent to the standard error. -# - -# Fail and display the expression if it evaluates to false. -# -# NOTE: The expression must be a simple command. Compound commands, such -# as `[[', can be used only when executed with `bash -c'. -# -# Globals: -# none -# Arguments: -# $1 - expression -# Returns: -# 0 - expression evaluates to TRUE -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -assert() { - if ! "$@"; then - batslib_print_kv_single 10 'expression' "$*" \ - | batslib_decorate 'assertion failed' \ - | fail - fi -} - -# Fail and display the expression if it evaluates to true. -# -# NOTE: The expression must be a simple command. Compound commands, such -# as `[[', can be used only when executed with `bash -c'. -# -# Globals: -# none -# Arguments: -# $1 - expression -# Returns: -# 0 - expression evaluates to FALSE -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -refute() { - if "$@"; then - batslib_print_kv_single 10 'expression' "$*" \ - | batslib_decorate 'assertion succeeded, but it was expected to fail' \ - | fail - fi -} - -# Fail and display details if the expected and actual values do not -# equal. Details include both values. -# -# Globals: -# none -# Arguments: -# $1 - actual value -# $2 - expected value -# Returns: -# 0 - values equal -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -assert_equal() { - if [[ $1 != "$2" ]]; then - batslib_print_kv_single_or_multi 8 \ - 'expected' "$2" \ - 'actual' "$1" \ - | batslib_decorate 'values do not equal' \ - | fail - fi -} - -# Fail and display details if `$status' is not 0. Details include -# `$status' and `$output'. -# -# Globals: -# status -# output -# Arguments: -# none -# Returns: -# 0 - `$status' is 0 -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -assert_success() { - if (( status != 0 )); then - { local -ir width=6 - batslib_print_kv_single "$width" 'status' "$status" - batslib_print_kv_single_or_multi "$width" 'output' "$output" - } | batslib_decorate 'command failed' \ - | fail - fi -} - -# Fail and display details if `$status' is 0. Details include `$output'. -# -# Optionally, when the expected status is specified, fail when it does -# not equal `$status'. In this case, details include the expected and -# actual status, and `$output'. -# -# Globals: -# status -# output -# Arguments: -# $1 - [opt] expected status -# Returns: -# 0 - `$status' is not 0, or -# `$status' equals the expected status -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -assert_failure() { - (( $# > 0 )) && local -r expected="$1" - if (( status == 0 )); then - batslib_print_kv_single_or_multi 6 'output' "$output" \ - | batslib_decorate 'command succeeded, but it was expected to fail' \ - | fail - elif (( $# > 0 )) && (( status != expected )); then - { local -ir width=8 - batslib_print_kv_single "$width" \ - 'expected' "$expected" \ - 'actual' "$status" - batslib_print_kv_single_or_multi "$width" \ - 'output' "$output" - } | batslib_decorate 'command failed as expected, but status differs' \ - | fail - fi -} - -# Fail and display details if `$output' does not match the expected -# output. The expected output can be specified either by the first -# parameter or on the standard input. -# -# By default, literal matching is performed. The assertion fails if the -# expected output does not equal `$output'. Details include both values. -# -# Option `--partial' enables partial matching. The assertion fails if -# the expected substring cannot be found in `$output'. -# -# Option `--regexp' enables regular expression matching. The assertion -# fails if the extended regular expression does not match `$output'. An -# invalid regular expression causes an error to be displayed. -# -# It is an error to use partial and regular expression matching -# simultaneously. -# -# Globals: -# output -# Options: -# -p, --partial - partial matching -# -e, --regexp - extended regular expression matching -# Arguments: -# $1 - [=STDIN] expected output -# Returns: -# 0 - expected matches the actual output -# 1 - otherwise -# Inputs: -# STDIN - [=$1] expected output -# Outputs: -# STDERR - details, on failure -# error message, on error -assert_output() { - local -i is_mode_partial=0 - local -i is_mode_regexp=0 - - # Handle options. - while (( $# > 0 )); do - case "$1" in - -p|--partial) is_mode_partial=1; shift ;; - -e|--regexp) is_mode_regexp=1; shift ;; - --) shift; break ;; - *) break ;; - esac - done - - if (( is_mode_partial )) && (( is_mode_regexp )); then - echo "\`--partial' and \`--regexp' are mutually exclusive" \ - | batslib_decorate 'ERROR: assert_output' \ - | fail - return $? - fi - - # Arguments. - local expected - (( $# == 0 )) && expected="$(cat -)" || expected="$1" - - # Matching. - if (( is_mode_regexp )); then - if [[ '' =~ $expected ]] || (( $? == 2 )); then - echo "Invalid extended regular expression: \`$expected'" \ - | batslib_decorate 'ERROR: assert_output' \ - | fail - return $? - fi - if ! [[ $output =~ $expected ]]; then - batslib_print_kv_single_or_multi 6 \ - 'regexp' "$expected" \ - 'output' "$output" \ - | batslib_decorate 'regular expression does not match output' \ - | fail - fi - elif (( is_mode_partial )); then - if [[ $output != *"$expected"* ]]; then - batslib_print_kv_single_or_multi 9 \ - 'substring' "$expected" \ - 'output' "$output" \ - | batslib_decorate 'output does not contain substring' \ - | fail - fi - else - if [[ $output != "$expected" ]]; then - batslib_print_kv_single_or_multi 8 \ - 'expected' "$expected" \ - 'actual' "$output" \ - | batslib_decorate 'output differs' \ - | fail - fi - fi -} - -# Fail and display details if `$output' matches the unexpected output. -# The unexpected output can be specified either by the first parameter -# or on the standard input. -# -# By default, literal matching is performed. The assertion fails if the -# unexpected output equals `$output'. Details include `$output'. -# -# Option `--partial' enables partial matching. The assertion fails if -# the unexpected substring is found in `$output'. The unexpected -# substring is added to details. -# -# Option `--regexp' enables regular expression matching. The assertion -# fails if the extended regular expression does matches `$output'. The -# regular expression is added to details. An invalid regular expression -# causes an error to be displayed. -# -# It is an error to use partial and regular expression matching -# simultaneously. -# -# Globals: -# output -# Options: -# -p, --partial - partial matching -# -e, --regexp - extended regular expression matching -# Arguments: -# $1 - [=STDIN] unexpected output -# Returns: -# 0 - unexpected matches the actual output -# 1 - otherwise -# Inputs: -# STDIN - [=$1] unexpected output -# Outputs: -# STDERR - details, on failure -# error message, on error -refute_output() { - local -i is_mode_partial=0 - local -i is_mode_regexp=0 - - # Handle options. - while (( $# > 0 )); do - case "$1" in - -p|--partial) is_mode_partial=1; shift ;; - -e|--regexp) is_mode_regexp=1; shift ;; - --) shift; break ;; - *) break ;; - esac - done - - if (( is_mode_partial )) && (( is_mode_regexp )); then - echo "\`--partial' and \`--regexp' are mutually exclusive" \ - | batslib_decorate 'ERROR: refute_output' \ - | fail - return $? - fi - - # Arguments. - local unexpected - (( $# == 0 )) && unexpected="$(cat -)" || unexpected="$1" - - if (( is_mode_regexp == 1 )) && [[ '' =~ $unexpected ]] || (( $? == 2 )); then - echo "Invalid extended regular expression: \`$unexpected'" \ - | batslib_decorate 'ERROR: refute_output' \ - | fail - return $? - fi - - # Matching. - if (( is_mode_regexp )); then - if [[ $output =~ $unexpected ]] || (( $? == 0 )); then - batslib_print_kv_single_or_multi 6 \ - 'regexp' "$unexpected" \ - 'output' "$output" \ - | batslib_decorate 'regular expression should not match output' \ - | fail - fi - elif (( is_mode_partial )); then - if [[ $output == *"$unexpected"* ]]; then - batslib_print_kv_single_or_multi 9 \ - 'substring' "$unexpected" \ - 'output' "$output" \ - | batslib_decorate 'output should not contain substring' \ - | fail - fi - else - if [[ $output == "$unexpected" ]]; then - batslib_print_kv_single_or_multi 6 \ - 'output' "$output" \ - | batslib_decorate 'output equals, but it was expected to differ' \ - | fail - fi - fi -} - -# Fail and display details if the expected line is not found in the -# output (default) or in a specific line of it. -# -# By default, the entire output is searched for the expected line. The -# expected line is matched against every element of `${lines[@]}'. If no -# match is found, the assertion fails. Details include the expected line -# and `${lines[@]}'. -# -# When `--index ' is specified, only the -th line is matched. -# If the expected line does not match `${lines[]}', the assertion -# fails. Details include and the compared lines. -# -# By default, literal matching is performed. A literal match fails if -# the expected string does not equal the matched string. -# -# Option `--partial' enables partial matching. A partial match fails if -# the expected substring is not found in the target string. -# -# Option `--regexp' enables regular expression matching. A regular -# expression match fails if the extended regular expression does not -# match the target string. An invalid regular expression causes an error -# to be displayed. -# -# It is an error to use partial and regular expression matching -# simultaneously. -# -# Mandatory arguments to long options are mandatory for short options -# too. -# -# Globals: -# output -# lines -# Options: -# -n, --index - match the -th line -# -p, --partial - partial matching -# -e, --regexp - extended regular expression matching -# Arguments: -# $1 - expected line -# Returns: -# 0 - match found -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -# error message, on error -# FIXME(ztombol): Display `${lines[@]}' instead of `$output'! -assert_line() { - local -i is_match_line=0 - local -i is_mode_partial=0 - local -i is_mode_regexp=0 - - # Handle options. - while (( $# > 0 )); do - case "$1" in - -n|--index) - if (( $# < 2 )) || ! [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then - echo "\`--index' requires an integer argument: \`$2'" \ - | batslib_decorate 'ERROR: assert_line' \ - | fail - return $? - fi - is_match_line=1 - local -ri idx="$2" - shift 2 - ;; - -p|--partial) is_mode_partial=1; shift ;; - -e|--regexp) is_mode_regexp=1; shift ;; - --) shift; break ;; - *) break ;; - esac - done - - if (( is_mode_partial )) && (( is_mode_regexp )); then - echo "\`--partial' and \`--regexp' are mutually exclusive" \ - | batslib_decorate 'ERROR: assert_line' \ - | fail - return $? - fi - - # Arguments. - local -r expected="$1" - - if (( is_mode_regexp == 1 )) && [[ '' =~ $expected ]] || (( $? == 2 )); then - echo "Invalid extended regular expression: \`$expected'" \ - | batslib_decorate 'ERROR: assert_line' \ - | fail - return $? - fi - - # Matching. - if (( is_match_line )); then - # Specific line. - if (( is_mode_regexp )); then - if ! [[ ${lines[$idx]} =~ $expected ]]; then - batslib_print_kv_single 6 \ - 'index' "$idx" \ - 'regexp' "$expected" \ - 'line' "${lines[$idx]}" \ - | batslib_decorate 'regular expression does not match line' \ - | fail - fi - elif (( is_mode_partial )); then - if [[ ${lines[$idx]} != *"$expected"* ]]; then - batslib_print_kv_single 9 \ - 'index' "$idx" \ - 'substring' "$expected" \ - 'line' "${lines[$idx]}" \ - | batslib_decorate 'line does not contain substring' \ - | fail - fi - else - if [[ ${lines[$idx]} != "$expected" ]]; then - batslib_print_kv_single 8 \ - 'index' "$idx" \ - 'expected' "$expected" \ - 'actual' "${lines[$idx]}" \ - | batslib_decorate 'line differs' \ - | fail - fi - fi - else - # Contained in output. - if (( is_mode_regexp )); then - local -i idx - for (( idx = 0; idx < ${#lines[@]}; ++idx )); do - [[ ${lines[$idx]} =~ $expected ]] && return 0 - done - { local -ar single=( - 'regexp' "$expected" - ) - local -ar may_be_multi=( - 'output' "$output" - ) - local -ir width="$( batslib_get_max_single_line_key_width \ - "${single[@]}" "${may_be_multi[@]}" )" - batslib_print_kv_single "$width" "${single[@]}" - batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}" - } | batslib_decorate 'no output line matches regular expression' \ - | fail - elif (( is_mode_partial )); then - local -i idx - for (( idx = 0; idx < ${#lines[@]}; ++idx )); do - [[ ${lines[$idx]} == *"$expected"* ]] && return 0 - done - { local -ar single=( - 'substring' "$expected" - ) - local -ar may_be_multi=( - 'output' "$output" - ) - local -ir width="$( batslib_get_max_single_line_key_width \ - "${single[@]}" "${may_be_multi[@]}" )" - batslib_print_kv_single "$width" "${single[@]}" - batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}" - } | batslib_decorate 'no output line contains substring' \ - | fail - else - local -i idx - for (( idx = 0; idx < ${#lines[@]}; ++idx )); do - [[ ${lines[$idx]} == "$expected" ]] && return 0 - done - { local -ar single=( - 'line' "$expected" - ) - local -ar may_be_multi=( - 'output' "$output" - ) - local -ir width="$( batslib_get_max_single_line_key_width \ - "${single[@]}" "${may_be_multi[@]}" )" - batslib_print_kv_single "$width" "${single[@]}" - batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}" - } | batslib_decorate 'output does not contain line' \ - | fail - fi - fi -} - -# Fail and display details if the unexpected line is found in the output -# (default) or in a specific line of it. -# -# By default, the entire output is searched for the unexpected line. The -# unexpected line is matched against every element of `${lines[@]}'. If -# a match is found, the assertion fails. Details include the unexpected -# line, the index of the first match and `${lines[@]}' with the matching -# line highlighted if `${lines[@]}' is longer than one line. -# -# When `--index ' is specified, only the -th line is matched. -# If the unexpected line matches `${lines[]}', the assertion fails. -# Details include and the unexpected line. -# -# By default, literal matching is performed. A literal match fails if -# the unexpected string does not equal the matched string. -# -# Option `--partial' enables partial matching. A partial match fails if -# the unexpected substring is found in the target string. When used with -# `--index ', the unexpected substring is also displayed on -# failure. -# -# Option `--regexp' enables regular expression matching. A regular -# expression match fails if the extended regular expression matches the -# target string. When used with `--index ', the regular expression -# is also displayed on failure. An invalid regular expression causes an -# error to be displayed. -# -# It is an error to use partial and regular expression matching -# simultaneously. -# -# Mandatory arguments to long options are mandatory for short options -# too. -# -# Globals: -# output -# lines -# Options: -# -n, --index - match the -th line -# -p, --partial - partial matching -# -e, --regexp - extended regular expression matching -# Arguments: -# $1 - unexpected line -# Returns: -# 0 - match not found -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -# error message, on error -# FIXME(ztombol): Display `${lines[@]}' instead of `$output'! -refute_line() { - local -i is_match_line=0 - local -i is_mode_partial=0 - local -i is_mode_regexp=0 - - # Handle options. - while (( $# > 0 )); do - case "$1" in - -n|--index) - if (( $# < 2 )) || ! [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then - echo "\`--index' requires an integer argument: \`$2'" \ - | batslib_decorate 'ERROR: refute_line' \ - | fail - return $? - fi - is_match_line=1 - local -ri idx="$2" - shift 2 - ;; - -p|--partial) is_mode_partial=1; shift ;; - -e|--regexp) is_mode_regexp=1; shift ;; - --) shift; break ;; - *) break ;; - esac - done - - if (( is_mode_partial )) && (( is_mode_regexp )); then - echo "\`--partial' and \`--regexp' are mutually exclusive" \ - | batslib_decorate 'ERROR: refute_line' \ - | fail - return $? - fi - - # Arguments. - local -r unexpected="$1" - - if (( is_mode_regexp == 1 )) && [[ '' =~ $unexpected ]] || (( $? == 2 )); then - echo "Invalid extended regular expression: \`$unexpected'" \ - | batslib_decorate 'ERROR: refute_line' \ - | fail - return $? - fi - - # Matching. - if (( is_match_line )); then - # Specific line. - if (( is_mode_regexp )); then - if [[ ${lines[$idx]} =~ $unexpected ]] || (( $? == 0 )); then - batslib_print_kv_single 6 \ - 'index' "$idx" \ - 'regexp' "$unexpected" \ - 'line' "${lines[$idx]}" \ - | batslib_decorate 'regular expression should not match line' \ - | fail - fi - elif (( is_mode_partial )); then - if [[ ${lines[$idx]} == *"$unexpected"* ]]; then - batslib_print_kv_single 9 \ - 'index' "$idx" \ - 'substring' "$unexpected" \ - 'line' "${lines[$idx]}" \ - | batslib_decorate 'line should not contain substring' \ - | fail - fi - else - if [[ ${lines[$idx]} == "$unexpected" ]]; then - batslib_print_kv_single 5 \ - 'index' "$idx" \ - 'line' "${lines[$idx]}" \ - | batslib_decorate 'line should differ' \ - | fail - fi - fi - else - # Line contained in output. - if (( is_mode_regexp )); then - local -i idx - for (( idx = 0; idx < ${#lines[@]}; ++idx )); do - if [[ ${lines[$idx]} =~ $unexpected ]]; then - { local -ar single=( - 'regexp' "$unexpected" - 'index' "$idx" - ) - local -a may_be_multi=( - 'output' "$output" - ) - local -ir width="$( batslib_get_max_single_line_key_width \ - "${single[@]}" "${may_be_multi[@]}" )" - batslib_print_kv_single "$width" "${single[@]}" - if batslib_is_single_line "${may_be_multi[1]}"; then - batslib_print_kv_single "$width" "${may_be_multi[@]}" - else - may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" \ - | batslib_prefix \ - | batslib_mark '>' "$idx" )" - batslib_print_kv_multi "${may_be_multi[@]}" - fi - } | batslib_decorate 'no line should match the regular expression' \ - | fail - return $? - fi - done - elif (( is_mode_partial )); then - local -i idx - for (( idx = 0; idx < ${#lines[@]}; ++idx )); do - if [[ ${lines[$idx]} == *"$unexpected"* ]]; then - { local -ar single=( - 'substring' "$unexpected" - 'index' "$idx" - ) - local -a may_be_multi=( - 'output' "$output" - ) - local -ir width="$( batslib_get_max_single_line_key_width \ - "${single[@]}" "${may_be_multi[@]}" )" - batslib_print_kv_single "$width" "${single[@]}" - if batslib_is_single_line "${may_be_multi[1]}"; then - batslib_print_kv_single "$width" "${may_be_multi[@]}" - else - may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" \ - | batslib_prefix \ - | batslib_mark '>' "$idx" )" - batslib_print_kv_multi "${may_be_multi[@]}" - fi - } | batslib_decorate 'no line should contain substring' \ - | fail - return $? - fi - done - else - local -i idx - for (( idx = 0; idx < ${#lines[@]}; ++idx )); do - if [[ ${lines[$idx]} == "$unexpected" ]]; then - { local -ar single=( - 'line' "$unexpected" - 'index' "$idx" - ) - local -a may_be_multi=( - 'output' "$output" - ) - local -ir width="$( batslib_get_max_single_line_key_width \ - "${single[@]}" "${may_be_multi[@]}" )" - batslib_print_kv_single "$width" "${single[@]}" - if batslib_is_single_line "${may_be_multi[1]}"; then - batslib_print_kv_single "$width" "${may_be_multi[@]}" - else - may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" \ - | batslib_prefix \ - | batslib_mark '>' "$idx" )" - batslib_print_kv_multi "${may_be_multi[@]}" - fi - } | batslib_decorate 'line should not be in output' \ - | fail - return $? - fi - done - fi - fi -} diff --git a/tests/unit/bats-assert/test/50-assert-11-assert.bats b/tests/unit/bats-assert/test/50-assert-11-assert.bats deleted file mode 100755 index 6b7606b..0000000 --- a/tests/unit/bats-assert/test/50-assert-11-assert.bats +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'assert() : returns 0 if evaluates to TRUE' { - run assert true - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert() : returns 1 and displays if it evaluates to FALSE' { - run assert false - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- assertion failed --' ] - [ "${lines[1]}" == 'expression : false' ] - [ "${lines[2]}" == '--' ] -} diff --git a/tests/unit/bats-assert/test/50-assert-12-assert_equal.bats b/tests/unit/bats-assert/test/50-assert-12-assert_equal.bats deleted file mode 100755 index b21725a..0000000 --- a/tests/unit/bats-assert/test/50-assert-12-assert_equal.bats +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'assert_equal() : returns 0 if equals ' { - run assert_equal 'a' 'a' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_equal() : returns 1 and displays details if does not equal ' { - run assert_equal 'a' 'b' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- values do not equal --' ] - [ "${lines[1]}" == 'expected : b' ] - [ "${lines[2]}" == 'actual : a' ] - [ "${lines[3]}" == '--' ] -} - -@test 'assert_equal() : displays details in multi-line format if is longer than one line' { - run assert_equal $'a 0\na 1' 'b' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- values do not equal --' ] - [ "${lines[1]}" == 'expected (1 lines):' ] - [ "${lines[2]}" == ' b' ] - [ "${lines[3]}" == 'actual (2 lines):' ] - [ "${lines[4]}" == ' a 0' ] - [ "${lines[5]}" == ' a 1' ] - [ "${lines[6]}" == '--' ] -} - -@test 'assert_equal() : displays details in multi-line format if is longer than one line' { - run assert_equal 'a' $'b 0\nb 1' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- values do not equal --' ] - [ "${lines[1]}" == 'expected (2 lines):' ] - [ "${lines[2]}" == ' b 0' ] - [ "${lines[3]}" == ' b 1' ] - [ "${lines[4]}" == 'actual (1 lines):' ] - [ "${lines[5]}" == ' a' ] - [ "${lines[6]}" == '--' ] -} - -@test 'assert_equal() : performs literal matching' { - run assert_equal 'a' '*' - [ "$status" -eq 1 ] -} diff --git a/tests/unit/bats-assert/test/50-assert-13-assert_success.bats b/tests/unit/bats-assert/test/50-assert-13-assert_success.bats deleted file mode 100755 index 6e80caa..0000000 --- a/tests/unit/bats-assert/test/50-assert-13-assert_success.bats +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test "assert_success(): returns 0 if \`\$status' is 0" { - run true - run assert_success - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_success(): returns 1 and displays details if \`\$status' is not 0" { - run bash -c 'echo "a" - exit 1' - run assert_success - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- command failed --' ] - [ "${lines[1]}" == 'status : 1' ] - [ "${lines[2]}" == 'output : a' ] - [ "${lines[3]}" == '--' ] -} - -@test "assert_success(): displays \`\$output' in multi-line format if it is longer than one line" { - run bash -c 'printf "a 0\na 1" - exit 1' - run assert_success - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 6 ] - [ "${lines[0]}" == '-- command failed --' ] - [ "${lines[1]}" == 'status : 1' ] - [ "${lines[2]}" == 'output (2 lines):' ] - [ "${lines[3]}" == ' a 0' ] - [ "${lines[4]}" == ' a 1' ] - [ "${lines[5]}" == '--' ] -} diff --git a/tests/unit/bats-assert/test/50-assert-14-assert_failure.bats b/tests/unit/bats-assert/test/50-assert-14-assert_failure.bats deleted file mode 100755 index fee9685..0000000 --- a/tests/unit/bats-assert/test/50-assert-14-assert_failure.bats +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test "assert_failure(): returns 0 if \`\$status' is not 0" { - run false - run assert_failure - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_failure(): returns 1 and displays details if \`\$status' is 0" { - run bash -c 'echo "a" - exit 0' - run assert_failure - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- command succeeded, but it was expected to fail --' ] - [ "${lines[1]}" == 'output : a' ] - [ "${lines[2]}" == '--' ] -} - -@test "assert_failure(): displays \`\$output' in multi-line format if it is longer then one line" { - run bash -c 'printf "a 0\na 1" - exit 0' - run assert_failure - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- command succeeded, but it was expected to fail --' ] - [ "${lines[1]}" == 'output (2 lines):' ] - [ "${lines[2]}" == ' a 0' ] - [ "${lines[3]}" == ' a 1' ] - [ "${lines[4]}" == '--' ] -} - -@test "assert_failure() : returns 0 if \`\$status' equals " { - run bash -c 'exit 1' - run assert_failure 1 - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_failure() : returns 1 and displays details if \`\$status' does not equal " { - run bash -c 'echo "a" - exit 1' - run assert_failure 2 - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- command failed as expected, but status differs --' ] - [ "${lines[1]}" == 'expected : 2' ] - [ "${lines[2]}" == 'actual : 1' ] - [ "${lines[3]}" == 'output : a' ] - [ "${lines[4]}" == '--' ] -} - -@test "assert_failure() : displays \`\$output' in multi-line format if it is longer then one line" { - run bash -c 'printf "a 0\na 1" - exit 1' - run assert_failure 2 - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- command failed as expected, but status differs --' ] - [ "${lines[1]}" == 'expected : 2' ] - [ "${lines[2]}" == 'actual : 1' ] - [ "${lines[3]}" == 'output (2 lines):' ] - [ "${lines[4]}" == ' a 0' ] - [ "${lines[5]}" == ' a 1' ] - [ "${lines[6]}" == '--' ] -} diff --git a/tests/unit/bats-assert/test/50-assert-15-assert_output.bats b/tests/unit/bats-assert/test/50-assert-15-assert_output.bats deleted file mode 100755 index cca79cc..0000000 --- a/tests/unit/bats-assert/test/50-assert-15-assert_output.bats +++ /dev/null @@ -1,242 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - - -# -# Literal matching -# - -# Correctness -@test "assert_output() : returns 0 if equals \`\$output'" { - run echo 'a' - run assert_output 'a' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_output() : returns 1 and displays details if does not equal \`\$output'" { - run echo 'b' - run assert_output 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- output differs --' ] - [ "${lines[1]}" == 'expected : a' ] - [ "${lines[2]}" == 'actual : b' ] - [ "${lines[3]}" == '--' ] -} - -@test 'assert_output(): reads from STDIN' { - run echo 'a' - run assert_output <: displays details in multi-line format if \`\$output' is longer than one line" { - run printf 'b 0\nb 1' - run assert_output 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- output differs --' ] - [ "${lines[1]}" == 'expected (1 lines):' ] - [ "${lines[2]}" == ' a' ] - [ "${lines[3]}" == 'actual (2 lines):' ] - [ "${lines[4]}" == ' b 0' ] - [ "${lines[5]}" == ' b 1' ] - [ "${lines[6]}" == '--' ] -} - -@test 'assert_output() : displays details in multi-line format if is longer than one line' { - run echo 'b' - run assert_output $'a 0\na 1' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- output differs --' ] - [ "${lines[1]}" == 'expected (2 lines):' ] - [ "${lines[2]}" == ' a 0' ] - [ "${lines[3]}" == ' a 1' ] - [ "${lines[4]}" == 'actual (1 lines):' ] - [ "${lines[5]}" == ' b' ] - [ "${lines[6]}" == '--' ] -} - -# Options -@test 'assert_output() : performs literal matching by default' { - run echo 'a' - run assert_output '*' - [ "$status" -eq 1 ] -} - - -# -# Partial matching: `-p' and `--partial' -# - -# Options -test_p_partial () { - run echo 'abc' - run assert_output "$1" 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_output() -p : enables partial matching' { - test_p_partial -p -} - -@test 'assert_output() --partial : enables partial matching' { - test_p_partial --partial -} - -# Correctness -@test "assert_output() --partial : returns 0 if is a substring in \`\$output'" { - run printf 'a\nb\nc' - run assert_output --partial 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_output() --partial : returns 1 and displays details if is not a substring in \`\$output'" { - run echo 'b' - run assert_output --partial 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- output does not contain substring --' ] - [ "${lines[1]}" == 'substring : a' ] - [ "${lines[2]}" == 'output : b' ] - [ "${lines[3]}" == '--' ] -} - -# Output formatting -@test "assert_output() --partial : displays details in multi-line format if \`\$output' is longer than one line" { - run printf 'b 0\nb 1' - run assert_output --partial 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- output does not contain substring --' ] - [ "${lines[1]}" == 'substring (1 lines):' ] - [ "${lines[2]}" == ' a' ] - [ "${lines[3]}" == 'output (2 lines):' ] - [ "${lines[4]}" == ' b 0' ] - [ "${lines[5]}" == ' b 1' ] - [ "${lines[6]}" == '--' ] -} - -@test 'assert_output() --partial : displays details in multi-line format if is longer than one line' { - run echo 'b' - run assert_output --partial $'a 0\na 1' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- output does not contain substring --' ] - [ "${lines[1]}" == 'substring (2 lines):' ] - [ "${lines[2]}" == ' a 0' ] - [ "${lines[3]}" == ' a 1' ] - [ "${lines[4]}" == 'output (1 lines):' ] - [ "${lines[5]}" == ' b' ] - [ "${lines[6]}" == '--' ] -} - - -# -# Regular expression matching: `-e' and `--regexp' -# - -# Options -test_r_regexp () { - run echo 'abc' - run assert_output "$1" '^a' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_output() -e : enables regular expression matching' { - test_r_regexp -e -} - -@test 'assert_output() --regexp : enables regular expression matching' { - test_r_regexp --regexp -} - -# Correctness -@test "assert_output() --regexp : returns 0 if matches \`\$output'" { - run printf 'a\nb\nc' - run assert_output --regexp '.*b.*' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_output() --regexp : returns 1 and displays details if does not match \`\$output'" { - run echo 'b' - run assert_output --regexp '.*a.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- regular expression does not match output --' ] - [ "${lines[1]}" == 'regexp : .*a.*' ] - [ "${lines[2]}" == 'output : b' ] - [ "${lines[3]}" == '--' ] -} - -# Output formatting -@test "assert_output() --regexp : displays details in multi-line format if \`\$output' is longer than one line" { - run printf 'b 0\nb 1' - run assert_output --regexp '.*a.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- regular expression does not match output --' ] - [ "${lines[1]}" == 'regexp (1 lines):' ] - [ "${lines[2]}" == ' .*a.*' ] - [ "${lines[3]}" == 'output (2 lines):' ] - [ "${lines[4]}" == ' b 0' ] - [ "${lines[5]}" == ' b 1' ] - [ "${lines[6]}" == '--' ] -} - -@test 'assert_output() --regexp : displays details in multi-line format if is longer than one line' { - run echo 'b' - run assert_output --regexp $'.*a\nb.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- regular expression does not match output --' ] - [ "${lines[1]}" == 'regexp (2 lines):' ] - [ "${lines[2]}" == ' .*a' ] - [ "${lines[3]}" == ' b.*' ] - [ "${lines[4]}" == 'output (1 lines):' ] - [ "${lines[5]}" == ' b' ] - [ "${lines[6]}" == '--' ] -} - -# Error handling -@test 'assert_output() --regexp : returns 1 and displays an error message if is not a valid extended regular expression' { - run assert_output --regexp '[.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: assert_output --' ] - [ "${lines[1]}" == "Invalid extended regular expression: \`[.*'" ] - [ "${lines[2]}" == '--' ] -} - - -# -# Common -# - -@test "assert_output(): \`--partial' and \`--regexp' are mutually exclusive" { - run assert_output --partial --regexp - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: assert_output --' ] - [ "${lines[1]}" == "\`--partial' and \`--regexp' are mutually exclusive" ] - [ "${lines[2]}" == '--' ] -} - -@test "assert_output(): \`--' stops parsing options" { - run echo '-p' - run assert_output -- '-p' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} diff --git a/tests/unit/bats-assert/test/50-assert-16-refute_output.bats b/tests/unit/bats-assert/test/50-assert-16-refute_output.bats deleted file mode 100755 index 5204301..0000000 --- a/tests/unit/bats-assert/test/50-assert-16-refute_output.bats +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - - -# -# Literal matching -# - -# Correctness -@test "refute_output() : returns 0 if does not equal \`\$output'" { - run echo 'b' - run refute_output 'a' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_output() : returns 1 and displays details if equals \`\$output'" { - run echo 'a' - run refute_output 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- output equals, but it was expected to differ --' ] - [ "${lines[1]}" == 'output : a' ] - [ "${lines[2]}" == '--' ] -} - -@test 'refute_output(): reads from STDIN' { - run echo 'a' - run refute_output <: displays details in multi-line format if necessary' { - run printf 'a 0\na 1' - run refute_output $'a 0\na 1' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- output equals, but it was expected to differ --' ] - [ "${lines[1]}" == 'output (2 lines):' ] - [ "${lines[2]}" == ' a 0' ] - [ "${lines[3]}" == ' a 1' ] - [ "${lines[4]}" == '--' ] -} - -# Options -@test 'refute_output() : performs literal matching by default' { - run echo 'a' - run refute_output '*' - [ "$status" -eq 0 ] -} - - -# -# Partial matching: `-p' and `--partial' -# - -# Options -test_p_partial () { - run echo 'abc' - run refute_output "$1" 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'refute_output() -p : enables partial matching' { - test_p_partial -p -} - -@test 'refute_output() --partial : enables partial matching' { - test_p_partial --partial -} - -# Correctness -@test "refute_output() --partial : returns 0 if is not a substring in \`\$output'" { - run printf 'a\nb\nc' - run refute_output --partial 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_output() --partial : returns 1 and displays details if is a substring in \`\$output'" { - run echo 'a' - run refute_output --partial 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- output should not contain substring --' ] - [ "${lines[1]}" == 'substring : a' ] - [ "${lines[2]}" == 'output : a' ] - [ "${lines[3]}" == '--' ] -} - -# Output formatting -@test 'refute_output() --partial : displays details in multi-line format if necessary' { - run printf 'a 0\na 1' - run refute_output --partial 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- output should not contain substring --' ] - [ "${lines[1]}" == 'substring (1 lines):' ] - [ "${lines[2]}" == ' a' ] - [ "${lines[3]}" == 'output (2 lines):' ] - [ "${lines[4]}" == ' a 0' ] - [ "${lines[5]}" == ' a 1' ] - [ "${lines[6]}" == '--' ] -} - - -# -# Regular expression matching: `-e' and `--regexp' -# - -# Options -test_r_regexp () { - run echo 'abc' - run refute_output "$1" '^d' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'refute_output() -e : enables regular expression matching' { - test_r_regexp -e -} - -@test 'refute_output() --regexp : enables regular expression matching' { - test_r_regexp --regexp -} - -# Correctness -@test "refute_output() --regexp : returns 0 if does not match \`\$output'" { - run printf 'a\nb\nc' - run refute_output --regexp '.*d.*' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_output() --regexp : returns 1 and displays details if matches \`\$output'" { - run echo 'a' - run refute_output --regexp '.*a.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- regular expression should not match output --' ] - [ "${lines[1]}" == 'regexp : .*a.*' ] - [ "${lines[2]}" == 'output : a' ] - [ "${lines[3]}" == '--' ] -} - -# Output formatting -@test 'refute_output() --regexp : displays details in multi-line format if necessary' { - run printf 'a 0\na 1' - run refute_output --regexp '.*a.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 7 ] - [ "${lines[0]}" == '-- regular expression should not match output --' ] - [ "${lines[1]}" == 'regexp (1 lines):' ] - [ "${lines[2]}" == ' .*a.*' ] - [ "${lines[3]}" == 'output (2 lines):' ] - [ "${lines[4]}" == ' a 0' ] - [ "${lines[5]}" == ' a 1' ] - [ "${lines[6]}" == '--' ] -} - -# Error handling -@test 'refute_output() --regexp : returns 1 and displays an error message if is not a valid extended regular expression' { - run refute_output --regexp '[.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: refute_output --' ] - [ "${lines[1]}" == "Invalid extended regular expression: \`[.*'" ] - [ "${lines[2]}" == '--' ] -} - - -# -# Common -# - -@test "refute_output(): \`--partial' and \`--regexp' are mutually exclusive" { - run refute_output --partial --regexp - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: refute_output --' ] - [ "${lines[1]}" == "\`--partial' and \`--regexp' are mutually exclusive" ] - [ "${lines[2]}" == '--' ] -} - -@test "refute_output(): \`--' stops parsing options" { - run echo '--' - run refute_output -- '-p' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} diff --git a/tests/unit/bats-assert/test/50-assert-17-assert_line.bats b/tests/unit/bats-assert/test/50-assert-17-assert_line.bats deleted file mode 100755 index bee3850..0000000 --- a/tests/unit/bats-assert/test/50-assert-17-assert_line.bats +++ /dev/null @@ -1,334 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - - -############################################################################### -# Containing a line -############################################################################### - -# -# Literal matching -# - -# Correctness -@test "assert_line() : returns 0 if is a line in \`\${lines[@]}'" { - run printf 'a\nb\nc' - run assert_line 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_line() : returns 1 and displays details if is not a line in \`\${lines[@]}'" { - run echo 'b' - run assert_line 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- output does not contain line --' ] - [ "${lines[1]}" == 'line : a' ] - [ "${lines[2]}" == 'output : b' ] - [ "${lines[3]}" == '--' ] -} - -# Output formatting -@test "assert_line() : displays \`\$output' in multi-line format if it is longer than one line" { - run printf 'b 0\nb 1' - run assert_line 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 6 ] - [ "${lines[0]}" == '-- output does not contain line --' ] - [ "${lines[1]}" == 'line : a' ] - [ "${lines[2]}" == 'output (2 lines):' ] - [ "${lines[3]}" == ' b 0' ] - [ "${lines[4]}" == ' b 1' ] - [ "${lines[5]}" == '--' ] -} - -# Options -@test 'assert_line() : performs literal matching by default' { - run echo 'a' - run assert_line '*' - [ "$status" -eq 1 ] -} - - -# -# Partial matching: `-p' and `--partial' -# - -# Options -test_p_partial () { - run printf 'a\n_b_\nc' - run assert_line "$1" 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_line() -p : enables partial matching' { - test_p_partial -p -} - -@test 'assert_line() --partial : enables partial matching' { - test_p_partial --partial -} - -# Correctness -@test "assert_line() --partial : returns 0 if is a substring in any line in \`\${lines[@]}'" { - run printf 'a\n_b_\nc' - run assert_line --partial 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_line() --partial : returns 1 and displays details if is not a substring in any lines in \`\${lines[@]}'" { - run echo 'b' - run assert_line --partial 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- no output line contains substring --' ] - [ "${lines[1]}" == 'substring : a' ] - [ "${lines[2]}" == 'output : b' ] - [ "${lines[3]}" == '--' ] -} - -# Output formatting -@test "assert_line() --partial : displays \`\$output' in multi-line format if it is longer than one line" { - run printf 'b 0\nb 1' - run assert_line --partial 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 6 ] - [ "${lines[0]}" == '-- no output line contains substring --' ] - [ "${lines[1]}" == 'substring : a' ] - [ "${lines[2]}" == 'output (2 lines):' ] - [ "${lines[3]}" == ' b 0' ] - [ "${lines[4]}" == ' b 1' ] - [ "${lines[5]}" == '--' ] -} - - -# -# Regular expression matching: `-e' and `--regexp' -# - -# Options -test_r_regexp () { - run printf 'a\n_b_\nc' - run assert_line "$1" '^.b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_line() -e : enables regular expression matching' { - test_r_regexp -e -} - -@test 'assert_line() --regexp : enables regular expression matching' { - test_r_regexp --regexp -} - -# Correctness -@test "assert_line() --regexp : returns 0 if matches any line in \`\${lines[@]}'" { - run printf 'a\n_b_\nc' - run assert_line --regexp '^.b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_line() --regexp : returns 1 and displays details if does not match any lines in \`\${lines[@]}'" { - run echo 'b' - run assert_line --regexp '^.a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- no output line matches regular expression --' ] - [ "${lines[1]}" == 'regexp : ^.a' ] - [ "${lines[2]}" == 'output : b' ] - [ "${lines[3]}" == '--' ] -} - -# Output formatting -@test "assert_line() --regexp : displays \`\$output' in multi-line format if longer than one line" { - run printf 'b 0\nb 1' - run assert_line --regexp '^.a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 6 ] - [ "${lines[0]}" == '-- no output line matches regular expression --' ] - [ "${lines[1]}" == 'regexp : ^.a' ] - [ "${lines[2]}" == 'output (2 lines):' ] - [ "${lines[3]}" == ' b 0' ] - [ "${lines[4]}" == ' b 1' ] - [ "${lines[5]}" == '--' ] -} - - -############################################################################### -# Matching single line: `-n' and `--index' -############################################################################### - -# Options -test_n_index () { - run printf 'a\nb\nc' - run assert_line "$1" 1 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_line() -n : matches against the -th line only' { - test_n_index -n -} - -@test 'assert_line() --index : matches against the -th line only' { - test_n_index --index -} - -@test 'assert_line() --index : returns 1 and displays an error message if is not an integer' { - run assert_line --index 1a - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: assert_line --' ] - [ "${lines[1]}" == "\`--index' requires an integer argument: \`1a'" ] - [ "${lines[2]}" == '--' ] -} - - -# -# Literal matching -# - -# Correctness -@test "assert_line() --index : returns 0 if equals \`\${lines[]}'" { - run printf 'a\nb\nc' - run assert_line --index 1 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_line() --index : returns 1 and displays details if does not equal \`\${lines[]}'" { - run printf 'a\nb\nc' - run assert_line --index 1 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- line differs --' ] - [ "${lines[1]}" == 'index : 1' ] - [ "${lines[2]}" == 'expected : a' ] - [ "${lines[3]}" == 'actual : b' ] - [ "${lines[4]}" == '--' ] -} - -# Options -@test 'assert_line() --index : performs literal matching by default' { - run printf 'a\nb\nc' - run assert_line --index 1 '*' - [ "$status" -eq 1 ] -} - - -# -# Partial matching: `-p' and `--partial' -# - -# Options -test_index_p_partial () { - run printf 'a\n_b_\nc' - run assert_line --index 1 "$1" 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_line() --index -p : enables partial matching' { - test_index_p_partial -p -} - -@test 'assert_line() --index --partial : enables partial matching' { - test_index_p_partial --partial -} - -# Correctness -@test "assert_line() --index --partial : returns 0 if is a substring in \`\${lines[]}'" { - run printf 'a\n_b_\nc' - run assert_line --index 1 --partial 'b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_line() --index --partial : returns 1 and displays details if is not a substring in \`\${lines[]}'" { - run printf 'b 0\nb 1' - run assert_line --index 1 --partial 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- line does not contain substring --' ] - [ "${lines[1]}" == 'index : 1' ] - [ "${lines[2]}" == 'substring : a' ] - [ "${lines[3]}" == 'line : b 1' ] - [ "${lines[4]}" == '--' ] -} - - -# -# Regular expression matching: `-e' and `--regexp' -# - -# Options -test_index_r_regexp () { - run printf 'a\n_b_\nc' - run assert_line --index 1 "$1" '^.b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_line() --index -e : enables regular expression matching' { - test_index_r_regexp -e -} - -@test 'assert_line() --index --regexp : enables regular expression matching' { - test_index_r_regexp --regexp -} - -# Correctness -@test "assert_line() --index --regexp : returns 0 if matches \`\${lines[]}'" { - run printf 'a\n_b_\nc' - run assert_line --index 1 --regexp '^.b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "assert_line() --index --regexp : returns 1 and displays details if does not match \`\${lines[]}'" { - run printf 'a\nb\nc' - run assert_line --index 1 --regexp '^.a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- regular expression does not match line --' ] - [ "${lines[1]}" == 'index : 1' ] - [ "${lines[2]}" == 'regexp : ^.a' ] - [ "${lines[3]}" == 'line : b' ] - [ "${lines[4]}" == '--' ] -} - - -############################################################################### -# Common -############################################################################### - -@test "assert_line(): \`--partial' and \`--regexp' are mutually exclusive" { - run assert_line --partial --regexp - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: assert_line --' ] - [ "${lines[1]}" == "\`--partial' and \`--regexp' are mutually exclusive" ] - [ "${lines[2]}" == '--' ] -} - -@test 'assert_line() --regexp : returns 1 and displays an error message if is not a valid extended regular expression' { - run assert_line --regexp '[.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: assert_line --' ] - [ "${lines[1]}" == "Invalid extended regular expression: \`[.*'" ] - [ "${lines[2]}" == '--' ] -} - -@test "assert_line(): \`--' stops parsing options" { - run printf 'a\n-p\nc' - run assert_line -- '-p' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} diff --git a/tests/unit/bats-assert/test/50-assert-18-refute_line.bats b/tests/unit/bats-assert/test/50-assert-18-refute_line.bats deleted file mode 100755 index 9cc8185..0000000 --- a/tests/unit/bats-assert/test/50-assert-18-refute_line.bats +++ /dev/null @@ -1,342 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - - -############################################################################### -# Containing a line -############################################################################### - -# -# Literal matching -# - -# Correctness -@test "refute_line() : returns 0 if is not a line in \`\${lines[@]}'" { - run printf 'a\nb\nc' - run refute_line 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_line() : returns 1 and displays details if is not a line in \`\${lines[@]}'" { - run echo 'a' - run refute_line 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- line should not be in output --' ] - [ "${lines[1]}" == 'line : a' ] - [ "${lines[2]}" == 'index : 0' ] - [ "${lines[3]}" == 'output : a' ] - [ "${lines[4]}" == '--' ] -} - -# Output formatting -@test "refute_line() : displays \`\$output' in multi-line format if it is longer than one line" { - run printf 'a 0\na 1\na 2' - run refute_line 'a 1' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 8 ] - [ "${lines[0]}" == '-- line should not be in output --' ] - [ "${lines[1]}" == 'line : a 1' ] - [ "${lines[2]}" == 'index : 1' ] - [ "${lines[3]}" == 'output (3 lines):' ] - [ "${lines[4]}" == ' a 0' ] - [ "${lines[5]}" == '> a 1' ] - [ "${lines[6]}" == ' a 2' ] - [ "${lines[7]}" == '--' ] -} - -# Options -@test 'refute_line() : performs literal matching by default' { - run echo 'a' - run refute_line '*' - [ "$status" -eq 0 ] -} - - -# -# Partial matching: `-p' and `--partial' -# - -# Options -test_p_partial () { - run printf 'a\nb\nc' - run refute_line "$1" 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'refute_line() -p : enables partial matching' { - test_p_partial -p -} - -@test 'refute_line() --partial : enables partial matching' { - test_p_partial --partial -} - -# Correctness -@test "refute_line() --partial : returns 0 if is not a substring in any line in \`\${lines[@]}'" { - run printf 'a\nb\nc' - run refute_line --partial 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_line() --partial : returns 1 and displays details if is a substring in any line in \`\${lines[@]}'" { - run echo 'a' - run refute_line --partial 'a' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- no line should contain substring --' ] - [ "${lines[1]}" == 'substring : a' ] - [ "${lines[2]}" == 'index : 0' ] - [ "${lines[3]}" == 'output : a' ] - [ "${lines[4]}" == '--' ] -} - -# Output formatting -@test "refute_line() --partial : displays \`\$output' in multi-line format if it is longer than one line" { - run printf 'a\nabc\nc' - run refute_line --partial 'b' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 8 ] - [ "${lines[0]}" == '-- no line should contain substring --' ] - [ "${lines[1]}" == 'substring : b' ] - [ "${lines[2]}" == 'index : 1' ] - [ "${lines[3]}" == 'output (3 lines):' ] - [ "${lines[4]}" == ' a' ] - [ "${lines[5]}" == '> abc' ] - [ "${lines[6]}" == ' c' ] - [ "${lines[7]}" == '--' ] -} - - -# -# Regular expression matching: `-e' and `--regexp' -# - -# Options -test_r_regexp () { - run printf 'a\nb\nc' - run refute_line "$1" '^.d' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'refute_line() -e : enables regular expression matching' { - test_r_regexp -e -} - -@test 'refute_line() --regexp : enables regular expression matching' { - test_r_regexp --regexp -} - -# Correctness -@test "refute_line() --regexp : returns 0 if does not match any line in \`\${lines[@]}'" { - run printf 'a\nb\nc' - run refute_line --regexp '.*d.*' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_line() --regexp : returns 1 and displays details if matches any lines in \`\${lines[@]}'" { - run echo 'a' - run refute_line --regexp '.*a.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- no line should match the regular expression --' ] - [ "${lines[1]}" == 'regexp : .*a.*' ] - [ "${lines[2]}" == 'index : 0' ] - [ "${lines[3]}" == 'output : a' ] - [ "${lines[4]}" == '--' ] -} - -# Output formatting -@test "refute_line() --regexp : displays \`\$output' in multi-line format if longer than one line" { - run printf 'a\nabc\nc' - run refute_line --regexp '.*b.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 8 ] - [ "${lines[0]}" == '-- no line should match the regular expression --' ] - [ "${lines[1]}" == 'regexp : .*b.*' ] - [ "${lines[2]}" == 'index : 1' ] - [ "${lines[3]}" == 'output (3 lines):' ] - [ "${lines[4]}" == ' a' ] - [ "${lines[5]}" == '> abc' ] - [ "${lines[6]}" == ' c' ] - [ "${lines[7]}" == '--' ] -} - - -############################################################################### -# Matching single line: `-n' and `--index' -############################################################################### - -# Options -test_n_index () { - run printf 'a\nb\nc' - run refute_line "$1" 1 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'refute_line() -n : matches against the -th line only' { - test_n_index -n -} - -@test 'refute_line() --index : matches against the -th line only' { - test_n_index --index -} - -@test 'refute_line() --index : returns 1 and displays an error message if is not an integer' { - run refute_line --index 1a - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: refute_line --' ] - [ "${lines[1]}" == "\`--index' requires an integer argument: \`1a'" ] - [ "${lines[2]}" == '--' ] -} - - -# -# Literal matching -# - -# Correctness -@test "refute_line() --index : returns 0 if does not equal \`\${lines[]}'" { - run printf 'a\nb\nc' - run refute_line --index 1 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_line() --index : returns 1 and displays details if equals \`\${lines[]}'" { - run printf 'a\nb\nc' - run refute_line --index 1 'b' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == '-- line should differ --' ] - [ "${lines[1]}" == 'index : 1' ] - [ "${lines[2]}" == 'line : b' ] - [ "${lines[3]}" == '--' ] -} - -# Options -@test 'refute_line() --index : performs literal matching by default' { - run printf 'a\nb\nc' - run refute_line --index 1 '*' - [ "$status" -eq 0 ] -} - - -# -# Partial matching: `-p' and `--partial' -# - -# Options -test_index_p_partial () { - run printf 'a\nb\nc' - run refute_line --index 1 "$1" 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'refute_line() --index -p : enables partial matching' { - test_index_p_partial -p -} - -@test 'refute_line() --index --partial : enables partial matching' { - test_index_p_partial --partial -} - -# Correctness -@test "refute_line() --index --partial : returns 0 if is not a substring in \`\${lines[]}'" { - run printf 'a\nabc\nc' - run refute_line --index 1 --partial 'd' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_line() --index --partial : returns 1 and displays details if is a substring in \`\${lines[]}'" { - run printf 'a\nabc\nc' - run refute_line --index 1 --partial 'b' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- line should not contain substring --' ] - [ "${lines[1]}" == 'index : 1' ] - [ "${lines[2]}" == 'substring : b' ] - [ "${lines[3]}" == 'line : abc' ] - [ "${lines[4]}" == '--' ] -} - - -# -# Regular expression matching: `-e' and `--regexp' -# - -# Options -test_index_r_regexp () { - run printf 'a\nb\nc' - run refute_line --index 1 "$1" '^.b' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'refute_line() --index -e : enables regular expression matching' { - test_index_r_regexp -e -} - -@test 'refute_line() --index --regexp : enables regular expression matching' { - test_index_r_regexp --regexp -} - -# Correctness -@test "refute_line() --index --regexp : returns 0 if does not match \`\${lines[]}'" { - run printf 'a\nabc\nc' - run refute_line --index 1 --regexp '.*d.*' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test "refute_line() --index --regexp : returns 1 and displays details if matches \`\${lines[]}'" { - run printf 'a\nabc\nc' - run refute_line --index 1 --regexp '.*b.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 5 ] - [ "${lines[0]}" == '-- regular expression should not match line --' ] - [ "${lines[1]}" == 'index : 1' ] - [ "${lines[2]}" == 'regexp : .*b.*' ] - [ "${lines[3]}" == 'line : abc' ] - [ "${lines[4]}" == '--' ] -} - - -############################################################################### -# Common -############################################################################### - -@test "refute_line(): \`--partial' and \`--regexp' are mutually exclusive" { - run refute_line --partial --regexp - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: refute_line --' ] - [ "${lines[1]}" == "\`--partial' and \`--regexp' are mutually exclusive" ] - [ "${lines[2]}" == '--' ] -} - -@test 'refute_line() --regexp : returns 1 and displays an error message if is not a valid extended regular expression' { - run refute_line --regexp '[.*' - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: refute_line --' ] - [ "${lines[1]}" == "Invalid extended regular expression: \`[.*'" ] - [ "${lines[2]}" == '--' ] -} - -@test "refute_line(): \`--' stops parsing options" { - run printf 'a\n--\nc' - run refute_line -- '-p' - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} diff --git a/tests/unit/bats-assert/test/50-assert-19-refute.bats b/tests/unit/bats-assert/test/50-assert-19-refute.bats deleted file mode 100755 index 191dc73..0000000 --- a/tests/unit/bats-assert/test/50-assert-19-refute.bats +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'refute() : returns 0 if evaluates to FALSE' { - run refute false - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'refute() : returns 1 and displays if it evaluates to TRUE' { - run refute true - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- assertion succeeded, but it was expected to fail --' ] - [ "${lines[1]}" == 'expression : true' ] - [ "${lines[2]}" == '--' ] -} diff --git a/tests/unit/bats-assert/test/test_helper.bash b/tests/unit/bats-assert/test/test_helper.bash deleted file mode 100644 index 32ad846..0000000 --- a/tests/unit/bats-assert/test/test_helper.bash +++ /dev/null @@ -1,10 +0,0 @@ -setup() { - export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." - export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/..}" - - # Load dependencies. - load "${TEST_DEPS_DIR}/bats-support/load.bash" - - # Load library. - load '../load' -} diff --git a/tests/unit/bats-file/.travis.yml b/tests/unit/bats-file/.travis.yml deleted file mode 100644 index e56169a..0000000 --- a/tests/unit/bats-file/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: bash -before_install: - - ./script/install-bats.sh - - git clone --depth 1 https://github.com/ztombol/bats-support ../bats-support -before_script: - - export PATH="${HOME}/.local/bin:${PATH}" -script: - - bats test diff --git a/tests/unit/bats-file/CHANGELOG.md b/tests/unit/bats-file/CHANGELOG.md deleted file mode 100644 index 049740a..0000000 --- a/tests/unit/bats-file/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -This project adheres to [Semantic Versioning](http://semver.org/). - - -## [0.2.0] - 2016-12-07 - -### Added - -- Handling temporary directories with `temp_make()` and `temp_del()` - -### Fixed - -- Function comments listing path transformation variables incorrectly - - -## 0.1.0 - 2016-03-22 - -### Added - -- Testing file existence with `assert_file_exist` and - `assert_file_not_exist` -- `npm` support - - -[0.2.0]: https://github.com/ztombol/bats-file/compare/v0.1.0...v0.2.0 diff --git a/tests/unit/bats-file/LICENSE b/tests/unit/bats-file/LICENSE deleted file mode 100644 index 670154e..0000000 --- a/tests/unit/bats-file/LICENSE +++ /dev/null @@ -1,116 +0,0 @@ -CC0 1.0 Universal - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator and -subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for the -purpose of contributing to a commons of creative, cultural and scientific -works ("Commons") that the public can reliably and without fear of later -claims of infringement build upon, modify, incorporate in other works, reuse -and redistribute as freely as possible in any form whatsoever and for any -purposes, including without limitation commercial purposes. These owners may -contribute to the Commons to promote the ideal of a free culture and the -further production of creative, cultural and scientific works, or to gain -reputation or greater distribution for their Work in part through the use and -efforts of others. - -For these and/or other purposes and motivations, and without any expectation -of additional consideration or compensation, the person associating CC0 with a -Work (the "Affirmer"), to the extent that he or she is an owner of Copyright -and Related Rights in the Work, voluntarily elects to apply CC0 to the Work -and publicly distribute the Work under its terms, with knowledge of his or her -Copyright and Related Rights in the Work and the meaning and intended legal -effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not limited -to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, communicate, - and translate a Work; - - ii. moral rights retained by the original author(s) and/or performer(s); - - iii. publicity and privacy rights pertaining to a person's image or likeness - depicted in a Work; - - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - - v. rights protecting the extraction, dissemination, use and reuse of data in - a Work; - - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation thereof, - including any amended or successor version of such directive); and - - vii. other similar, equivalent or corresponding rights throughout the world - based on applicable law or treaty, and any national implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention of, -applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and -unconditionally waives, abandons, and surrenders all of Affirmer's Copyright -and Related Rights and associated claims and causes of action, whether now -known or unknown (including existing as well as future claims and causes of -action), in the Work (i) in all territories worldwide, (ii) for the maximum -duration provided by applicable law or treaty (including future time -extensions), (iii) in any current or future medium and for any number of -copies, and (iv) for any purpose whatsoever, including without limitation -commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes -the Waiver for the benefit of each member of the public at large and to the -detriment of Affirmer's heirs and successors, fully intending that such Waiver -shall not be subject to revocation, rescission, cancellation, termination, or -any other legal or equitable action to disrupt the quiet enjoyment of the Work -by the public as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason be -judged legally invalid or ineffective under applicable law, then the Waiver -shall be preserved to the maximum extent permitted taking into account -Affirmer's express Statement of Purpose. In addition, to the extent the Waiver -is so judged Affirmer hereby grants to each affected person a royalty-free, -non transferable, non sublicensable, non exclusive, irrevocable and -unconditional license to exercise Affirmer's Copyright and Related Rights in -the Work (i) in all territories worldwide, (ii) for the maximum duration -provided by applicable law or treaty (including future time extensions), (iii) -in any current or future medium and for any number of copies, and (iv) for any -purpose whatsoever, including without limitation commercial, advertising or -promotional purposes (the "License"). The License shall be deemed effective as -of the date CC0 was applied by Affirmer to the Work. Should any part of the -License for any reason be judged legally invalid or ineffective under -applicable law, such partial invalidity or ineffectiveness shall not -invalidate the remainder of the License, and in such case Affirmer hereby -affirms that he or she will not (i) exercise any of his or her remaining -Copyright and Related Rights in the Work or (ii) assert any associated claims -and causes of action with respect to the Work, in either case contrary to -Affirmer's express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - - b. Affirmer offers the Work as-is and makes no representations or warranties - of any kind concerning the Work, express, implied, statutory or otherwise, - including without limitation warranties of title, merchantability, fitness - for a particular purpose, non infringement, or the absence of latent or - other defects, accuracy, or the present or absence of errors, whether or not - discoverable, all to the greatest extent permissible under applicable law. - - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without limitation - any person's Copyright and Related Rights in the Work. Further, Affirmer - disclaims responsibility for obtaining any necessary consents, permissions - or other rights required for any use of the Work. - - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to this - CC0 or use of the Work. - -For more information, please see - diff --git a/tests/unit/bats-file/README.md b/tests/unit/bats-file/README.md deleted file mode 100644 index 820b368..0000000 --- a/tests/unit/bats-file/README.md +++ /dev/null @@ -1,236 +0,0 @@ -# bats-file - -[![GitHub license](https://img.shields.io/badge/license-CC0-blue.svg)](https://raw.githubusercontent.com/ztombol/bats-file/master/LICENSE) -[![GitHub release](https://img.shields.io/github/release/ztombol/bats-file.svg)](https://github.com/ztombol/bats-file/releases/latest) -[![Build Status](https://travis-ci.org/ztombol/bats-file.svg?branch=master)](https://travis-ci.org/ztombol/bats-file) - -`bats-file` is a helper library providing common filesystem related -assertions and helpers for [Bats][bats]. - -Assertions are functions that perform a test and output relevant -information on failure to help debugging. They return 1 on failure and 0 -otherwise. Output, [formatted][bats-support-output] for readability, is -sent to the standard error to make assertions usable outside of `@test` -blocks too. - -Features: -- [assertions](#usage) -- [temporary directory handling](#working-with-temporary-directories) - -Dependencies: -- [`bats-support`][bats-support] - output formatting, function call - restriction - -See the [shared documentation][bats-docs] to learn how to install and -load this library. - - -## Usage - -### `assert_file_exist` - -Fail if the given file or directory does not exist. - -```bash -@test 'assert_file_exist()' { - assert_file_exist /path/to/non-existent-file -} -``` - -On failure, the path is displayed. - -``` --- file does not exist -- -path : /path/to/non-existent-file --- -``` - - -### `assert_file_not_exist` - -Fail if the given file or directory exists. - -```bash -@test 'assert_file_not_exist() { - assert_file_not_exist /path/to/existing-file -} -``` - -On failure, the path is displayed. - -``` --- file exists, but it was expected to be absent -- -path : /path/to/existing-file --- -``` - - -## Working with temporary directories - -When testing code that manipulates the filesystem, it is good practice -to run tests in clean, throw-away environments to ensure correctness and -reproducibility. Therefore, this library includes convenient functions -to create and destroy temporary directories. - - -### `temp_make` - -Create a temporary directory for the current test in `BATS_TMPDIR`. The -directory is guaranteed to be unique and its name is derived from the -test's filename and number for easy identification. - -``` --- -``` - -This information is only available in `setup`, `@test` and `teardown`, -thus the function must be called from one of these locations. - -The path of the directory is displayed on the standard output and is -meant to be captured into a variable. - -```bash -setup() { - TEST_TEMP_DIR="$(temp_make)" -} -``` - -For example, for the first test in `sample.bats`, this snippet creates a -directory named `sample.bats-1-XXXXXXXXXX`, where each trailing `X` is a -random alphanumeric character. - -If the directory cannot be created, the function fails and displays an -error message on the standard error. - -``` --- ERROR: temp_make -- -mktemp: failed to create directory via template ‘/etc/samle.bats-1-XXXXXXXXXX’: Permission denied --- -``` - -#### Directory name prefix - -The directory name can be prefixed with an arbitrary string using the `--prefix -` option (`-p ` for short). - -```bash -setup() { - TEST_TEMP_DIR="$(temp_make --prefix 'myapp-')" -} -``` - -Following the previous example, this will create a directory named -`myapp-sample.bats-1-XXXXXXXXXX`. This can be used to group temporary -directories. - -Generally speaking, the directory name is of the following form. - -``` --- -``` - - -### `temp_del` - -Delete a temporary directory, typically created with `temp_make`. - -```bash -teardown() { - temp_del "$TEST_TEMP_DIR" -} -``` - -If the directory cannot be deleted, the function fails and displays an -error message on the standard error. - -``` --- ERROR: temp_del -- -rm: cannot remove '/etc/samle.bats-1-04RUVmBP7x': No such file or directory --- -``` - -_**Note:** Actually, this function can be used to delete any file or -directory. However, it is most useful in deleting temporary directories -created with `temp_make`, hence the naming._ - -#### Preserve directory - -During development, it is useful to peak into temporary directories -post-mortem to see what the tested code has done. - -When `BATSLIB_TEMP_PRESERVE` is set to 1, the function succeeds but the -directory is not deleted. - -```bash -$ BATSLIB_TEMP_PRESERVE=1 bats sample.bats -``` - -#### Preserve directory on failure - -During debugging, it is useful to preserve the temporary directories of -failing tests. - -When `BATSLIB_TEMP_PRESERVE_ON_FAILURE` is set to 1, the function -succeeds but the directory is not deleted if the test has failed. - -```bash -$ BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 bats sample.bats -``` - -The outcome of a test is only known in `teardown`, therefore this -feature can be used only when `temp_del` is called from that location. -Otherwise and error is displayed on the standard error. - - -## Transforming displayed paths - -Sometimes paths can be long and tiresome to parse to the human eye. To -help focus on the interesting bits, all functions support hiding part of -the displayed paths by replacing it with an arbitrary string. - -A single [pattern substitution][bash-pe] is performed on the path before -displaying it. - -``` -${path/$BATSLIB_FILE_PATH_REM/$BATSLIB_FILE_PATH_ADD} -``` - -The longest match of the pattern `BATSLIB_FILE_PATH_REM` is replaced -with `BATSLIB_FILE_PATH_ADD`. To anchor the pattern to the beginning or -the end, prepend `#` or `%`, respectively. - -For example, the following example hides the path of the temporary -directory where the test takes place. - -```bash -setup { - TEST_TEMP_DIR="$(temp_make)" - BATSLIB_FILE_PATH_REM="#${TEST_TEMP_DIR}" - BATSLIB_FILE_PATH_ADD='' -} - -@test 'assert_file_exist()' { - assert_file_exist "${TEST_TEMP_DIR}/path/to/non-existent-file" -} - -teardown() { - temp_del "$TEST_TEMP_DIR" -} -``` - -On failure, only the relevant part of the path is shown. - -``` --- file does not exist -- -path : /path/to/non-existent-file --- -``` - - - - -[bats]: https://github.com/sstephenson/bats -[bats-support-output]: https://github.com/ztombol/bats-support#output-formatting -[bats-support]: https://github.com/ztombol/bats-support -[bats-docs]: https://github.com/ztombol/bats-docs -[bash-pe]: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html diff --git a/tests/unit/bats-file/load.bash b/tests/unit/bats-file/load.bash deleted file mode 100644 index bf0c4cf..0000000 --- a/tests/unit/bats-file/load.bash +++ /dev/null @@ -1,2 +0,0 @@ -source "$(dirname "${BASH_SOURCE[0]}")/src/file.bash" -source "$(dirname "${BASH_SOURCE[0]}")/src/temp.bash" diff --git a/tests/unit/bats-file/package.json b/tests/unit/bats-file/package.json deleted file mode 100644 index ae1b5ff..0000000 --- a/tests/unit/bats-file/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "bats-file", - "version": "0.2.0", - "private": true, - "peerDependencies": { - "bats-support": "git+https://github.com/ztombol/bats-support.git#v0.3.0" - } -} diff --git a/tests/unit/bats-file/script/install-bats.sh b/tests/unit/bats-file/script/install-bats.sh deleted file mode 100755 index 4c3161a..0000000 --- a/tests/unit/bats-file/script/install-bats.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -o errexit -set -o xtrace - -git clone --depth 1 https://github.com/sstephenson/bats -cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats diff --git a/tests/unit/bats-file/src/file.bash b/tests/unit/bats-file/src/file.bash deleted file mode 100644 index 70e168c..0000000 --- a/tests/unit/bats-file/src/file.bash +++ /dev/null @@ -1,74 +0,0 @@ -# -# bats-file - Common filesystem assertions and helpers for Bats -# -# Written in 2016 by Zoltan Tombol -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. -# -# You should have received a copy of the CC0 Public Domain Dedication -# along with this software. If not, see -# . -# - -# -# file.bash -# --------- -# -# Assertions are functions that perform a test and output relevant -# information on failure to help debugging. They return 1 on failure -# and 0 otherwise. -# -# All output is formatted for readability using the functions of -# `output.bash' and sent to the standard error. -# - -# Fail and display path of the file (or directory) if it does not exist. -# This function is the logical complement of `assert_file_not_exist'. -# -# Globals: -# BATSLIB_FILE_PATH_REM -# BATSLIB_FILE_PATH_ADD -# Arguments: -# $1 - path -# Returns: -# 0 - file exists -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -assert_file_exist() { - local -r file="$1" - if [[ ! -e "$file" ]]; then - local -r rem="$BATSLIB_FILE_PATH_REM" - local -r add="$BATSLIB_FILE_PATH_ADD" - batslib_print_kv_single 4 'path' "${file/$rem/$add}" \ - | batslib_decorate 'file does not exist' \ - | fail - fi -} - -# Fail and display path of the file (or directory) if it exists. This -# function is the logical complement of `assert_file_exist'. -# -# Globals: -# BATSLIB_FILE_PATH_REM -# BATSLIB_FILE_PATH_ADD -# Arguments: -# $1 - path -# Returns: -# 0 - file does not exist -# 1 - otherwise -# Outputs: -# STDERR - details, on failure -assert_file_not_exist() { - local -r file="$1" - if [[ -e "$file" ]]; then - local -r rem="$BATSLIB_FILE_PATH_REM" - local -r add="$BATSLIB_FILE_PATH_ADD" - batslib_print_kv_single 4 'path' "${file/$rem/$add}" \ - | batslib_decorate 'file exists, but it was expected to be absent' \ - | fail - fi -} diff --git a/tests/unit/bats-file/src/temp.bash b/tests/unit/bats-file/src/temp.bash deleted file mode 100644 index 1361836..0000000 --- a/tests/unit/bats-file/src/temp.bash +++ /dev/null @@ -1,178 +0,0 @@ -# -# bats-file - Common filesystem assertions and helpers for Bats -# -# Written in 2016 by Zoltan Tombol -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. -# -# You should have received a copy of the CC0 Public Domain Dedication -# along with this software. If not, see -# . -# - -# -# temp.bash -# --------- -# -# Functions for handling temporary directories. -# - -# Create a temporary directory for the current test in `BATS_TMPDIR`, -# and display its path on the standard output. -# -# The directory name is derived from the test's filename and number, and -# a random string for uniqueness. -# -# -- -# -# When `--prefix ' is specified, `' is prepended to the -# directory name. -# -# -- -# -# Must be called from `setup', `@test' or `teardown'. -# -# Example: -# -# setup() { -# TEST_TEMP_DIR="$(temp_make --prefix 'myapp-')" -# } -# -# teardown() { -# temp_del "$TEST_TEMP_DIR" -# } -# -# Globals: -# BATS_TEST_NAME -# BATS_TEST_FILENAME -# BATS_TEST_NUMBER -# BATS_TMPDIR -# Arguments: -# none -# Options: -# -p, --prefix - prefix the directory name with `' -# Returns: -# 0 - on success -# 1 - otherwise -# Outputs: -# STDOUT - path of temporary directory -# STDERR - error messages -temp_make() { - # Check caller. - if ! ( batslib_is_caller --indirect 'setup' \ - || batslib_is_caller --indirect "$BATS_TEST_NAME" \ - || batslib_is_caller --indirect 'teardown' ) - then - echo "Must be called from \`setup', \`@test' or \`teardown'" \ - | batslib_decorate 'ERROR: temp_make' \ - | fail - return $? - fi - - # Handle options. - local prefix='' - - while (( $# > 0 )); do - case "$1" in - -p|--prefix) - if (( $# < 2 )); then - echo "\`--prefix' requires an argument" \ - | batslib_decorate 'ERROR: temp_make' \ - | fail - return $? - fi - prefix="$2" - shift 2 - ;; - --) shift; break ;; - *) break ;; - esac - done - - # Create directory. - local template="$prefix" - template+="${BATS_TEST_FILENAME##*/}" - template+="-${BATS_TEST_NUMBER}" - template+='-XXXXXXXXXX' - - local path - path="$(mktemp --directory --tmpdir="$BATS_TMPDIR" -- "$template" 2>&1)" - if (( $? )); then - echo "$path" \ - | batslib_decorate 'ERROR: temp_make' \ - | fail - return $? - fi - - echo "$path" -} - -# Delete a temporary directory, typically created with `temp_make', and -# its contents. -# -# Note: Actually, this function can be used to delete any file or -# directory. However, it is most useful in deleting temporary -# directories created with `temp_make', hence the naming. -# -# For development and debugging, deletion can be prevented using -# environment variables. -# -# When `BATSLIB_TEMP_PRESERVE' is set to 1, the function succeeds but -# the directory is not deleted. -# -# When `BATSLIB_TEMP_PRESERVE_ON_FAILURE' is set to 1 and `temp_del' is -# called, directly or indirectly, from `teardown', the function succeeds -# but the directory is not deleted if the test has failed. -# -# Example: -# -# setup() { -# TEST_TEMP_DIR="$(temp_make --prefix 'myapp-')" -# } -# -# teardown() { -# temp_del "$TEST_TEMP_DIR" -# } -# -# Globals: -# BATSLIB_TEMP_PRESERVE -# BATSLIB_TEMP_PRESERVE_ON_FAILURE -# BATS_TEST_COMPLETED -# Arguments: -# $1 - path of directory -# Returns: -# 0 - on success -# 1 - otherwise -# Outputs: -# STDERR - error messages -temp_del() { - local -r path="$1" - - # Environment variables. - if [[ $BATSLIB_TEMP_PRESERVE == '1' ]]; then - return 0 - elif [[ $BATSLIB_TEMP_PRESERVE_ON_FAILURE == '1' ]]; then - # Check caller. - if ! batslib_is_caller --indirect 'teardown'; then - echo "Must be called from \`teardown' when using \`BATSLIB_TEMP_PRESERVE_ON_FAILURE'" \ - | batslib_decorate 'ERROR: temp_del' \ - | fail - return $? - fi - - (( BATS_TEST_COMPLETED != 1 )) && return 0 - fi - - # Delete directory. - local result - result="$(rm -r -- "$path" 2>&1)" - if (( $? )); then - echo "$result" \ - | batslib_decorate 'ERROR: temp_del' \ - | fail - return $? - fi -} diff --git a/tests/unit/bats-file/test/50-assert-10-assert_file_exist.bats b/tests/unit/bats-file/test/50-assert-10-assert_file_exist.bats deleted file mode 100755 index 85aaa16..0000000 --- a/tests/unit/bats-file/test/50-assert-10-assert_file_exist.bats +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' -fixtures 'exist' - -# Correctness -@test 'assert_file_exist() : returns 0 if exists' { - local -r file="${TEST_FIXTURE_ROOT}/dir/file" - run assert_file_exist "$file" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_file_exist() : returns 1 and displays path if does not exist' { - local -r file="${TEST_FIXTURE_ROOT}/dir/file.does_not_exist" - run assert_file_exist "$file" - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- file does not exist --' ] - [ "${lines[1]}" == "path : $file" ] - [ "${lines[2]}" == '--' ] -} - -# Transforming path -@test 'assert_file_exist() : replace prefix of displayed path' { - local -r BATSLIB_FILE_PATH_REM="#${TEST_FIXTURE_ROOT}" - local -r BATSLIB_FILE_PATH_ADD='..' - run assert_file_exist "${TEST_FIXTURE_ROOT}/dir/file.does_not_exist" - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- file does not exist --' ] - [ "${lines[1]}" == "path : ../dir/file.does_not_exist" ] - [ "${lines[2]}" == '--' ] -} - -@test 'assert_file_exist() : replace suffix of displayed path' { - local -r BATSLIB_FILE_PATH_REM='%file.does_not_exist' - local -r BATSLIB_FILE_PATH_ADD='..' - run assert_file_exist "${TEST_FIXTURE_ROOT}/dir/file.does_not_exist" - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- file does not exist --' ] - [ "${lines[1]}" == "path : ${TEST_FIXTURE_ROOT}/dir/.." ] - [ "${lines[2]}" == '--' ] -} - -@test 'assert_file_exist() : replace infix of displayed path' { - local -r BATSLIB_FILE_PATH_REM='dir' - local -r BATSLIB_FILE_PATH_ADD='..' - run assert_file_exist "${TEST_FIXTURE_ROOT}/dir/file.does_not_exist" - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- file does not exist --' ] - [ "${lines[1]}" == "path : ${TEST_FIXTURE_ROOT}/../file.does_not_exist" ] - [ "${lines[2]}" == '--' ] -} diff --git a/tests/unit/bats-file/test/50-assert-11-assert_file_not_exist.bats b/tests/unit/bats-file/test/50-assert-11-assert_file_not_exist.bats deleted file mode 100755 index 5310fc3..0000000 --- a/tests/unit/bats-file/test/50-assert-11-assert_file_not_exist.bats +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' -fixtures 'exist' - -# Correctness -@test 'assert_file_not_exist() : returns 0 if does not exist' { - local -r file="${TEST_FIXTURE_ROOT}/dir/file.does_not_exist" - run assert_file_not_exist "$file" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'assert_file_not_exist() : returns 1 and displays path if exists' { - local -r file="${TEST_FIXTURE_ROOT}/dir/file" - run assert_file_not_exist "$file" - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- file exists, but it was expected to be absent --' ] - [ "${lines[1]}" == "path : $file" ] - [ "${lines[2]}" == '--' ] -} - -# Transforming path -@test 'assert_file_not_exist() : replace prefix of displayed path' { - local -r BATSLIB_FILE_PATH_REM="#${TEST_FIXTURE_ROOT}" - local -r BATSLIB_FILE_PATH_ADD='..' - run assert_file_not_exist "${TEST_FIXTURE_ROOT}/dir/file" - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- file exists, but it was expected to be absent --' ] - [ "${lines[1]}" == "path : ../dir/file" ] - [ "${lines[2]}" == '--' ] -} - -@test 'assert_file_not_exist() : replace suffix of displayed path' { - local -r BATSLIB_FILE_PATH_REM='%file' - local -r BATSLIB_FILE_PATH_ADD='..' - run assert_file_not_exist "${TEST_FIXTURE_ROOT}/dir/file" - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- file exists, but it was expected to be absent --' ] - [ "${lines[1]}" == "path : ${TEST_FIXTURE_ROOT}/dir/.." ] - [ "${lines[2]}" == '--' ] -} - -@test 'assert_file_not_exist() : replace infix of displayed path' { - local -r BATSLIB_FILE_PATH_REM='dir' - local -r BATSLIB_FILE_PATH_ADD='..' - run assert_file_not_exist "${TEST_FIXTURE_ROOT}/dir/file" - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- file exists, but it was expected to be absent --' ] - [ "${lines[1]}" == "path : ${TEST_FIXTURE_ROOT}/../file" ] - [ "${lines[2]}" == '--' ] -} diff --git a/tests/unit/bats-file/test/51-temp-10-temp_make.bats b/tests/unit/bats-file/test/51-temp-10-temp_make.bats deleted file mode 100755 index 30048c1..0000000 --- a/tests/unit/bats-file/test/51-temp-10-temp_make.bats +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' -fixtures 'temp' - - -# Correctness -@test 'temp_make() : returns 0, creates a temporary directory and displays its path' { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make)" - - local -r literal="${BATS_TMPDIR}/${BATS_TEST_FILENAME##*/}-" - local -r pattern='[1-9][0-9]*-.{10}' - [[ $TEST_TEMP_DIR =~ ^"${literal}"${pattern}$ ]] || false - [ -e "$TEST_TEMP_DIR" ] -} - -@test 'temp_make() : returns 1 and displays an error message if the directory can not be created' { - local -r BATS_TMPDIR='/does/not/exist' - run temp_make - - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: temp_make --' ] - [[ ${lines[1]} == 'mktemp: failed to create directory via template'* ]] || false - [ "${lines[2]}" == '--' ] -} - -@test "temp_make() : works when called from \`setup'" { - bats "${TEST_FIXTURE_ROOT}/temp_make-setup.bats" -} - -@test "temp_make() : works when called from \`@test'" { - bats "${TEST_FIXTURE_ROOT}/temp_make-test.bats" -} - -@test "temp_make() : works when called from \`teardown'" { - bats "${TEST_FIXTURE_ROOT}/temp_make-teardown.bats" -} - -@test "temp_make() : does not work when called from \`main'" { - run bats "${TEST_FIXTURE_ROOT}/temp_make-main.bats" - - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: temp_make --' ] - [ "${lines[1]}" == "Must be called from \`setup', \`@test' or \`teardown'" ] - [ "${lines[2]}" == '--' ] -} - -# Options -test_p_prefix() { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make "$@" 'test-')" - - local -r literal="${BATS_TMPDIR}/test-${BATS_TEST_FILENAME##*/}-" - local -r pattern='[1-9][0-9]*-.{10}' - [[ $TEST_TEMP_DIR =~ ^"${literal}"${pattern}$ ]] || false - [ -e "$TEST_TEMP_DIR" ] -} - -@test 'temp_make() -p : returns 0 and creates a temporary directory with prefix' { - test_p_prefix -p -} - -@test 'temp_make() --prefix : returns 0 and creates a temporary directory with prefix' { - test_p_prefix --prefix -} - -@test "temp_make() --prefix : works if starts with a \`-'" { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make --prefix -)" - - [ -e "$TEST_TEMP_DIR" ] -} diff --git a/tests/unit/bats-file/test/51-temp-11-temp_del.bats b/tests/unit/bats-file/test/51-temp-11-temp_del.bats deleted file mode 100755 index 7349508..0000000 --- a/tests/unit/bats-file/test/51-temp-11-temp_del.bats +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' -fixtures 'temp' - - -# Correctness -@test 'temp_del() : returns 0 and deletes ' { - TEST_TEMP_DIR="$(temp_make)" - run temp_del "$TEST_TEMP_DIR" - - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] - [ ! -e "$TEST_TEMP_DIR" ] -} - -@test 'temp_del() : returns 1 and displays an error message if can not be deleted' { - local -r path="${TEST_FIXTURE_ROOT}/does/not/exist" - run temp_del "$path" - - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: temp_del --' ] - # Travis CI's Ubuntu 12.04, quotes the path with a backtick and an - # apostrophe, instead of just apostrophes. - [[ ${lines[1]} =~ 'rm: cannot remove '[\`\']"${path}': No such file or directory" ]] - [ "${lines[2]}" == '--' ] -} - -@test "temp_del() : works if starts with a \`-'" { - TEST_TEMP_DIR="$(temp_make --prefix -)" - run temp_del "$TEST_TEMP_DIR" - - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] - [ ! -e "$TEST_TEMP_DIR" ] -} - -# Environment variables -@test "temp_del() : returns 0 and does not delete if \`BATSLIB_TEMP_PRESERVE' is set to \`1'" { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make)" - local -r BATSLIB_TEMP_PRESERVE=1 - run temp_del "$TEST_TEMP_DIR" - - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] - [ -e "$TEST_TEMP_DIR" ] -} - -@test "temp_del() : returns 0 and does not delete if \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' is set to \`1' and the test have failed" { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make)" - export TEST_TEMP_DIR - run bats "${TEST_FIXTURE_ROOT}/temp_del-fail.bats" - - [ "$status" -eq 1 ] - [ -e "$TEST_TEMP_DIR" ] -} - -@test "temp_del() : returns 0 and deletes if \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' is set to \`1' and the test have passed" { - TEST_TEMP_DIR="$(temp_make)" - export TEST_TEMP_DIR - run bats "${TEST_FIXTURE_ROOT}/temp_del-pass.bats" - - [ "$status" -eq 0 ] - [ ! -e "$TEST_TEMP_DIR" ] -} - -@test "temp_del() : returns 0 and deletes if \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' is set to \`1' and the test have been skipped" { - TEST_TEMP_DIR="$(temp_make)" - export TEST_TEMP_DIR - run bats "${TEST_FIXTURE_ROOT}/temp_del-skip.bats" - - [ "$status" -eq 0 ] - [ ! -e "$TEST_TEMP_DIR" ] -} - -@test "temp_del() : \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' works when called from \`teardown'" { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make)" - export TEST_TEMP_DIR - run bats "${TEST_FIXTURE_ROOT}/temp_del-teardown.bats" - - [ "$status" -eq 1 ] - [ -e "$TEST_TEMP_DIR" ] -} - -@test "temp_del() : \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' does not work when called from \`main'" { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make)" - export TEST_TEMP_DIR - run bats "${TEST_FIXTURE_ROOT}/temp_del-main.bats" - - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- ERROR: temp_del --' ] - [ "${lines[1]}" == "Must be called from \`teardown' when using \`BATSLIB_TEMP_PRESERVE_ON_FAILURE'" ] - [ "${lines[2]}" == '--' ] -} - -@test "temp_del() : \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' does not work when called from \`setup'" { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make)" - export TEST_TEMP_DIR - run bats "${TEST_FIXTURE_ROOT}/temp_del-setup.bats" - - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 10 ] - [[ ${lines[6]} == *'-- ERROR: temp_del --' ]] || false - [[ ${lines[7]} == *"Must be called from \`teardown' when using \`BATSLIB_TEMP_PRESERVE_ON_FAILURE'" ]] || false - [[ ${lines[8]} == *'--' ]] || false -} - -@test "temp_del() : \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' does not work when called from \`@test'" { - teardown() { rm -r -- "$TEST_TEMP_DIR"; } - - TEST_TEMP_DIR="$(temp_make)" - export TEST_TEMP_DIR - run bats "${TEST_FIXTURE_ROOT}/temp_del-test.bats" - - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 10 ] - [[ ${lines[6]} == *'-- ERROR: temp_del --' ]] || false - [[ ${lines[7]} == *"Must be called from \`teardown' when using \`BATSLIB_TEMP_PRESERVE_ON_FAILURE'" ]] || false - [[ ${lines[8]} == *'--' ]] || false -} diff --git a/tests/unit/bats-file/test/fixtures/exist/dir/file b/tests/unit/bats-file/test/fixtures/exist/dir/file deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_del-fail.bats b/tests/unit/bats-file/test/fixtures/temp/temp_del-fail.bats deleted file mode 100644 index 1e67402..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_del-fail.bats +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -@test "temp_del() : returns 0 and does not delete if \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' is set to \`1' and the test have failed" { - false -} - -teardown() { - local -ir BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 - temp_del "$TEST_TEMP_DIR" -} diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_del-main.bats b/tests/unit/bats-file/test/fixtures/temp/temp_del-main.bats deleted file mode 100644 index e2576d9..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_del-main.bats +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 -temp_del "$TEST_TEMP_DIR" diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_del-pass.bats b/tests/unit/bats-file/test/fixtures/temp/temp_del-pass.bats deleted file mode 100644 index 6d45ab8..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_del-pass.bats +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -@test "temp_del() : returns 0 and deletes if \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' is set to \`1' and the test have passed" { - true -} - -teardown() { - local -ir BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 - temp_del "$TEST_TEMP_DIR" -} diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_del-setup.bats b/tests/unit/bats-file/test/fixtures/temp/temp_del-setup.bats deleted file mode 100644 index 7dca32f..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_del-setup.bats +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -setup() { - local -ir BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 - temp_del "$TEST_TEMP_DIR" -} - -@test "temp_del() : \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' does not work when called from \`setup'" { - true -} diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_del-skip.bats b/tests/unit/bats-file/test/fixtures/temp/temp_del-skip.bats deleted file mode 100644 index 89f11ae..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_del-skip.bats +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -@test "temp_del() : returns 0 and deletes if \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' is set to \`1' and the test have been skipped" { - skip -} - -teardown() { - local -ir BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 - temp_del "$TEST_TEMP_DIR" -} diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_del-teardown.bats b/tests/unit/bats-file/test/fixtures/temp/temp_del-teardown.bats deleted file mode 100644 index ada91cd..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_del-teardown.bats +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -@test "temp_del() : \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' works when called from \`teardown'" { - false -} - -teardown() { - local -ir BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 - temp_del "$TEST_TEMP_DIR" -} diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_del-test.bats b/tests/unit/bats-file/test/fixtures/temp/temp_del-test.bats deleted file mode 100644 index 0dbe126..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_del-test.bats +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -@test "temp_del() : \`BATSLIB_TEMP_PRESERVE_ON_FAILURE' does not work when called from \`@test'" { - local -ir BATSLIB_TEMP_PRESERVE_ON_FAILURE=1 - temp_del "$TEST_TEMP_DIR" -} diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_make-main.bats b/tests/unit/bats-file/test/fixtures/temp/temp_make-main.bats deleted file mode 100644 index e0226a0..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_make-main.bats +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -TEST_TEMP_DIR="$(temp_make)" diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_make-setup.bats b/tests/unit/bats-file/test/fixtures/temp/temp_make-setup.bats deleted file mode 100644 index 5a4e953..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_make-setup.bats +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -setup() { - TEST_TEMP_DIR="$(temp_make)" -} - -@test "temp_make() : works when called from \`setup'" { - true -} - -teardown() { - rm -r -- "$TEST_TEMP_DIR" -} diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_make-teardown.bats b/tests/unit/bats-file/test/fixtures/temp/temp_make-teardown.bats deleted file mode 100644 index 95efa34..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_make-teardown.bats +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -@test "temp_make() : works when called from \`teardown'" { - true -} - -teardown() { - TEST_TEMP_DIR="$(temp_make)" - rm -r -- "$TEST_TEMP_DIR" -} diff --git a/tests/unit/bats-file/test/fixtures/temp/temp_make-test.bats b/tests/unit/bats-file/test/fixtures/temp/temp_make-test.bats deleted file mode 100644 index cb892de..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/temp_make-test.bats +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - -@test "temp_make() : works when called from \`@test'" { - TEST_TEMP_DIR="$(temp_make)" -} - -teardown() { - rm -r -- "$TEST_TEMP_DIR" -} diff --git a/tests/unit/bats-file/test/fixtures/temp/test_helper.bash b/tests/unit/bats-file/test/fixtures/temp/test_helper.bash deleted file mode 100644 index d6e0846..0000000 --- a/tests/unit/bats-file/test/fixtures/temp/test_helper.bash +++ /dev/null @@ -1,8 +0,0 @@ -export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/../../.." -export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/..}" - -# Load dependencies. -load "${TEST_DEPS_DIR}/bats-support/load.bash" - -# Load library. -load "${TEST_MAIN_DIR}/load.bash" diff --git a/tests/unit/bats-file/test/test_helper.bash b/tests/unit/bats-file/test/test_helper.bash deleted file mode 100644 index 3ae57b0..0000000 --- a/tests/unit/bats-file/test/test_helper.bash +++ /dev/null @@ -1,25 +0,0 @@ -# Set variables for easily accessing sub-directories of `./fixtures'. -# -# Globals: -# BATS_TEST_DIRNAME -# TEST_FIXTURE_ROOT -# TEST_RELATIVE_FIXTURE_ROOT -# Arguments: -# $1 - name of sub-directory -# Returns: -# none -fixtures() { - TEST_FIXTURE_ROOT="${BATS_TEST_DIRNAME}/fixtures/$1" - TEST_RELATIVE_FIXTURE_ROOT="$(bats_trim_filename "${TEST_FIXTURE_ROOT}")" -} - -setup() { - export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." - export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/..}" - - # Load dependencies. - load "${TEST_DEPS_DIR}/bats-support/load.bash" - - # Load library. - load '../load' -} diff --git a/tests/unit/bats-support/.travis.yml b/tests/unit/bats-support/.travis.yml deleted file mode 100644 index 75721f2..0000000 --- a/tests/unit/bats-support/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: bash -before_install: - - ./script/install-bats.sh -before_script: - - export PATH="${HOME}/.local/bin:${PATH}" -script: - - bats test diff --git a/tests/unit/bats-support/CHANGELOG.md b/tests/unit/bats-support/CHANGELOG.md deleted file mode 100644 index 324d247..0000000 --- a/tests/unit/bats-support/CHANGELOG.md +++ /dev/null @@ -1,46 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -This project adheres to [Semantic Versioning](http://semver.org/). - - -## [0.3.0] - 2016-11-29 - -### Added - -- Restricting invocation to specific locations with - `batslib_is_caller()` - - -## [0.2.0] - 2016-03-22 - -### Added - -- `npm` support -- Reporting arbitrary failures with `fail()` (moved from `bats-assert`) - -### Changed - -- Library renamed to `bats-support` - - -## 0.1.0 - 2016-02-16 - -### Added - -- Two-column key-value formatting with `batslib_print_kv_single()` -- Multi-line key-value formatting with `batslib_print_kv_multi()` -- Mixed formatting with `batslib_print_kv_single_or_multi()` -- Header and footer decoration with `batslib_decorate()` -- Prefixing lines with `batslib_prefix()` -- Marking lines with `batslib_mark()` -- Common output function `batslib_err()` -- Line counting with `batslib_count_lines()` -- Checking whether a text is one line long with - `batslib_is_single_line()` -- Determining key width for two-column and mixed formatting with - `batslib_get_max_single_line_key_width()` - - -[0.3.0]: https://github.com/ztombol/bats-support/compare/v0.2.0...v0.3.0 -[0.2.0]: https://github.com/ztombol/bats-support/compare/v0.1.0...v0.2.0 diff --git a/tests/unit/bats-support/LICENSE b/tests/unit/bats-support/LICENSE deleted file mode 100644 index 670154e..0000000 --- a/tests/unit/bats-support/LICENSE +++ /dev/null @@ -1,116 +0,0 @@ -CC0 1.0 Universal - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator and -subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for the -purpose of contributing to a commons of creative, cultural and scientific -works ("Commons") that the public can reliably and without fear of later -claims of infringement build upon, modify, incorporate in other works, reuse -and redistribute as freely as possible in any form whatsoever and for any -purposes, including without limitation commercial purposes. These owners may -contribute to the Commons to promote the ideal of a free culture and the -further production of creative, cultural and scientific works, or to gain -reputation or greater distribution for their Work in part through the use and -efforts of others. - -For these and/or other purposes and motivations, and without any expectation -of additional consideration or compensation, the person associating CC0 with a -Work (the "Affirmer"), to the extent that he or she is an owner of Copyright -and Related Rights in the Work, voluntarily elects to apply CC0 to the Work -and publicly distribute the Work under its terms, with knowledge of his or her -Copyright and Related Rights in the Work and the meaning and intended legal -effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not limited -to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, communicate, - and translate a Work; - - ii. moral rights retained by the original author(s) and/or performer(s); - - iii. publicity and privacy rights pertaining to a person's image or likeness - depicted in a Work; - - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - - v. rights protecting the extraction, dissemination, use and reuse of data in - a Work; - - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation thereof, - including any amended or successor version of such directive); and - - vii. other similar, equivalent or corresponding rights throughout the world - based on applicable law or treaty, and any national implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention of, -applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and -unconditionally waives, abandons, and surrenders all of Affirmer's Copyright -and Related Rights and associated claims and causes of action, whether now -known or unknown (including existing as well as future claims and causes of -action), in the Work (i) in all territories worldwide, (ii) for the maximum -duration provided by applicable law or treaty (including future time -extensions), (iii) in any current or future medium and for any number of -copies, and (iv) for any purpose whatsoever, including without limitation -commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes -the Waiver for the benefit of each member of the public at large and to the -detriment of Affirmer's heirs and successors, fully intending that such Waiver -shall not be subject to revocation, rescission, cancellation, termination, or -any other legal or equitable action to disrupt the quiet enjoyment of the Work -by the public as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason be -judged legally invalid or ineffective under applicable law, then the Waiver -shall be preserved to the maximum extent permitted taking into account -Affirmer's express Statement of Purpose. In addition, to the extent the Waiver -is so judged Affirmer hereby grants to each affected person a royalty-free, -non transferable, non sublicensable, non exclusive, irrevocable and -unconditional license to exercise Affirmer's Copyright and Related Rights in -the Work (i) in all territories worldwide, (ii) for the maximum duration -provided by applicable law or treaty (including future time extensions), (iii) -in any current or future medium and for any number of copies, and (iv) for any -purpose whatsoever, including without limitation commercial, advertising or -promotional purposes (the "License"). The License shall be deemed effective as -of the date CC0 was applied by Affirmer to the Work. Should any part of the -License for any reason be judged legally invalid or ineffective under -applicable law, such partial invalidity or ineffectiveness shall not -invalidate the remainder of the License, and in such case Affirmer hereby -affirms that he or she will not (i) exercise any of his or her remaining -Copyright and Related Rights in the Work or (ii) assert any associated claims -and causes of action with respect to the Work, in either case contrary to -Affirmer's express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - - b. Affirmer offers the Work as-is and makes no representations or warranties - of any kind concerning the Work, express, implied, statutory or otherwise, - including without limitation warranties of title, merchantability, fitness - for a particular purpose, non infringement, or the absence of latent or - other defects, accuracy, or the present or absence of errors, whether or not - discoverable, all to the greatest extent permissible under applicable law. - - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without limitation - any person's Copyright and Related Rights in the Work. Further, Affirmer - disclaims responsibility for obtaining any necessary consents, permissions - or other rights required for any use of the Work. - - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to this - CC0 or use of the Work. - -For more information, please see - diff --git a/tests/unit/bats-support/README.md b/tests/unit/bats-support/README.md deleted file mode 100644 index 71c02ba..0000000 --- a/tests/unit/bats-support/README.md +++ /dev/null @@ -1,189 +0,0 @@ -*__Important:__ `bats-core` has been renamed to `bats-support`. GitHub -automatically redirects all references, e.g. submodules and clones will -continue to work, but you are encouraged to [update][github-rename] -them. Version numbering continues where `bats-core` left off.* - -[github-rename]: https://help.github.com/articles/renaming-a-repository/ - -- - - - - - -# bats-support - -[![GitHub license](https://img.shields.io/badge/license-CC0-blue.svg)](https://raw.githubusercontent.com/ztombol/bats-support/master/LICENSE) -[![GitHub release](https://img.shields.io/github/release/ztombol/bats-support.svg)](https://github.com/ztombol/bats-support/releases/latest) -[![Build Status](https://travis-ci.org/ztombol/bats-support.svg?branch=master)](https://travis-ci.org/ztombol/bats-support) - -`bats-support` is a supporting library providing common functions to -test helper libraries written for [Bats][bats]. - -Features: -- [error reporting](#error-reporting) -- [output formatting](#output-formatting) -- [language tools](#language-and-execution) - -See the [shared documentation][bats-docs] to learn how to install and -load this library. - -If you want to use this library in your own helpers or just want to -learn about its internals see the developer documentation in the [source -files](src). - - -## Error reporting - -### `fail` - -Display an error message and fail. This function provides a convenient -way to report failure in arbitrary situations. You can use it to -implement your own helpers when the ones available do not meet your -needs. Other functions use it internally as well. - -```bash -@test 'fail()' { - fail 'this test always fails' -} -``` - -The message can also be specified on the standard input. - -```bash -@test 'fail() with pipe' { - echo 'this test always fails' | fail -} -``` - -This function always fails and simply outputs the given message. - -``` -this test always fails -``` - - -## Output formatting - -Many test helpers need to produce human readable output. This library -provides a simple way to format simple messages and key value pairs, and -display them on the standard error. - - -### Simple message - -Simple messages without structure, e.g. one-line error messages, are -simply wrapped in a header and a footer to help them stand out. - -``` --- ERROR: assert_output -- -`--partial' and `--regexp' are mutually exclusive --- -``` - - -### Key-Value pairs - -Some helpers, e.g. [assertions][bats-assert], structure output as -key-value pairs. This library provides two ways to format them. - -When the value is one line long, a pair can be displayed in a columnar -fashion called ***two-column*** format. - -``` --- output differs -- -expected : want -actual : have --- -``` - -When the value is longer than one line, the key and value must be -displayed on separate lines. First, the key is displayed along with the -number of lines in the value. Then, the value, indented by two spaces -for added readability, starting on the next line. This is called -***multi-line*** format. - -``` --- command failed -- -status : 1 -output (2 lines): - Error! Something went terribly wrong! - Our engineers are panicing... \`>`;/ --- -``` - -Sometimes, for clarity, it is a good idea to display related values also -in this format, even if they are just one line long. - -``` --- output differs -- -expected (1 lines): - want -actual (3 lines): - have 1 - have 2 - have 3 --- -``` - -## Language and Execution - -### Restricting invocation to specific locations - -Sometimes a helper may work properly only when called from a certain -location. Because it depends on variables to be set or some other side -effect. - -A good example is cleaning up temporary files only if the test has -succeeded. The outcome of a test is only available in `teardown`. Thus, -to avoid programming mistakes, it makes sense to restrict such a -clean-up helper to that function. - -`batslib_is_caller` checks the call stack and returns `0` if the caller -was invoked from a given function, and `1` otherwise. This function -becomes really useful with the `--indirect` option, which allows calls -through intermediate functions, e.g. the calling function may be called -from a function that was called from the given function. - -Staying with the example above, the following code snippet implements a -helper that is restricted to `teardown` or any function called -indirectly from it. - -```shell -clean_up() { - # Check caller. - if batslib_is_caller --indirect 'teardown'; then - echo "Must be called from \`teardown'" \ - | batslib_decorate 'ERROR: clean_up' \ - | fail - return $? - fi - - # Body goes here... -} -``` - -In some cases a helper may be called from multiple locations. For -example, a logging function that uses the test name, description or -number, information only available in `setup`, `@test` or `teardown`, to -distinguish entries. The following snippet implements this restriction. - -```shell -log_test() { - # Check caller. - if ! ( batslib_is_caller --indirect 'setup' \ - || batslib_is_caller --indirect "$BATS_TEST_NAME" \ - || batslib_is_caller --indirect 'teardown' ) - then - echo "Must be called from \`setup', \`@test' or \`teardown'" \ - | batslib_decorate 'ERROR: log_test' \ - | fail - return $? - fi - - # Body goes here... -} -``` - - - - -[bats]: https://github.com/sstephenson/bats -[bats-docs]: https://github.com/ztombol/bats-docs -[bats-assert]: https://github.com/ztombol/bats-assert diff --git a/tests/unit/bats-support/load.bash b/tests/unit/bats-support/load.bash deleted file mode 100644 index 0727aeb..0000000 --- a/tests/unit/bats-support/load.bash +++ /dev/null @@ -1,3 +0,0 @@ -source "$(dirname "${BASH_SOURCE[0]}")/src/output.bash" -source "$(dirname "${BASH_SOURCE[0]}")/src/error.bash" -source "$(dirname "${BASH_SOURCE[0]}")/src/lang.bash" diff --git a/tests/unit/bats-support/package.json b/tests/unit/bats-support/package.json deleted file mode 100644 index 192d16a..0000000 --- a/tests/unit/bats-support/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "bats-support", - "version": "0.3.0", - "private": true -} diff --git a/tests/unit/bats-support/script/install-bats.sh b/tests/unit/bats-support/script/install-bats.sh deleted file mode 100755 index 4c3161a..0000000 --- a/tests/unit/bats-support/script/install-bats.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -o errexit -set -o xtrace - -git clone --depth 1 https://github.com/sstephenson/bats -cd bats && ./install.sh "${HOME}/.local" && cd .. && rm -rf bats diff --git a/tests/unit/bats-support/src/error.bash b/tests/unit/bats-support/src/error.bash deleted file mode 100644 index e5d9791..0000000 --- a/tests/unit/bats-support/src/error.bash +++ /dev/null @@ -1,41 +0,0 @@ -# -# bats-support - Supporting library for Bats test helpers -# -# Written in 2016 by Zoltan Tombol -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. -# -# You should have received a copy of the CC0 Public Domain Dedication -# along with this software. If not, see -# . -# - -# -# error.bash -# ---------- -# -# Functions implementing error reporting. Used by public helper -# functions or test suits directly. -# - -# Fail and display a message. When no parameters are specified, the -# message is read from the standard input. Other functions use this to -# report failure. -# -# Globals: -# none -# Arguments: -# $@ - [=STDIN] message -# Returns: -# 1 - always -# Inputs: -# STDIN - [=$@] message -# Outputs: -# STDERR - message -fail() { - (( $# == 0 )) && batslib_err || batslib_err "$@" - return 1 -} diff --git a/tests/unit/bats-support/src/lang.bash b/tests/unit/bats-support/src/lang.bash deleted file mode 100644 index c57e299..0000000 --- a/tests/unit/bats-support/src/lang.bash +++ /dev/null @@ -1,73 +0,0 @@ -# -# bats-util - Various auxiliary functions for Bats -# -# Written in 2016 by Zoltan Tombol -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. -# -# You should have received a copy of the CC0 Public Domain Dedication -# along with this software. If not, see -# . -# - -# -# lang.bash -# --------- -# -# Bash language and execution related functions. Used by public helper -# functions. -# - -# Check whether the calling function was called from a given function. -# -# By default, direct invocation is checked. The function succeeds if the -# calling function was called directly from the given function. In other -# words, if the given function is the next element on the call stack. -# -# When `--indirect' is specified, indirect invocation is checked. The -# function succeeds if the calling function was called from the given -# function with any number of intermediate calls. In other words, if the -# given function can be found somewhere on the call stack. -# -# Direct invocation is a form of indirect invocation with zero -# intermediate calls. -# -# Globals: -# FUNCNAME -# Options: -# -i, --indirect - check indirect invocation -# Arguments: -# $1 - calling function's name -# Returns: -# 0 - current function was called from the given function -# 1 - otherwise -batslib_is_caller() { - local -i is_mode_direct=1 - - # Handle options. - while (( $# > 0 )); do - case "$1" in - -i|--indirect) is_mode_direct=0; shift ;; - --) shift; break ;; - *) break ;; - esac - done - - # Arguments. - local -r func="$1" - - # Check call stack. - if (( is_mode_direct )); then - [[ $func == "${FUNCNAME[2]}" ]] && return 0 - else - local -i depth - for (( depth=2; depth<${#FUNCNAME[@]}; ++depth )); do - [[ $func == "${FUNCNAME[$depth]}" ]] && return 0 - done - fi - - return 1 -} diff --git a/tests/unit/bats-support/src/output.bash b/tests/unit/bats-support/src/output.bash deleted file mode 100644 index c6cf6a6..0000000 --- a/tests/unit/bats-support/src/output.bash +++ /dev/null @@ -1,279 +0,0 @@ -# -# bats-support - Supporting library for Bats test helpers -# -# Written in 2016 by Zoltan Tombol -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. -# -# You should have received a copy of the CC0 Public Domain Dedication -# along with this software. If not, see -# . -# - -# -# output.bash -# ----------- -# -# Private functions implementing output formatting. Used by public -# helper functions. -# - -# Print a message to the standard error. When no parameters are -# specified, the message is read from the standard input. -# -# Globals: -# none -# Arguments: -# $@ - [=STDIN] message -# Returns: -# none -# Inputs: -# STDIN - [=$@] message -# Outputs: -# STDERR - message -batslib_err() { - { if (( $# > 0 )); then - echo "$@" - else - cat - - fi - } >&2 -} - -# Count the number of lines in the given string. -# -# TODO(ztombol): Fix tests and remove this note after #93 is resolved! -# NOTE: Due to a bug in Bats, `batslib_count_lines "$output"' does not -# give the same result as `${#lines[@]}' when the output contains -# empty lines. -# See PR #93 (https://github.com/sstephenson/bats/pull/93). -# -# Globals: -# none -# Arguments: -# $1 - string -# Returns: -# none -# Outputs: -# STDOUT - number of lines -batslib_count_lines() { - local -i n_lines=0 - local line - while IFS='' read -r line || [[ -n $line ]]; do - (( ++n_lines )) - done < <(printf '%s' "$1") - echo "$n_lines" -} - -# Determine whether all strings are single-line. -# -# Globals: -# none -# Arguments: -# $@ - strings -# Returns: -# 0 - all strings are single-line -# 1 - otherwise -batslib_is_single_line() { - for string in "$@"; do - (( $(batslib_count_lines "$string") > 1 )) && return 1 - done - return 0 -} - -# Determine the length of the longest key that has a single-line value. -# -# This function is useful in determining the correct width of the key -# column in two-column format when some keys may have multi-line values -# and thus should be excluded. -# -# Globals: -# none -# Arguments: -# $odd - key -# $even - value of the previous key -# Returns: -# none -# Outputs: -# STDOUT - length of longest key -batslib_get_max_single_line_key_width() { - local -i max_len=-1 - while (( $# != 0 )); do - local -i key_len="${#1}" - batslib_is_single_line "$2" && (( key_len > max_len )) && max_len="$key_len" - shift 2 - done - echo "$max_len" -} - -# Print key-value pairs in two-column format. -# -# Keys are displayed in the first column, and their corresponding values -# in the second. To evenly line up values, the key column is fixed-width -# and its width is specified with the first parameter (possibly computed -# using `batslib_get_max_single_line_key_width'). -# -# Globals: -# none -# Arguments: -# $1 - width of key column -# $even - key -# $odd - value of the previous key -# Returns: -# none -# Outputs: -# STDOUT - formatted key-value pairs -batslib_print_kv_single() { - local -ir col_width="$1"; shift - while (( $# != 0 )); do - printf '%-*s : %s\n' "$col_width" "$1" "$2" - shift 2 - done -} - -# Print key-value pairs in multi-line format. -# -# The key is displayed first with the number of lines of its -# corresponding value in parenthesis. Next, starting on the next line, -# the value is displayed. For better readability, it is recommended to -# indent values using `batslib_prefix'. -# -# Globals: -# none -# Arguments: -# $odd - key -# $even - value of the previous key -# Returns: -# none -# Outputs: -# STDOUT - formatted key-value pairs -batslib_print_kv_multi() { - while (( $# != 0 )); do - printf '%s (%d lines):\n' "$1" "$( batslib_count_lines "$2" )" - printf '%s\n' "$2" - shift 2 - done -} - -# Print all key-value pairs in either two-column or multi-line format -# depending on whether all values are single-line. -# -# If all values are single-line, print all pairs in two-column format -# with the specified key column width (identical to using -# `batslib_print_kv_single'). -# -# Otherwise, print all pairs in multi-line format after indenting values -# with two spaces for readability (identical to using `batslib_prefix' -# and `batslib_print_kv_multi') -# -# Globals: -# none -# Arguments: -# $1 - width of key column (for two-column format) -# $even - key -# $odd - value of the previous key -# Returns: -# none -# Outputs: -# STDOUT - formatted key-value pairs -batslib_print_kv_single_or_multi() { - local -ir width="$1"; shift - local -a pairs=( "$@" ) - - local -a values=() - local -i i - for (( i=1; i < ${#pairs[@]}; i+=2 )); do - values+=( "${pairs[$i]}" ) - done - - if batslib_is_single_line "${values[@]}"; then - batslib_print_kv_single "$width" "${pairs[@]}" - else - local -i i - for (( i=1; i < ${#pairs[@]}; i+=2 )); do - pairs[$i]="$( batslib_prefix < <(printf '%s' "${pairs[$i]}") )" - done - batslib_print_kv_multi "${pairs[@]}" - fi -} - -# Prefix each line read from the standard input with the given string. -# -# Globals: -# none -# Arguments: -# $1 - [= ] prefix string -# Returns: -# none -# Inputs: -# STDIN - lines -# Outputs: -# STDOUT - prefixed lines -batslib_prefix() { - local -r prefix="${1:- }" - local line - while IFS='' read -r line || [[ -n $line ]]; do - printf '%s%s\n' "$prefix" "$line" - done -} - -# Mark select lines of the text read from the standard input by -# overwriting their beginning with the given string. -# -# Usually the input is indented by a few spaces using `batslib_prefix' -# first. -# -# Globals: -# none -# Arguments: -# $1 - marking string -# $@ - indices (zero-based) of lines to mark -# Returns: -# none -# Inputs: -# STDIN - lines -# Outputs: -# STDOUT - lines after marking -batslib_mark() { - local -r symbol="$1"; shift - # Sort line numbers. - set -- $( sort -nu <<< "$( printf '%d\n' "$@" )" ) - - local line - local -i idx=0 - while IFS='' read -r line || [[ -n $line ]]; do - if (( ${1:--1} == idx )); then - printf '%s\n' "${symbol}${line:${#symbol}}" - shift - else - printf '%s\n' "$line" - fi - (( ++idx )) - done -} - -# Enclose the input text in header and footer lines. -# -# The header contains the given string as title. The output is preceded -# and followed by an additional newline to make it stand out more. -# -# Globals: -# none -# Arguments: -# $1 - title -# Returns: -# none -# Inputs: -# STDIN - text -# Outputs: -# STDOUT - decorated text -batslib_decorate() { - echo - echo "-- $1 --" - cat - - echo '--' - echo -} diff --git a/tests/unit/bats-support/test/50-output-10-batslib_err.bats b/tests/unit/bats-support/test/50-output-10-batslib_err.bats deleted file mode 100755 index 8c27fd1..0000000 --- a/tests/unit/bats-support/test/50-output-10-batslib_err.bats +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_err() : displays ' { - run batslib_err 'm1' 'm2' - [ "$status" -eq 0 ] - [ "$output" == 'm1 m2' ] -} - -@test 'batslib_err(): reads from STDIN' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - echo 'm1' 'm2' | batslib_err" - [ "$status" -eq 0 ] - [ "$output" == 'm1 m2' ] -} diff --git a/tests/unit/bats-support/test/50-output-11-batslib_count_lines.bats b/tests/unit/bats-support/test/50-output-11-batslib_count_lines.bats deleted file mode 100755 index ea172c3..0000000 --- a/tests/unit/bats-support/test/50-output-11-batslib_count_lines.bats +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_count_lines() : displays the number of lines in ' { - run batslib_count_lines $'a\nb\nc\n' - [ "$status" -eq 0 ] - [ "$output" == '3' ] -} - -@test 'batslib_count_lines() : counts the last line when it is not terminated by a newline' { - run batslib_count_lines $'a\nb\nc' - [ "$status" -eq 0 ] - [ "$output" == '3' ] -} - -@test 'batslib_count_lines() : counts empty lines' { - run batslib_count_lines $'\n\n\n' - [ "$status" -eq 0 ] - [ "$output" == '3' ] -} diff --git a/tests/unit/bats-support/test/50-output-12-batslib_is_single_line.bats b/tests/unit/bats-support/test/50-output-12-batslib_is_single_line.bats deleted file mode 100755 index 484b64d..0000000 --- a/tests/unit/bats-support/test/50-output-12-batslib_is_single_line.bats +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_is_single_line() : returns 0 if all are single-line' { - run batslib_is_single_line 'a' $'b\n' 'c' - [ "$status" -eq 0 ] -} - -@test 'batslib_is_single_line() : returns 1 if at least one of is longer than one line' { - run batslib_is_single_line 'a' $'b\nb' 'c' - [ "$status" -eq 1 ] -} diff --git a/tests/unit/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats b/tests/unit/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats deleted file mode 100755 index e6af161..0000000 --- a/tests/unit/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_get_max_single_line_key_width() : displays the length of the longest key' { - local -ar pairs=( 'k _1' 'v 1' - 'k 2' 'v 2' - 'k __3' 'v 3' ) - run batslib_get_max_single_line_key_width "${pairs[@]}" - [ "$status" -eq 0 ] - [ "$output" == '5' ] -} - -@test 'batslib_get_max_single_line_key_width() : only considers keys with single-line values' { - local -ar pairs=( 'k _1' 'v 1' - 'k 2' 'v 2' - 'k __3' $'v\n3' ) - run batslib_get_max_single_line_key_width "${pairs[@]}" - [ "$status" -eq 0 ] - [ "$output" == '4' ] -} diff --git a/tests/unit/bats-support/test/50-output-14-batslib_print_kv_single.bats b/tests/unit/bats-support/test/50-output-14-batslib_print_kv_single.bats deleted file mode 100755 index 7637897..0000000 --- a/tests/unit/bats-support/test/50-output-14-batslib_print_kv_single.bats +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_print_kv_single() : displays in two-column format with wide key column' { - local -ar pairs=( 'k _1' 'v 1' - 'k 2 ' 'v 2' - 'k __3' 'v 3' ) - run batslib_print_kv_single 5 "${pairs[@]}" - [ "$status" -eq 0 ] - [ "${#lines[@]}" == '3' ] - [ "${lines[0]}" == 'k _1 : v 1' ] - [ "${lines[1]}" == 'k 2 : v 2' ] - [ "${lines[2]}" == 'k __3 : v 3' ] -} - -@test 'batslib_print_kv_single() : does not truncate keys when the column is too narrow' { - local -ar pairs=( 'k _1' 'v 1' - 'k 2' 'v 2' - 'k __3' 'v 3' ) - run batslib_print_kv_single 0 "${pairs[@]}" - [ "$status" -eq 0 ] - [ "${#lines[@]}" == '3' ] - [ "${lines[0]}" == 'k _1 : v 1' ] - [ "${lines[1]}" == 'k 2 : v 2' ] - [ "${lines[2]}" == 'k __3 : v 3' ] -} diff --git a/tests/unit/bats-support/test/50-output-15-batslib_print_kv_multi.bats b/tests/unit/bats-support/test/50-output-15-batslib_print_kv_multi.bats deleted file mode 100755 index 6ad4b3d..0000000 --- a/tests/unit/bats-support/test/50-output-15-batslib_print_kv_multi.bats +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_print_kv_multi() : displays in multi-line format' { - local -ar pairs=( 'k _1' 'v 1' - 'k 2' $'v 2-1\nv 2-2' - 'k __3' 'v 3' ) - run batslib_print_kv_multi "${pairs[@]}" - [ "$status" -eq 0 ] - [ "${#lines[@]}" == '7' ] - [ "${lines[0]}" == 'k _1 (1 lines):' ] - [ "${lines[1]}" == 'v 1' ] - [ "${lines[2]}" == 'k 2 (2 lines):' ] - [ "${lines[3]}" == 'v 2-1' ] - [ "${lines[4]}" == 'v 2-2' ] - [ "${lines[5]}" == 'k __3 (1 lines):' ] - [ "${lines[6]}" == 'v 3' ] -} diff --git a/tests/unit/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats b/tests/unit/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats deleted file mode 100755 index c20d101..0000000 --- a/tests/unit/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_print_kv_single_or_multi() : displays in two-column format if all values are one line long' { - local -ar pairs=( 'k _1' 'v 1' - 'k 2 ' 'v 2' - 'k __3' 'v 3' ) - run batslib_print_kv_single_or_multi 5 "${pairs[@]}" - [ "$status" -eq 0 ] - [ "${#lines[@]}" == '3' ] - [ "${lines[0]}" == 'k _1 : v 1' ] - [ "${lines[1]}" == 'k 2 : v 2' ] - [ "${lines[2]}" == 'k __3 : v 3' ] -} - -@test 'batslib_print_kv_single_or_multi() : displays in multi-line format if at least one value is longer than one line' { - local -ar pairs=( 'k _1' 'v 1' - 'k 2' $'v 2-1\nv 2-2' - 'k __3' 'v 3' ) - run batslib_print_kv_single_or_multi 5 "${pairs[@]}" - [ "$status" -eq 0 ] - [ "${#lines[@]}" == '7' ] - [ "${lines[0]}" == 'k _1 (1 lines):' ] - [ "${lines[1]}" == ' v 1' ] - [ "${lines[2]}" == 'k 2 (2 lines):' ] - [ "${lines[3]}" == ' v 2-1' ] - [ "${lines[4]}" == ' v 2-2' ] - [ "${lines[5]}" == 'k __3 (1 lines):' ] - [ "${lines[6]}" == ' v 3' ] -} diff --git a/tests/unit/bats-support/test/50-output-17-batslib_prefix.bats b/tests/unit/bats-support/test/50-output-17-batslib_prefix.bats deleted file mode 100755 index 817fd33..0000000 --- a/tests/unit/bats-support/test/50-output-17-batslib_prefix.bats +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_prefix() : prefixes each line of the input with ' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf 'a\nb\nc\n' | batslib_prefix '_'" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '_a' ] - [ "${lines[1]}" == '_b' ] - [ "${lines[2]}" == '_c' ] -} - -@test 'batslib_prefix() : prefixes the last line when it is not terminated by a newline' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf 'a\nb\nc' | batslib_prefix '_'" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '_a' ] - [ "${lines[1]}" == '_b' ] - [ "${lines[2]}" == '_c' ] -} - -@test 'batslib_prefix() : prefixes empty lines' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf '\n\n\n' | batslib_prefix '_'" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '_' ] - [ "${lines[1]}" == '_' ] - [ "${lines[2]}" == '_' ] -} - -@test 'batslib_prefix(): default to two spaces' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf 'a\nb\nc\n' | batslib_prefix" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == ' a' ] - [ "${lines[1]}" == ' b' ] - [ "${lines[2]}" == ' c' ] -} diff --git a/tests/unit/bats-support/test/50-output-18-batslib_mark.bats b/tests/unit/bats-support/test/50-output-18-batslib_mark.bats deleted file mode 100755 index c5d0975..0000000 --- a/tests/unit/bats-support/test/50-output-18-batslib_mark.bats +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_mark() : marks the -th line of the input with ' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf ' a\n b\n c\n' | batslib_mark '>' 0" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '>a' ] - [ "${lines[1]}" == ' b' ] - [ "${lines[2]}" == ' c' ] -} - -@test 'batslib_mark() : marks multiple lines when is in ascending order' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf ' a\n b\n c\n' | batslib_mark '>' 1 2" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == ' a' ] - [ "${lines[1]}" == '>b' ] - [ "${lines[2]}" == '>c' ] -} - -@test 'batslib_mark() : marks multiple lines when is in random order' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf ' a\n b\n c\n d\n' | batslib_mark '>' 2 1 3" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 4 ] - [ "${lines[0]}" == ' a' ] - [ "${lines[1]}" == '>b' ] - [ "${lines[2]}" == '>c' ] - [ "${lines[3]}" == '>d' ] -} - -@test 'batslib_mark() : ignores duplicate indices' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf ' a\n b\n c\n' | batslib_mark '>' 1 2 1" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == ' a' ] - [ "${lines[1]}" == '>b' ] - [ "${lines[2]}" == '>c' ] -} - -@test 'batslib_mark() : outputs the input untouched if is the empty string' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf ' a\n b\n c\n' | batslib_mark '' 1" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == ' a' ] - [ "${lines[1]}" == ' b' ] - [ "${lines[2]}" == ' c' ] -} - -@test 'batslib_mark() : marks the last line when it is not terminated by a newline' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf ' a\n b\n c' | batslib_mark '>' 2" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == ' a' ] - [ "${lines[1]}" == ' b' ] - [ "${lines[2]}" == '>c' ] -} - -@test 'batslib_mark() : does not truncate if it is longer than the marked line' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - printf '\n' | batslib_mark '>' 0" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 1 ] - [ "${lines[0]}" == '>' ] -} diff --git a/tests/unit/bats-support/test/50-output-19-batslib_decorate.bats b/tests/unit/bats-support/test/50-output-19-batslib_decorate.bats deleted file mode 100755 index 02d55ad..0000000 --- a/tests/unit/bats-support/test/50-output-19-batslib_decorate.bats +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'batslib_decorate() : encloses the input in a footer line and a header line containing <title>' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - echo 'body' | batslib_decorate 'title'" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 3 ] - [ "${lines[0]}" == '-- title --' ] - [ "${lines[1]}" == 'body' ] - [ "${lines[2]}" == '--' ] -} diff --git a/tests/unit/bats-support/test/51-error-10-fail.bats b/tests/unit/bats-support/test/51-error-10-fail.bats deleted file mode 100755 index 1d8691a..0000000 --- a/tests/unit/bats-support/test/51-error-10-fail.bats +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -@test 'fail() <message>: returns 1 and displays <message>' { - run fail 'message' - [ "$status" -eq 1 ] - [ "$output" == 'message' ] -} - -@test 'fail(): reads <message> from STDIN' { - run bash -c "source '${TEST_MAIN_DIR}/load.bash' - echo 'message' | fail" - [ "$status" -eq 1 ] - [ "$output" == 'message' ] -} diff --git a/tests/unit/bats-support/test/52-lang-10-batslib_is_caller.bats b/tests/unit/bats-support/test/52-lang-10-batslib_is_caller.bats deleted file mode 100755 index 68fd59b..0000000 --- a/tests/unit/bats-support/test/52-lang-10-batslib_is_caller.bats +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helper' - - -# Test functions -test_func_lvl_2() { - test_func_lvl_1 "$@" -} - -test_func_lvl_1() { - test_func_lvl_0 "$@" -} - -test_func_lvl_0() { - batslib_is_caller "$@" -} - - -# -# Direct invocation -# - -# Interface -@test 'batslib_is_caller() <function>: returns 0 if the current function was called directly from <function>' { - run test_func_lvl_1 test_func_lvl_1 - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'batslib_is_caller() <function>: returns 1 if the current function was not called directly from <function>' { - run test_func_lvl_0 test_func_lvl_1 - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 0 ] -} - -# Correctness -@test 'batslib_is_caller() <function>: the current function does not appear on the call stack' { - run test_func_lvl_0 test_func_lvl_0 - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 0 ] -} - - -# -# Indirect invocation -# - -# Options -test_i_indirect() { - run test_func_lvl_2 "$@" - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'batslib_is_caller() -i <function>: enables indirect checking' { - test_i_indirect -i test_func_lvl_2 -} - -@test 'batslib_is_caller() --indirect <function>: enables indirect checking' { - test_i_indirect --indirect test_func_lvl_2 -} - -# Interface -@test 'batslib_is_caller() --indirect <function>: returns 0 if the current function was called indirectly from <function>' { - run test_func_lvl_2 --indirect test_func_lvl_2 - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'batslib_is_caller() --indirect <function>: returns 1 if the current function was not called indirectly from <function>' { - run test_func_lvl_1 --indirect test_func_lvl_2 - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 0 ] -} - -# Correctness -@test 'batslib_is_caller() --indirect <function>: direct invocation is a special case of indirect invocation with zero intermediate calls' { - run test_func_lvl_1 --indirect test_func_lvl_1 - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] -} - -@test 'batslib_is_caller() --indirect <function>: the current function does not appear on the call stack' { - run test_func_lvl_0 --indirect test_func_lvl_0 - [ "$status" -eq 1 ] - [ "${#lines[@]}" -eq 0 ] -} diff --git a/tests/unit/bats-support/test/test_helper.bash b/tests/unit/bats-support/test/test_helper.bash deleted file mode 100644 index ca16775..0000000 --- a/tests/unit/bats-support/test/test_helper.bash +++ /dev/null @@ -1,6 +0,0 @@ -setup() { - export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." - - # Load library. - load '../load' -} diff --git a/tests/unit/data/go-example-repo/hello/hello b/tests/unit/data/go-example-repo/hello/hello deleted file mode 100755 index 3927faa..0000000 Binary files a/tests/unit/data/go-example-repo/hello/hello and /dev/null differ diff --git a/tests/unit/data/go-example-repo/hello/hello.go b/tests/unit/data/go-example-repo/hello/hello.go deleted file mode 100644 index 9353cc8..0000000 --- a/tests/unit/data/go-example-repo/hello/hello.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright 2014 Google Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "fmt" - - "github.com/golang/example/stringutil" -) - -func main() { - fmt.Println(stringutil.Reverse("!selpmaxe oG ,olleH")) -} diff --git a/tests/unit/pkg-versions.bats b/tests/unit/pkg-versions.bats deleted file mode 100755 index 71162df..0000000 --- a/tests/unit/pkg-versions.bats +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bats - -@test "pkg-versions: versions.json is valid json" { - run bash -c "/opt/circleci/bin/pkg-versions.sh | jq ." - - [ "$status" -eq 0 ] -} - -# Making sure all version commands succeed thus no empty version string -@test "pkg-version: versions.json doesn't contain empty version" { - run bash -c '/opt/circleci/bin/pkg-versions.sh | jq . | grep "\"\""' - - [ "$status" -eq 1 ] -} diff --git a/tests/unit/test_helper_go.bash b/tests/unit/test_helper_go.bash deleted file mode 100644 index 2a9529e..0000000 --- a/tests/unit/test_helper_go.bash +++ /dev/null @@ -1,34 +0,0 @@ -# GOPATH is /home/ubuntu/.go_workspace on CircleCI -go_workspace () { - echo "/home/ubuntu/.go_workspace" -} - -go_test_repo () { - echo $BATS_TEST_DIRNAME/../data/go-example-repo -} - -go_test_version () { - local version=$1 - - go version | grep "$version" -} - -# I'm not a huge fan of doing anything that requires network connection -# inside unit tests, but Go's convetion/expectation is bit weird, so -# it's worth actually installing dependencies. -go_test_get () { - local test_repo=$BATS_TEST_DIRNAME/data/go-example-repo - - mkdir -p $(go_workspace) - - go get -t -d -v ./... - ls $(go_workspace)/src/github.com/golang/example/hello -} - -go_test_build () { - cd $(go_test_repo)/hello - # Writing to /tmp because there is a permission issue with mounted volume. - # /home/ubuntu/tests is a volume directory and `go build` trying to write to - # the directory gets a permission issue - go build -v -o /tmp/hello -} diff --git a/tests/unit/test_helper_haskell.bash b/tests/unit/test_helper_haskell.bash deleted file mode 100644 index 85c7037..0000000 --- a/tests/unit/test_helper_haskell.bash +++ /dev/null @@ -1,31 +0,0 @@ -test_ghc_version () { - local version=$1 - - ghc --version | grep $version -} - -test_happy_version () { - local version=$1 - - happy --version | grep $version -} - -test_alex_version () { - local version=$1 - - alex --version | grep $version -} - -test_cabal_version () { - local version=$1 - - cabal --version | grep $version -} - -test_cabal_parallel_build_disabled () { - grep -- '-- jobs:$ncpus' .cabal/config -} - -test_stack_works () { - stack --version -} diff --git a/tests/unit/test_helper_heroku.bash b/tests/unit/test_helper_heroku.bash deleted file mode 100644 index 5830d9e..0000000 --- a/tests/unit/test_helper_heroku.bash +++ /dev/null @@ -1,11 +0,0 @@ -heroku_test_heroku_cli () { - run heroku --version - - [ "$status" -eq 0 ] -} - -heroku_test_config_writable () { - run touch ~/.config/heroku/foo - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/test_helper_java.bash b/tests/unit/test_helper_java.bash deleted file mode 100644 index 4ffe1b8..0000000 --- a/tests/unit/test_helper_java.bash +++ /dev/null @@ -1,55 +0,0 @@ -java_test_oraclejdk1.8_default () { - run bash -c "update-alternatives --display java | grep 'link currently points to /usr/lib/jvm/jdk1.8.0/bin/java'" - - [ "$status" -eq 0 ] -} - -java_test_oraclejdk7 (){ - sudo update-alternatives --set "java" "/usr/lib/jvm/jdk1.7.0/bin/java" - - run bash -c "java -version 2>&1 | grep 'Java(TM)'" - [ "$status" -eq 0 ] - - run bash -c "java -version 2>&1 | grep 'java version \"1.7'" - [ "$status" -eq 0 ] -} - -java_test_oraclejdk8 (){ - sudo update-alternatives --set "java" "/usr/lib/jvm/jdk1.8.0/bin/java" - - run bash -c "java -version 2>&1 | grep 'Java(TM)'" - [ "$status" -eq 0 ] - - run bash -c "java -version 2>&1 | grep 'java version \"1.8'" - [ "$status" -eq 0 ] -} - -java_test_oraclejdk9 (){ - sudo update-alternatives --set "java" "/usr/lib/jvm/java-9-oracle/bin/java" - - run bash -c "java -version 2>&1 | grep 'Java(TM)'" - [ "$status" -eq 0 ] - - run bash -c "java -version 2>&1 | grep 'java version \"9.0.1'" - [ "$status" -eq 0 ] -} - -java_test_openjdk7() { - sudo update-alternatives --set "java" "/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java" - - run bash -c "java -version 2>&1 | grep 'OpenJDK Runtime Environment'" - [ "$status" -eq 0 ] - - run bash -c "java -version 2>&1 | grep 'java version \"1.7'" - [ "$status" -eq 0 ] -} - -java_test_openjdk8() { - sudo update-alternatives --set "java" "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" - - run bash -c "java -version 2>&1 | grep 'OpenJDK Runtime Environment'" - [ "$status" -eq 0 ] - - run bash -c "java -version 2>&1 | grep 'openjdk version \"1.8'" - [ "$status" -eq 0 ] -} diff --git a/tests/unit/test_helper_nodejs.bash b/tests/unit/test_helper_nodejs.bash deleted file mode 100644 index 207bc57..0000000 --- a/tests/unit/test_helper_nodejs.bash +++ /dev/null @@ -1,43 +0,0 @@ -test_nodejs () { - local version=$1 - - # Loading nvm.sh makes bats very slow but getting - # 'nvm command not found' error otherwise, so no choise :( - . /opt/circleci/.nvm/nvm.sh - - nvm use $version - - run nodejs_test_version $version - [[ "$status" -eq 0 ]] - - run nodejs_test_npm - [[ "$status" -eq 0 ]] -} - -nodejs_test_version () { - local version=$1 - - node -e "console.log(process.version);" | grep "$version" -} - -nodejs_test_npm () { - npm --version -} - -test_yarn_version () { - local expected=$1 - local actual=$(yarn --version) - - run test "$expected" = "$actual" - - [ "$status" -eq 0 ] -} - -nodejs_test_all_installed (){ - local expected=$(grep "circleci-install nodejs" /opt/circleci/Dockerfile | awk '{print "v" $4}' | sort) - local actual=$(ls /opt/circleci/nodejs/ | sort) - - run test "$expected" = "$actual" - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/test_helper_php.bash b/tests/unit/test_helper_php.bash deleted file mode 100644 index f5849a2..0000000 --- a/tests/unit/test_helper_php.bash +++ /dev/null @@ -1,56 +0,0 @@ -test_php () { - local version=$1 - - phpenv local $version - - run php_test_version $version - [ "$status" -eq 0 ] - - run php_test_composer - [ "$status" -eq 0 ] - - run php_test_pecl - [ "$status" -eq 0 ] - - run php_test_libphp_exists $version - [ "$status" -eq 0 ] -} - -php_test_version () { - local version=$1 - - php -r 'echo phpversion();' | grep "$version" -} - -php_test_composer () { - composer --version -} - -php_test_pecl () { - pecl version -} - -php_test_libphp_exists () { - local version=$1 - - # PHP 5 - if echo $version | grep -q "^5"; then - local libphp_path="$PHPENV_ROOT/versions/$version/usr/lib/apache2/modules/libphp5.so" - # PHP 7 - elif echo $version | grep -q "^7"; then - local libphp_path="$PHPENV_ROOT/versions/$version/usr/lib/apache2/modules/libphp7.so" - else - echo "unknown version: $version" && return 1 - fi - - test -e $libphp_path -} - -php_test_all_installed () { - local expected=$(grep "circleci-install php" /opt/circleci/Dockerfile | awk '{print $4}' | sort) - local actual=$(ls /opt/circleci/php/ | sort) - - run test "$expected" = "$actual" - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/test_helper_python.bash b/tests/unit/test_helper_python.bash deleted file mode 100644 index 0287340..0000000 --- a/tests/unit/test_helper_python.bash +++ /dev/null @@ -1,64 +0,0 @@ -test_python () { - local version=$1 - - pyenv global $version - - if echo $version | grep pypy; then - run pypy_test_version $version - [ "$status" -eq 0 ] - else - run python_test_version $version - [ "$status" -eq 0 ] - fi - - run python_test_pip - [ "$status" -eq 0 ] - - # kludge: I couldn't install curses only in pypy-1.9 for some reasons - if ! [ "$version" = "pypy-1.9" ] ; then - run python_test_curses - [ "$status" -eq 0 ] - fi -} - -python_test_version () { - local version=$1 - - python --version 2>&1 | grep "$version" -} - -pypy_test_version () { - local version=$1 - local split=( `echo ${version} | tr -s '-' ' '` ) - local pypy=${split[0]} - local ver=${split[1]} - - echo $split >> /tmp/debug - - python --version 2>&1 | grep -i $pypy | grep $ver -} - -python_test_pip () { - pip --version -} - -python_test_pyenv_global () { - local current_version=$(pyenv global) - local new_version=3.5.3 - - pyenv global $new_version - python_test_version $new_version -} - -python_test_all_installed () { - local expected=$(grep "circleci-install python" /opt/circleci/Dockerfile | awk '{print $4}' | sort) - local actual=$(ls /opt/circleci/python/ | sort) - - run test "$expected" = "$actual" - - [ "$status" -eq 0 ] -} - -python_test_curses() { - python -c 'import curses' -} diff --git a/tests/unit/test_helper_ruby.bash b/tests/unit/test_helper_ruby.bash deleted file mode 100644 index 2b092f7..0000000 --- a/tests/unit/test_helper_ruby.bash +++ /dev/null @@ -1,57 +0,0 @@ -test_ruby () { - local version=$1 - - # Don't use rvm!! - # Using 'rvm use ...' requires you to source /opt/circleci/.rvm/scripts/rvm - # and this makes bats extremely slow for some reasons. (probably same as https://github.com/sstephenson/bats/issues/107) - # So just load only env vars - . /opt/circleci/.rvm/environments/ruby-$version - - run ruby_test_version $version - [ "$status" -eq 0 ] - - run ruby_test_gem - [ "$status" -eq 0 ] - - run ruby_test_bundler - [ "$status" -eq 0 ] - - run ruby_test_gem_version_fixed 2.6 - [ "$status" -eq 0 ] - - run ruby_test_bundler_version_fixed 1.14 - [ "$status" -eq 0 ] -} - -ruby_test_version () { - local version=$1 - - ruby -e 'puts RUBY_VERSION' | grep "$version" -} - -ruby_test_gem () { - gem --version -} - -ruby_test_gem_version_fixed () { - local version=$1 - gem --version | grep $version -} - -ruby_test_bundler () { - bundler --version -} - -ruby_test_bundler_version_fixed () { - local version=$1 - bundler --version | grep $version -} - -ruby_test_all_installed () { - local expected=$(grep "circleci-install ruby" /opt/circleci/Dockerfile | awk '{print "ruby-" $4}' | sort) - local actual=$(ls /opt/circleci/ruby/ | grep -v default | sort) - - run test "$expected" = "$actual" - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XL/android.bats b/tests/unit/ubuntu-14.04-XL/android.bats deleted file mode 100755 index 2ddcb04..0000000 --- a/tests/unit/ubuntu-14.04-XL/android.bats +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env bats - -# Idealy we can actually run android emulator to make sure -# Android is working but emulator is too slow to test. -# So only checking whether correct versions of packages are installed. - -android_test_sdk_tool_version() { - local expected=$1 - local actual=$(grep 'Pkg.Revision=' $ANDROID_HOME/tools/source.properties | sed 's/Pkg.Revision=//') - - test "$expected" = "$actual" -} - -android_test_sdk_build_tool_installed() { - local version=$1 - local install_path=$ANDROID_HOME/build-tools/$version - - ls $install_path -} - -android_test_sdk_platform_installed() { - local version=$1 - local install_path=$ANDROID_HOME/platforms/android-$version - - ls $install_path -} - -android_test_sdk_extra_installed() { - local pkg=$1 - local type=$2 - local install_path=$ANDROID_HOME/extras/$type/$pkg - - ls $install_path -} - -android_test_sdk_addons_installed() { - local pkg=$1 - local install_path=$ANDROID_HOME/add-ons/$pkg - - ls $install_path -} - -@test "android: correct version of sdk tool is installed" { - run android_test_sdk_tool_version "24.4.1" - - [ "$status" -eq 0 ] -} - -@test "android: build-tools-23.0.3 is installed" { - run android_test_sdk_build_tool_installed "23.0.3" - - [ "$status" -eq 0 ] -} - -@test "android: build-tools-23.0.2 is installed" { - run android_test_sdk_build_tool_installed "23.0.2" - - [ "$status" -eq 0 ] -} - -@test "android: build-tools-22.0.1 is installed" { - run android_test_sdk_build_tool_installed "22.0.1" - - [ "$status" -eq 0 ] -} - -@test "android: android-23 is installed" { - run android_test_sdk_platform_installed "23" - - [ "$status" -eq 0 ] -} - -@test "android: android-22 is installed" { - run android_test_sdk_platform_installed "22" - - [ "$status" -eq 0 ] -} - -@test "android: extra-android-m2repository is installed" { - run android_test_sdk_extra_installed "m2repository" "android" - - [ "$status" -eq 0 ] -} - -@test "android: extra-google-m2repository is installed" { - run android_test_sdk_extra_installed "m2repository" "google" - - [ "$status" -eq 0 ] -} - -@test "android: extra-google-google_play_services is installed" { - run android_test_sdk_extra_installed "google_play_services" "google" - - [ "$status" -eq 0 ] -} - -@test "android: addon-google_apis-google-23 is installed" { - run android_test_sdk_addons_installed "addon-google_apis-google-23" - - [ "$status" -eq 0 ] -} - -@test "android: addon-google_apis-google-22 is installed" { - run android_test_sdk_addons_installed "addon-google_apis-google-22" - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XL/go.bats b/tests/unit/ubuntu-14.04-XL/go.bats deleted file mode 100755 index 394bbcb..0000000 --- a/tests/unit/ubuntu-14.04-XL/go.bats +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_go -load ../bats-support/load -load ../bats-assert/load - -@test "go: 1.7.4 works" { - run go_test_version 1.7.4 - - assert_success -} - -@test "go: go get works" { - run go_test_get - - assert_success -} - -@test "go: go build works" { - run go_test_build - assert_success -} diff --git a/tests/unit/ubuntu-14.04-XL/haskell.bats b/tests/unit/ubuntu-14.04-XL/haskell.bats deleted file mode 100644 index 01415d1..0000000 --- a/tests/unit/ubuntu-14.04-XL/haskell.bats +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_haskell - -@test "haskell: ghc 8.0.1 is installed" { - run test_ghc_version 8.0.1 - - [ "$status" -eq 0 ] -} - -@test "haskell: happy 1.19.5 is installed" { - run test_happy_version 1.19.5 - - [ "$status" -eq 0 ] -} - -@test "haskell: alex 3.1.7 is installed" { - run test_alex_version 3.1.7 - - [ "$status" -eq 0 ] -} - -@test "haskell: cabal 1.24 is installed" { - run test_cabal_version 1.24 - - [ "$status" -eq 0 ] -} - -@test "haskell: cabal parallel build is disabled" { - run test_cabal_parallel_build_disabled - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XL/heroku.bats b/tests/unit/ubuntu-14.04-XL/heroku.bats deleted file mode 100755 index 98a5bd3..0000000 --- a/tests/unit/ubuntu-14.04-XL/heroku.bats +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_heroku - -@test "heroku: heroku-cli works" { - heroku_test_heroku_cli -} - -@test "heroku: config dir is writable by user" { - heroku_test_config_writable -} diff --git a/tests/unit/ubuntu-14.04-XL/java.bats b/tests/unit/ubuntu-14.04-XL/java.bats deleted file mode 100644 index e18d8f4..0000000 --- a/tests/unit/ubuntu-14.04-XL/java.bats +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_java - -@test "java: default is oraclejdk1.8" { - java_test_oraclejdk1.8_default -} - -@test "java: openjdk8 works" { - java_test_oraclejdk8 -} - -@test "java: openjdk7 works" { - java_test_oraclejdk7 -} - -@test "java: maven works" { - run mvn --version - - [ "$status" -eq 0 ] -} - -@test "java: gradle works" { - run gradle --version - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XL/nodejs.bats b/tests/unit/ubuntu-14.04-XL/nodejs.bats deleted file mode 100755 index 47180d6..0000000 --- a/tests/unit/ubuntu-14.04-XL/nodejs.bats +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_nodejs - -@test "nodejs: all versions are installed" { - nodejs_test_all_installed -} - -# Run this test first before version is changed by subsequent tests -@test "nodejs: default is 4.2.6" { - run nodejs_test_version 4.2.6 - - [ "$status" -eq 0 ] -} - -@test "nodejs: 0.12.9 works" { - test_nodejs 0.12.9 -} - -@test "nodejs: 4.0.0 works" { - test_nodejs 4.0.0 -} - -@test "nodejs: 4.1.2 works" { - test_nodejs 4.1.2 -} - -@test "nodejs: 4.2.6 works" { - test_nodejs 4.2.6 -} - -@test "nodejs: 4.3.0 works" { - test_nodejs 4.3.0 -} - -@test "nodejs: 4.5.0 works" { - test_nodejs 4.5.0 -} - -@test "nodejs: 5.0.0 works" { - test_nodejs 5.0.0 -} - -@test "nodejs: 5.1.1 works" { - test_nodejs 5.1.1 -} - -@test "nodejs: 5.2.0 works" { - test_nodejs 5.2.0 -} - -@test "nodejs: 5.3.0 works" { - test_nodejs 5.3.0 -} - -@test "nodejs: 5.4.1 works" { - test_nodejs 5.4.1 -} - -@test "nodejs: 5.5.0 works" { - test_nodejs 5.5.0 -} - -@test "nodejs: 5.6.0 works" { - test_nodejs 5.6.0 -} - -@test "nodejs: 5.7.0 works" { - test_nodejs 5.7.0 -} - -@test "nodejs: 6.1.0 works" { - test_nodejs 6.1.0 -} - -# We are not testing the behavior of nvm here... -# There was a bug that implicit versioning of nvm is broken -# because we use $CIRCLECI_PKG_DIR to store installed nodejs. -# This test makes sure the bug is fixed. -@test "nodejs: nvm implicit default alias works" { - . /opt/circleci/.nvm/nvm.sh; - - local version="5" - # Need to remove color from the string with sed - local explicit=$(nvm ls-remote | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | grep v5 | tail -1) - - nvm install $version - nvm alias default $version - - # Reload nvm to make sure default versinon persists - nvm unload; . /opt/circleci/.nvm/nvm.sh; - - run node --version - - [ "$output" = $explicit ] -} diff --git a/tests/unit/ubuntu-14.04-XL/php.bats b/tests/unit/ubuntu-14.04-XL/php.bats deleted file mode 100755 index d81d41d..0000000 --- a/tests/unit/ubuntu-14.04-XL/php.bats +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_php -load ../bats-support/load -load ../bats-assert/load - -@test "php: all versions are installed" { - php_test_all_installed -} - -# Run this test first before version is changed by subsequent tests -@test "php: default is 5.6.17" { - run php_test_version 5.6.17 - - assert_success -} - -@test "php: 5.5.31 works" { - test_php 5.5.31 -} - -@test "php: 5.5.32 works" { - test_php 5.5.32 -} - -@test "php: 5.5.36 works" { - test_php 5.5.36 -} - -@test "php: 5.6.17 works" { - test_php 5.6.17 -} - -@test "php: 5.6.18 works" { - test_php 5.6.18 -} - -@test "php: 5.6.22 works" { - test_php 5.6.22 -} - -@test "php: 7.0.4 works" { - test_php 7.0.4 -} - -@test "php: 7.0.7 works" { - test_php 7.0.7 -} - -@test "php: 7.0.11 works" { - test_php 7.0.11 -} - -@test "php: 7.1.0 works" { - test_php 7.1.0 -} diff --git a/tests/unit/ubuntu-14.04-XL/python.bats b/tests/unit/ubuntu-14.04-XL/python.bats deleted file mode 100755 index 3f9286f..0000000 --- a/tests/unit/ubuntu-14.04-XL/python.bats +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_python - -@test "python: all versions are installed" { - python_test_all_installed -} - -# Run this test first before version is changed by subsequent tests -@test "python: default is 2.7.11" { - run python_test_version 2.7.11 - - [ "$status" -eq 0 ] -} - -@test "python: 2.7.10 works" { - test_python 2.7.10 -} - -@test "python: 2.7.11 works" { - test_python 2.7.11 -} - -@test "python: 2.7.12 works" { - test_python 2.7.12 -} - -@test "python: 3.1.4 works" { - test_python 3.1.4 -} - -@test "python: 3.1.5 works" { - test_python 3.1.5 -} - -@test "python: 3.2.5 works" { - test_python 3.2.5 -} - -@test "python: 3.2.6 works" { - test_python 3.2.6 -} - -@test "python: 3.3.5 works" { - test_python 3.3.5 -} - -@test "python: 3.3.6 works" { - test_python 3.3.6 -} - -@test "python: 3.4.3 works" { - test_python 3.4.3 -} - -@test "python: 3.4.4 works" { - test_python 3.4.4 -} - -@test "python: 3.5.1 works" { - test_python 3.5.1 -} - -@test "python: 3.5.2 works" { - test_python 3.5.2 -} - -@test "python: pypy-1.9 works" { - test_python pypy-1.9 -} - -@test "python: pypy-2.6.1 works" { - test_python pypy-2.6.1 -} - -@test "python: pypy-4.0.1 works" { - test_python pypy-4.0.1 -} - -# We had a regression that changing python version with 'pyenv global' is broken -# because we accidentally run 'pyenv local' during image build. -# This breaks the version switching because CircleCI use 'pyenv global' but global -# doesn't override version set with local. -@test "python: switching version with 'pyenv global' works" { - run python_test_pyenv_global - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XL/qt.bats b/tests/unit/ubuntu-14.04-XL/qt.bats deleted file mode 100644 index 8793749..0000000 --- a/tests/unit/ubuntu-14.04-XL/qt.bats +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bats - -load ../bats-support/load -load ../bats-assert/load - -@test "qt: default is 5.2" { - run bash -c "qmake -query QT_VERSION | grep 5.2" - - assert_success -} - -@test "qt: switching to 5.5 works" { - run bash -c "source /opt/qt55/bin/qt55-env.sh && qmake -query QT_VERSION | grep 5.5" - - assert_success -} - -# You don't want to run these tests at every build since building capybara-webkit is slow -#@test "qt: building capybara-webkit with 5.2 works" { -# run gem install capybara-webkit -# -# assert_success -#} -# -#@test "qt: building capybara-webkit with 5.5 works" { -# run bash -c "source /opt/qt55/bin/qt55-env.sh && QMAKE=/opt/qt55/bin/qmake gem install capybara-webkit" -# -# assert_success -#} diff --git a/tests/unit/ubuntu-14.04-XL/ruby.bats b/tests/unit/ubuntu-14.04-XL/ruby.bats deleted file mode 100755 index b400970..0000000 --- a/tests/unit/ubuntu-14.04-XL/ruby.bats +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_ruby - -@test "ruby: all versions are installed" { - ruby_test_all_installed -} - -# Run this test first before version is changed by subsequent tests -@test "ruby: default is 2.2.4" { - run ruby_test_version 2.2.4 - - [ "$status" -eq 0 ] -} - -@test "ruby: 2.1.8 works" { - test_ruby 2.1.8 -} - -@test "ruby: 2.1.9 works" { - test_ruby 2.1.9 -} - -@test "ruby: 2.2.4 works" { - test_ruby 2.2.4 -} - -@test "ruby: 2.2.5 works" { - test_ruby 2.2.5 -} - -@test "ruby: 2.3.0 works" { - test_ruby 2.3.0 -} - -@test "ruby: 2.3.1 works" { - test_ruby 2.3.1 -} diff --git a/tests/unit/ubuntu-14.04-XXL/android.bats b/tests/unit/ubuntu-14.04-XXL/android.bats deleted file mode 100755 index 2ddcb04..0000000 --- a/tests/unit/ubuntu-14.04-XXL/android.bats +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env bats - -# Idealy we can actually run android emulator to make sure -# Android is working but emulator is too slow to test. -# So only checking whether correct versions of packages are installed. - -android_test_sdk_tool_version() { - local expected=$1 - local actual=$(grep 'Pkg.Revision=' $ANDROID_HOME/tools/source.properties | sed 's/Pkg.Revision=//') - - test "$expected" = "$actual" -} - -android_test_sdk_build_tool_installed() { - local version=$1 - local install_path=$ANDROID_HOME/build-tools/$version - - ls $install_path -} - -android_test_sdk_platform_installed() { - local version=$1 - local install_path=$ANDROID_HOME/platforms/android-$version - - ls $install_path -} - -android_test_sdk_extra_installed() { - local pkg=$1 - local type=$2 - local install_path=$ANDROID_HOME/extras/$type/$pkg - - ls $install_path -} - -android_test_sdk_addons_installed() { - local pkg=$1 - local install_path=$ANDROID_HOME/add-ons/$pkg - - ls $install_path -} - -@test "android: correct version of sdk tool is installed" { - run android_test_sdk_tool_version "24.4.1" - - [ "$status" -eq 0 ] -} - -@test "android: build-tools-23.0.3 is installed" { - run android_test_sdk_build_tool_installed "23.0.3" - - [ "$status" -eq 0 ] -} - -@test "android: build-tools-23.0.2 is installed" { - run android_test_sdk_build_tool_installed "23.0.2" - - [ "$status" -eq 0 ] -} - -@test "android: build-tools-22.0.1 is installed" { - run android_test_sdk_build_tool_installed "22.0.1" - - [ "$status" -eq 0 ] -} - -@test "android: android-23 is installed" { - run android_test_sdk_platform_installed "23" - - [ "$status" -eq 0 ] -} - -@test "android: android-22 is installed" { - run android_test_sdk_platform_installed "22" - - [ "$status" -eq 0 ] -} - -@test "android: extra-android-m2repository is installed" { - run android_test_sdk_extra_installed "m2repository" "android" - - [ "$status" -eq 0 ] -} - -@test "android: extra-google-m2repository is installed" { - run android_test_sdk_extra_installed "m2repository" "google" - - [ "$status" -eq 0 ] -} - -@test "android: extra-google-google_play_services is installed" { - run android_test_sdk_extra_installed "google_play_services" "google" - - [ "$status" -eq 0 ] -} - -@test "android: addon-google_apis-google-23 is installed" { - run android_test_sdk_addons_installed "addon-google_apis-google-23" - - [ "$status" -eq 0 ] -} - -@test "android: addon-google_apis-google-22 is installed" { - run android_test_sdk_addons_installed "addon-google_apis-google-22" - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XXL/gcloud.bats b/tests/unit/ubuntu-14.04-XXL/gcloud.bats deleted file mode 100644 index b40d3da..0000000 --- a/tests/unit/ubuntu-14.04-XXL/gcloud.bats +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_go -load ../bats-support/load -load ../bats-assert/load - -@test "gcloud works" { - run gcloud --version - - assert_success -} diff --git a/tests/unit/ubuntu-14.04-XXL/git-lfs.bats b/tests/unit/ubuntu-14.04-XXL/git-lfs.bats deleted file mode 100644 index face8c7..0000000 --- a/tests/unit/ubuntu-14.04-XXL/git-lfs.bats +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_go - -@test "git-lfs: 1.5.4 works" { - run bash -c "git-lfs | grep 1.5.4" - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XXL/go.bats b/tests/unit/ubuntu-14.04-XXL/go.bats deleted file mode 100755 index d1e0392..0000000 --- a/tests/unit/ubuntu-14.04-XXL/go.bats +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_go -load ../bats-support/load -load ../bats-assert/load - -@test "go: 1.9.1 works" { - run go_test_version 1.9.1 - - assert_success -} - -@test "go: go get works" { - run go_test_get - - assert_success -} - -@test "go: go build works" { - run go_test_build - assert_success -} diff --git a/tests/unit/ubuntu-14.04-XXL/haskell.bats b/tests/unit/ubuntu-14.04-XXL/haskell.bats deleted file mode 100644 index 004d1ee..0000000 --- a/tests/unit/ubuntu-14.04-XXL/haskell.bats +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_haskell -load ../bats-support/load -load ../bats-assert/load - -@test "haskell: ghc 8.0.2 is installed" { - run test_ghc_version 8.0.2 - - assert_success -} - -@test "haskell: happy 1.19.5 is installed" { - run test_happy_version 1.19.5 - - assert_success -} - -@test "haskell: alex 3.1.7 is installed" { - run test_alex_version 3.1.7 - - assert_success -} - -@test "haskell: cabal 1.24 is installed" { - run test_cabal_version 1.24 - - assert_success -} - -@test "haskell: cabal parallel build is disabled" { - run test_cabal_parallel_build_disabled - - assert_success -} - -@test "haskell: stack is installed" { - run test_stack_works - - assert_success -} diff --git a/tests/unit/ubuntu-14.04-XXL/heroku.bats b/tests/unit/ubuntu-14.04-XXL/heroku.bats deleted file mode 100755 index 98a5bd3..0000000 --- a/tests/unit/ubuntu-14.04-XXL/heroku.bats +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_heroku - -@test "heroku: heroku-cli works" { - heroku_test_heroku_cli -} - -@test "heroku: config dir is writable by user" { - heroku_test_config_writable -} diff --git a/tests/unit/ubuntu-14.04-XXL/java.bats b/tests/unit/ubuntu-14.04-XXL/java.bats deleted file mode 100644 index b1122a8..0000000 --- a/tests/unit/ubuntu-14.04-XXL/java.bats +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_java - -@test "java: default is oraclejdk1.8" { - java_test_oraclejdk1.8_default -} - -@test "java: oraclejdk7 works" { - java_test_oraclejdk7 -} - -@test "java: oraclejdk8 works" { - java_test_oraclejdk8 -} - -@test "java: openjdk7 works" { - java_test_openjdk7 -} - -@test "java: openjdk8 works" { - java_test_openjdk8 -} - -@test "java: maven works" { - run mvn --version - - [ "$status" -eq 0 ] -} - -@test "java: gradle works" { - run gradle --version - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XXL/nodejs.bats b/tests/unit/ubuntu-14.04-XXL/nodejs.bats deleted file mode 100755 index a31d4a7..0000000 --- a/tests/unit/ubuntu-14.04-XXL/nodejs.bats +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_nodejs -load ../bats-support/load -load ../bats-assert/load - -@test "nodejs: all versions are installed" { - nodejs_test_all_installed -} - -# Run this test first before version is changed by subsequent tests -@test "nodejs: default is 4.2.6" { - run nodejs_test_version 4.2.6 - - assert_success -} - -@test "nodejs: 0.12.9 works" { - test_nodejs 0.12.9 -} - -@test "nodejs: 4.0.0 works" { - test_nodejs 4.0.0 -} - -@test "nodejs: 4.1.2 works" { - test_nodejs 4.1.2 -} - -@test "nodejs: 4.2.6 works" { - test_nodejs 4.2.6 -} - -@test "nodejs: 4.3.0 works" { - test_nodejs 4.3.0 -} - -@test "nodejs: 4.5.0 works" { - test_nodejs 4.5.0 -} - -@test "nodejs: 5.0.0 works" { - test_nodejs 5.0.0 -} - -@test "nodejs: 5.1.1 works" { - test_nodejs 5.1.1 -} - -@test "nodejs: 5.2.0 works" { - test_nodejs 5.2.0 -} - -@test "nodejs: 5.3.0 works" { - test_nodejs 5.3.0 -} - -@test "nodejs: 5.4.1 works" { - test_nodejs 5.4.1 -} - -@test "nodejs: 5.5.0 works" { - test_nodejs 5.5.0 -} - -@test "nodejs: 5.6.0 works" { - test_nodejs 5.6.0 -} - -@test "nodejs: 5.7.0 works" { - test_nodejs 5.7.0 -} - -@test "nodejs: 6.1.0 works" { - test_nodejs 6.1.0 -} - -@test "nodejs: 6.11.4 works" { - test_nodejs 6.11.4 -} - -@test "nodejs: 8.1.4 works" { - test_nodejs 8.1.4 -} - -@test "nodejs: 8.2.0 works" { - test_nodejs 8.2.0 -} - -@test "nodejs: yarn 1.1.0 is installed" { - test_yarn_version 1.1.0 -} - -# We are not testing the behavior of nvm here... -# There was a bug that implicit versioning of nvm is broken -# because we use $CIRCLECI_PKG_DIR to store installed nodejs. -# This test makes sure the bug is fixed. -@test "nodejs: nvm implicit default alias works" { - . /opt/circleci/.nvm/nvm.sh; - - local version="5" - # Need to remove color from the string with sed - local explicit=$(nvm ls-remote | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | grep v5 | tail -1) - - nvm install $version - nvm alias default $version - - # Reload nvm to make sure default versinon persists - nvm unload; . /opt/circleci/.nvm/nvm.sh; - - run node --version - - [ "$output" = $explicit ] -} diff --git a/tests/unit/ubuntu-14.04-XXL/php.bats b/tests/unit/ubuntu-14.04-XXL/php.bats deleted file mode 100755 index 60ff27e..0000000 --- a/tests/unit/ubuntu-14.04-XXL/php.bats +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_php -load ../bats-support/load -load ../bats-assert/load - -@test "php: all versions are installed" { - php_test_all_installed -} - -# Run this test first before version is changed by subsequent tests -@test "php: default is 5.6.17" { - run php_test_version 5.6.17 - - assert_success -} - -@test "php: 5.5.31 works" { - test_php 5.5.31 -} - -@test "php: 5.5.32 works" { - test_php 5.5.32 -} - -@test "php: 5.5.36 works" { - test_php 5.5.36 -} - -@test "php: 5.6.17 works" { - test_php 5.6.17 -} - -@test "php: 5.6.18 works" { - test_php 5.6.18 -} - -@test "php: 5.6.22 works" { - test_php 5.6.22 -} - -@test "php: 7.0.7 works" { - test_php 7.0.7 -} - -@test "php: 7.0.11 works" { - test_php 7.0.11 -} - -@test "php: 7.0.17 works" { - test_php 7.0.17 -} - -@test "php: 7.0.20 works" { - test_php 7.0.20 -} - -@test "php: 7.0.24 works" { - test_php 7.0.24 -} - -@test "php: 7.1.3 works" { - test_php 7.1.3 -} - -@test "php: 7.1.6 works" { - test_php 7.1.6 -} - -@test "php: 7.1.9 works" { - test_php 7.1.9 -} \ No newline at end of file diff --git a/tests/unit/ubuntu-14.04-XXL/python.bats b/tests/unit/ubuntu-14.04-XXL/python.bats deleted file mode 100755 index 141c274..0000000 --- a/tests/unit/ubuntu-14.04-XXL/python.bats +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_python -load ../bats-support/load -load ../bats-assert/load - -@test "python: all versions are installed" { - python_test_all_installed -} - -# Run this test first before version is changed by subsequent tests -@test "python: default is 2.7.11" { - run python_test_version 2.7.11 - - assert_success -} - -@test "python: 2.7.10 works" { - test_python 2.7.10 -} - -@test "python: 2.7.11 works" { - test_python 2.7.11 -} - -@test "python: 2.7.12 works" { - test_python 2.7.12 -} - -@test "python: 3.1.4 works" { - test_python 3.1.4 -} - -@test "python: 3.1.5 works" { - test_python 3.1.5 -} - -@test "python: 3.2.5 works" { - test_python 3.2.5 -} - -@test "python: 3.2.6 works" { - test_python 3.2.6 -} - -@test "python: 3.3.5 works" { - test_python 3.3.5 -} - -@test "python: 3.3.6 works" { - test_python 3.3.6 -} - -@test "python: 3.4.3 works" { - test_python 3.4.3 -} - -@test "python: 3.4.4 works" { - test_python 3.4.4 -} - -@test "python: 3.5.2 works" { - test_python 3.5.2 -} - -@test "python: 3.5.3 works" { - test_python 3.5.3 -} - -@test "python: 3.6.1 works" { - test_python 3.6.1 -} - -@test "python: 3.6.2 works" { - test_python 3.6.2 -} - -@test "python: pypy-1.9 works" { - test_python pypy-1.9 -} - -@test "python: pypy-2.6.1 works" { - test_python pypy-2.6.1 -} - -@test "python: pypy-4.0.1 works" { - test_python pypy-4.0.1 -} - -# We had a regression that changing python version with 'pyenv global' is broken -# because we accidentally run 'pyenv local' during image build. -# This breaks the version switching because CircleCI use 'pyenv global' but global -# doesn't override version set with local. -@test "python: switching version with 'pyenv global' works" { - run python_test_pyenv_global - - assert_success -} diff --git a/tests/unit/ubuntu-14.04-XXL/qt.bats b/tests/unit/ubuntu-14.04-XXL/qt.bats deleted file mode 100644 index 8793749..0000000 --- a/tests/unit/ubuntu-14.04-XXL/qt.bats +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bats - -load ../bats-support/load -load ../bats-assert/load - -@test "qt: default is 5.2" { - run bash -c "qmake -query QT_VERSION | grep 5.2" - - assert_success -} - -@test "qt: switching to 5.5 works" { - run bash -c "source /opt/qt55/bin/qt55-env.sh && qmake -query QT_VERSION | grep 5.5" - - assert_success -} - -# You don't want to run these tests at every build since building capybara-webkit is slow -#@test "qt: building capybara-webkit with 5.2 works" { -# run gem install capybara-webkit -# -# assert_success -#} -# -#@test "qt: building capybara-webkit with 5.5 works" { -# run bash -c "source /opt/qt55/bin/qt55-env.sh && QMAKE=/opt/qt55/bin/qmake gem install capybara-webkit" -# -# assert_success -#} diff --git a/tests/unit/ubuntu-14.04-XXL/ruby.bats b/tests/unit/ubuntu-14.04-XXL/ruby.bats deleted file mode 100755 index 88f4cb0..0000000 --- a/tests/unit/ubuntu-14.04-XXL/ruby.bats +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bats - -load ../test_helper_ruby -load ../bats-support/load -load ../bats-assert/load - -@test "ruby: all versions are installed" { - ruby_test_all_installed -} - -# Run this test first before version is changed by subsequent tests -@test "ruby: default is 2.2.6" { - run ruby_test_version 2.2.6 - - assert_success -} - -@test "ruby: 2.1.8 works" { - run test_ruby 2.1.8 - assert_success -} - -@test "ruby: 2.1.9 works" { - run test_ruby 2.1.9 - assert_success -} - -@test "ruby: 2.2.6 works" { - run test_ruby 2.2.6 - assert_success -} - -@test "ruby: 2.2.7 works" { - run test_ruby 2.2.7 - assert_success -} - -@test "ruby: 2.3.4 works" { - run test_ruby 2.3.4 - assert_success -} - -@test "ruby: 2.3.5 works" { - run test_ruby 2.3.5 - assert_success -} - -@test "ruby: 2.4.1 works" { - run test_ruby 2.4.1 - assert_success -} - -@test "ruby: 2.4.2 works" { - run test_ruby 2.4.2 - assert_success -} diff --git a/tests/unit/ubuntu-14.04-XXL/services.bats b/tests/unit/ubuntu-14.04-XXL/services.bats deleted file mode 100755 index fda1cde..0000000 --- a/tests/unit/ubuntu-14.04-XXL/services.bats +++ /dev/null @@ -1,180 +0,0 @@ -#!/usr/bin/env bats - -test_enabled_default () { - local service=$1 - - sudo service $service status | grep "start/running" -} - -wait_service () { - local port=$1 - local sleep_time=3 - - for i in 1 2 3 4 5; do - if curl --silent localhost:$port > /dev/null; then - return 0 - else - sleep $sleep_time - fi - done - - exit 1 -} - -create_postgis_extention () { - local extentions=(postgis postgis_topology fuzzystrmatch postgis_tiger_geocoder) - - # Drop extentions in case it's already created by previous test run. - # You need to delete extentions in reverse order because of dependencies. - for (( i=${#extentions[@]}-1 ; i>=0 ; i-- )) ; do - psql -c "DROP EXTENSION ${extentions[i]};" || true - done - - for ((i = 0; i < ${#extentions[@]}; i++)) ; do - psql -c "CREATE EXTENSION ${extentions[i]};" || return 1 - done -} - -@test "mysql: enabled by default" { - run bash -c "sudo service mysql status | grep 'is running'" - - [ "$status" -eq 0 ] -} - -@test "mysql: query works" { - run mysql -e "STATUS;" - - [ "$status" -eq 0 ] -} - -@test "mysql: test database is created" { - run bash -c "mysql -e 'show databases;' | grep circle_test" - - [ "$status" -eq 0 ] -} - -@test "mysql: root password is empty" { - run mysql -u root -e 'STATUS;' -} - -@test "postgresql: enabled by default" { - run sudo service postgresql status - - [ "$status" -eq 0 ] -} - -@test "postgresql: query works" { - run psql -c "SELECT version();" - - [ "$status" -eq 0 ] -} - -@test "postgresql: version is 9.5" { - run bash -c 'psql -c "SELECT version();" | grep 9.5' - - [ "$status" -eq 0 ] -} - -@test "postgresql: postgis extention is enabled" { - run create_postgis_extention - - [ "$status" -eq 0 ] -} - -@test "postgresql: circle_test DB is created" { - run bash -c "psql -l | grep circle_test" - - [ "$status" -eq 0 ] -} - -@test "mongodb is enabled by default" { - run test_enabled_default "mongod" - - [ "$status" -eq 0 ] -} - -@test "mongodb works" { - run bash -c "echo 'show dbs;' | mongo" - - [ "$status" -eq 0 ] -} - -@test "redis works" { - sudo service redis-server start - - run bash -c "echo 'SET hoge bar' | redis-cli" - - [ "$status" -eq 0 ] -} - -@test "memcached works" { - sudo service memcached start - - sleep 5 # memcached is slow to start - - run bash -c "echo stats | nc localhost 11211" - - [ "$status" -eq 0 ] -} - -@test "neo4j works" { - sudo service neo4j-service start - - run neo4j-shell -c "mknode --cd" - - [ "$status" -eq 0 ] -} - -@test "neo4j: memory limit is placed" { - run bash -c "grep -v '#' /etc/neo4j/neo4j-wrapper.conf | grep 'wrapper.java.maxmemory'" - - [ "$status" -eq 0 ] -} - -@test "rabbitmq works" { - sudo service rabbitmq-server start - - run sudo rabbitmqctl cluster_status - - [ "$status" -eq 0 ] -} - -@test "elasticsearch works" { - local port=9200 - - sudo service elasticsearch start - - wait_service $port - - run curl http://localhost:$port - - [ "$status" -eq 0 ] -} - -@test "beanstalkd works" { - sudo service beanstalkd start - - run bash -c "echo -e 'stats\r\n' | nc localhost 11300" - - [ "$status" -eq 0 ] -} - -@test "couchdb works" { - local port=5984 - - sudo service couchdb start - - wait_service $port - - run curl http://localhost:$port - - [ "$status" -eq 0 ] -} - -# We just run `docker version` without running actual daemon -# because docker can't run inside docker (DIND) -@test "circleci docker is installed" { - run bash -c 'docker version | grep Version | grep circleci' - - [ "$status" -eq 0 ] -} diff --git a/tests/unit/ubuntu-14.04-XXL/sqlite3.bats b/tests/unit/ubuntu-14.04-XXL/sqlite3.bats deleted file mode 100644 index 51cb0af..0000000 --- a/tests/unit/ubuntu-14.04-XXL/sqlite3.bats +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bats - -@test "sqlite3: 3.15 is installed" { - run bash -c "sqlite3-15 --version | grep '3.15'" - - [ "$status" -eq 0 ] -} diff --git a/trigger-job.sh b/trigger-job.sh deleted file mode 100755 index 175dbdd..0000000 --- a/trigger-job.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash - -help() { - cat << EOF -trigger-job: triggering an image-builder job - -Usage: - trigger-job [-n] <job> <branch> - --n: Using no cache in docker build - -Example: - trigger-job ubuntu-14.04 test-branch -EOF -} - -trigger-job() { - local job=$1 - local branch=$2 - local no_cache=$3 - local no_cache_docker_opt="" - - if [[ $no_cache = "true" ]]; then - no_cache_docker_opt="--no-cache" - fi - - if [[ $no_cache = "true" ]]; then - echo "Triggering $job with no cache..." - else - echo "Triggering $job..." - fi - - curl -u ${CIRCLE_TOKEN}: \ - -d build_parameters[CIRCLE_JOB]=$job \ - -d build_parameters[NO_CACHE]=$no_cache_docker_opt \ - https://circleci.com/api/v1.1/project/github/circleci/image-builder/tree/$branch -} - -while getopts n:h OPT -do - case $OPT in - n) no_cache="true" - shift - ;; - h) help - exit 0 - ;; - \?) help - exit 0 - ;; - esac -done - -job=$1 -branch=$2 - -if [[ -z $CIRCLE_TOKEN ]]; then - echo "You must set CIRCLE_TOKEN env var" - exit 1 -fi - -if [[ -z $job ]]; then - echo "Error: You must specify at least one job" - echo "" - help - exit 1 -fi - -if [[ -z $branch ]]; then - echo "Error: You must specify at least one branch" - echo "" - help - exit 1 -fi - -trigger-job $job $branch $no_cache