Skip to content

Commit

Permalink
Use a common target to pick yadm to test in test/scripthost
Browse files Browse the repository at this point in the history
  • Loading branch information
erijo committed Dec 30, 2020
1 parent 0d3ff08 commit a9d9e89
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.jekyll-metadata
.pytest_cache
.sass-cache
.testyadm
_site
testenv
35 changes: 17 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,43 +97,42 @@ test:
docker run --rm -it -v "$(CURDIR):/yadm:ro" $(IMAGE) make test testargs="$(testargs)"; \
fi

.PHONY: testhost
testhost: version ?= HEAD
testhost: require-docker
@rm -rf /tmp/testhost
.PHONY: .testyadm
.testyadm: version ?= HEAD
.testyadm:
@echo "Using yadm version=\"$(version)\""
@if [ "$(version)" = "local" ]; then \
cp -f yadm /tmp/testhost; \
cp -f yadm $@; \
else \
git show $(version):yadm > /tmp/testhost; \
git show $(version):yadm > $@; \
fi
@chmod a+x /tmp/testhost
@echo Starting testhost version=\"$(version)\"
@chmod a+x $@

.PHONY: testhost
testhost: require-docker .testyadm
@echo "Starting testhost"
@docker run \
-w /root \
--hostname testhost \
--rm -it \
-v "/tmp/testhost:/bin/yadm:ro" \
-v "$(CURDIR)/.testyadm:/bin/yadm:ro" \
$(IMAGE) \
bash -l

.PHONY: scripthost
scripthost: version ?= HEAD
scripthost: require-docker
@rm -rf /tmp/testhost
@git show $(version):yadm > /tmp/testhost
@chmod a+x /tmp/testhost
@echo Starting scripthost version=\"$(version)\" \(recording script\)
scripthost: require-docker .testyadm
@echo "Starting scripthost \(recording script\)"
@printf '' > script.gz
@docker run \
-w /root \
--hostname scripthost \
--rm -it \
-v "$$PWD/script.gz:/script.gz:rw" \
-v "/tmp/testhost:/bin/yadm:ro" \
-v "$(CURDIR)/script.gz:/script.gz:rw" \
-v "$(CURDIR)/.testyadm:/bin/yadm:ro" \
$(IMAGE) \
bash -c "script /tmp/script -q -c 'bash -l'; gzip < /tmp/script > /script.gz"
@echo
@echo "Script saved to $$PWD/script.gz"
@echo "Script saved to $(CURDIR)/script.gz"


.PHONY: testenv
Expand Down

0 comments on commit a9d9e89

Please sign in to comment.