-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
98 lines (76 loc) · 2.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
current_dir = $(shell pwd)
export SODIUM_LIB_DIR := $(current_dir)/local/lib/
export SODIUM_STATIC := yes
export RUST_BACKTRACE := 1
SPEC_TEST_DIR=tests/spec
TMP_DIR=/tmp/mysteryshack
APP_BINARY=./target/debug/mysteryshack
TEST_CMD=$(APP_BINARY) -c $(TMP_DIR)/config
PROXY_SERVERS=false
all: libsodium
$(MAKE) release-build
release-build:
cargo build --release
debug-build:
cargo build
install-test: install-spectest
test: spectest unittest
install-spectest:
set -ex; \
[ -d $(SPEC_TEST_DIR)/suite ] || git clone https://github.com/remotestorage/api-test-suite $(SPEC_TEST_DIR)/suite
cd $(SPEC_TEST_DIR)/suite && bundle install --path vendor/bundle
testserver-config: debug-build
rm -r $(TMP_DIR) || true
mkdir -p $(TMP_DIR)
echo '[main]' > $(TMP_DIR)/config
echo 'listen = "127.0.0.1:6767"' >> $(TMP_DIR)/config
echo "data_path = \"$(TMP_DIR)\"" >> $(TMP_DIR)/config
echo "use_proxy_headers = $(PROXY_SERVERS)" >> $(TMP_DIR)/config
yes password123 | $(TEST_CMD) user create testuser
spectest: testserver-config
($(MAKE) testserver &);
wget -q --retry-connrefused --waitretry=1 http://localhost:6767/ -O /dev/null
set e && ( \
echo 'storage_base_url: http://127.0.0.1:6767/storage/testuser'; \
echo 'storage_base_url_other: http://127.0.0.1:6767/storage/wronguser'; \
echo 'category: api-test'; \
echo -n 'token: '; \
$(TEST_CMD) user authorize testuser https://example.com api-test:rw; \
echo -n 'read_only_token: '; \
$(TEST_CMD) user authorize testuser https://example.com api-test:r; \
echo -n 'root_token: '; \
$(TEST_CMD) user authorize testuser https://example.com \*:rw; \
) > $(SPEC_TEST_DIR)/suite/config.yml
cd $(SPEC_TEST_DIR)/suite && bundle exec rake test
testserver: debug-build
killall mysteryshack || true
$(TEST_CMD) serve
serve: testserver-config
$(MAKE) testserver
install-codegen:
true
codegen:
scripts/make_templates.py
scripts/make_staticfiles.py
install-clippy:
true
clippy:
cargo build --features clippy
sh:
$$SHELL
install-unittest:
true
unittest:
cargo test
libsodium:
[ -d libsodium ] || git clone https://github.com/jedisct1/libsodium libsodium
set -ex && cd libsodium && \
git fetch && \
git reset --hard && \
git checkout origin/stable && \
rm -rf lib && \
./autogen.sh && \
./configure --prefix=$$PWD/../local/ --disable-shared && \
$(MAKE) && \
$(MAKE) install
.PHONY: test libsodium