<commit_before>SHELL=/bin/sh

# Emoxi relies on some of the modules contained in ns_server, it
# is assumed that somewhere on the system under tests there is a built
# ns_server repo, these values can be overridded by using -e on the make
# command
#
NS_SERVER_REPO=../ns_server
NS_SERVER_EBIN=$(NS_SERVER_REPO)/ebin

EFLAGS=-pa ebin $(NS_SERVER_EBIN)

LUA=cd ../moxilua && lua -l luarocks.require

MEMCAPABLE_SCRIPT=./test/memcapable_test.sh

MEMCAPABLE=/usr/local/bin/memcapable

MEMCACHED=/usr/local/bin/memcached

TMP_DIR=./tmp

TMP_VER=$(TMP_DIR)/version_num.tmp

MEMCAPABLE_HOST=127.0.0.1

MEMCAPABLE_PORT=11211

.PHONY: ebins ebin_app version $(NS_SERVER_EBIN)

all: ebins test

ebins: ebin_app
	test -d ebin || mkdir ebin
	erl $(EFLAGS) -make

ebin_app: version
	test -d ebin || mkdir ebin
	sed s/0.0.0/`cat $(TMP_VER)`/g src/emoxi.app.src > ebin/emoxi.app

version:
	test -d $(TMP_DIR) || mkdir $(TMP_DIR)
	git describe | sed s/-/_/g > $(TMP_VER)

bdist: clean ebins
	tar --directory=.. -czf emoxi_`cat $(TMP_VER)`.tar.gz emoxi/ebin
	echo created emoxi_`cat $(TMP_VER)`.tar.gz

$(TMP_DIR):
	mkdir -p $(TMP_DIR);

clean:
	rm -f $(TMP_VER)
	rm -f $(TMP_DIR)/memcapable*
	rm -f $(TMP_DIR)/*.cov.html
	rm -f erl_crash.dump
	rm -rf test/log
	rm -rf ebin
	rm -f emoxi_*.tar.gz

test: test_unit cucumber

test_full: test memcapable

test_unit: ebins $(NS_SERVER_EBIN)
	$(MEMCACHED) -p 11211 -d -P /tmp/memcached.pid -E $(MEMCACHED)/.libs/default_engine.so
	erl $(EFLAGS) ../../ebin -noshell -s mc_test test -s init stop -kernel error_logger silent
	kill `cat /tmp/memcached.pid`

test_unit_verbose: ebins $(NS_SERVER_EBIN)
	$(MEMCACHED) -p 11211 -d -P /tmp/memcached.pid -E $(MEMCACHED)/.libs/default_engine.so
	erl $(EFLAGS) ../../ebin -noshell -s mc_test test -s init stop
	kill `cat /tmp/memcached.pid`

test_main: ebin $(NS_SERVER_EBIN)
	erl $(EFLAGS) -s mc_test main -noshell

test_main_shell: ebin $(NS_SERVER_EBIN)
	erl $(EFLAGS) -s mc_test main

test_main_mock: ebin $(NS_SERVER_EBIN)
	erl $(EFLAGS) -s mc_test main_mock

test_main_mock_driver: ebin $(NS_SERVER_EBIN)
	python ./test/emoxi_test.py

test_client_ascii:
	$(LUA) protocol_memcached/test_client_ascii.lua localhost:11300
	$(LUA) protocol_memcached/test_client_ascii.lua localhost:11400
	$(LUA) protocol_memcached/test_client_ascii.lua localhost:11233
	$(LUA) protocol_memcached/test_client_ascii.lua localhost:11244

test_client_binary:
	$(LUA) protocol_memcached/test_client_binary.lua localhost:11600
	$(LUA) protocol_memcached/test_client_binary.lua localhost:11244<commit_msg>Path to memcached engine used by makefile can be controlled at build time<commit_after>SHELL=/bin/sh

# Emoxi relies on some of the modules contained in ns_server, it
# is assumed that somewhere on the system under tests there is a built
# ns_server repo, these values can be overridded by using -e on the make
# command
#
NS_SERVER_REPO=../ns_server
NS_SERVER_EBIN=$(NS_SERVER_REPO)/ebin

EFLAGS=-pa ebin $(NS_SERVER_EBIN)

LUA=cd ../moxilua && lua -l luarocks.require

MEMCAPABLE_SCRIPT=./test/memcapable_test.sh

MEMCAPABLE=/usr/local/bin/memcapable

MEMCACHED=/usr/local/bin/memcached

MEMCACHED_LIBS=$(realpath $(dir $(MEMCACHED)).libs)

MEMCACHED_ENGINE=$(MEMCACHED_LIBS)/default_engine.so

TMP_DIR=./tmp

TMP_VER=$(TMP_DIR)/version_num.tmp

MEMCAPABLE_HOST=127.0.0.1

MEMCAPABLE_PORT=11211

.PHONY: ebins ebin_app version $(NS_SERVER_EBIN)

all: ebins test

ebins: ebin_app
	test -d ebin || mkdir ebin
	erl $(EFLAGS) -make

ebin_app: version
	test -d ebin || mkdir ebin
	sed s/0.0.0/`cat $(TMP_VER)`/g src/emoxi.app.src > ebin/emoxi.app

version:
	test -d $(TMP_DIR) || mkdir $(TMP_DIR)
	git describe | sed s/-/_/g > $(TMP_VER)

bdist: clean ebins
	tar --directory=.. -czf emoxi_`cat $(TMP_VER)`.tar.gz emoxi/ebin
	echo created emoxi_`cat $(TMP_VER)`.tar.gz

$(TMP_DIR):
	mkdir -p $(TMP_DIR);

clean:
	rm -f $(TMP_VER)
	rm -f $(TMP_DIR)/memcapable*
	rm -f $(TMP_DIR)/*.cov.html
	rm -f erl_crash.dump
	rm -rf test/log
	rm -rf ebin
	rm -f emoxi_*.tar.gz

test: test_unit cucumber

test_full: test memcapable

test_unit: ebins $(NS_SERVER_EBIN)
	$(MEMCACHED) -p 11211 -d -P /tmp/memcached.pid -E $(MEMCACHED_ENGINE)
	erl $(EFLAGS) ../../ebin -noshell -s mc_test test -s init stop -kernel error_logger silent
	kill `cat /tmp/memcached.pid`

test_unit_verbose: ebins $(NS_SERVER_EBIN)
	$(MEMCACHED) -p 11211 -d -P /tmp/memcached.pid -E $(MEMCACHED_ENGINE)
	erl $(EFLAGS) ../../ebin -noshell -s mc_test test -s init stop
	kill `cat /tmp/memcached.pid`

test_main: ebin $(NS_SERVER_EBIN)
	erl $(EFLAGS) -s mc_test main -noshell

test_main_shell: ebin $(NS_SERVER_EBIN)
	erl $(EFLAGS) -s mc_test main

test_main_mock: ebin $(NS_SERVER_EBIN)
	erl $(EFLAGS) -s mc_test main_mock

test_main_mock_driver: ebin $(NS_SERVER_EBIN)
	python ./test/emoxi_test.py

test_client_ascii:
	$(LUA) protocol_memcached/test_client_ascii.lua localhost:11300
	$(LUA) protocol_memcached/test_client_ascii.lua localhost:11400
	$(LUA) protocol_memcached/test_client_ascii.lua localhost:11233
	$(LUA) protocol_memcached/test_client_ascii.lua localhost:11244

test_client_binary:
	$(LUA) protocol_memcached/test_client_binary.lua localhost:11600
	$(LUA) protocol_memcached/test_client_binary.lua localhost:11244
{'fraction_non_alphanumeric': 0.12664756446991404, 'fraction_numerical': 0.020630372492836675, 'mean_word_length': 4.63010752688172, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '268748', 'n_tokens_mistral': 2272, 'n_tokens_neox': 2161, 'n_words': 501}