Browse Source

Avoid xargs -r

The -r option is not available on OS X
Mike Dillon 9 năm trước cách đây
mục cha
commit
2cba8a8d5f
4 tập tin đã thay đổi với 16 bổ sung4 xóa
  1. 4 1
      test/default-host.bats
  2. 4 1
      test/multiple-hosts.bats
  3. 4 1
      test/multiple-ports.bats
  4. 4 1
      test/wildcard-hosts.bats

+ 4 - 1
test/default-host.bats

@@ -4,7 +4,10 @@ load test_helpers
 function setup {
 	# make sure to stop any web container before each test so we don't
 	# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
-	docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2
+	CIDS=( $(docker ps -q --filter "label=bats-type=web") )
+	if [ ${#CIDS[@]} -gt 0 ]; then
+		docker stop ${CIDS[@]} >&2
+	fi
 }
 
 

+ 4 - 1
test/multiple-hosts.bats

@@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
 function setup {
 	# make sure to stop any web container before each test so we don't
 	# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
-	docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2
+	CIDS=( $(docker ps -q --filter "label=bats-type=web") )
+	if [ ${#CIDS[@]} -gt 0 ]; then
+		docker stop ${CIDS[@]} >&2
+	fi
 }
 
 

+ 4 - 1
test/multiple-ports.bats

@@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
 function setup {
 	# make sure to stop any web container before each test so we don't
 	# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
-	docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2
+	CIDS=( $(docker ps -q --filter "label=bats-type=web") )
+	if [ ${#CIDS[@]} -gt 0 ]; then
+		docker stop ${CIDS[@]} >&2
+	fi
 }
 
 

+ 4 - 1
test/wildcard-hosts.bats

@@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
 function setup {
 	# make sure to stop any web container before each test so we don't
 	# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
-	docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2
+	CIDS=( $(docker ps -q --filter "label=bats-type=web") )
+	if [ ${#CIDS[@]} -gt 0 ]; then
+		docker stop ${CIDS[@]} >&2
+	fi
 }