Skip to content

Commit

Permalink
improve module build/test tooling
Browse files Browse the repository at this point in the history
 * add `test-module` make target

 * `make distclean` now cleans module src/test directories

 * `runtest-moduleapi` now builds and exercises `testmodule`

 * add `clean` target for `commandfilter`

 * add `.gitignore` for `commandfilter`

 * typo "SOME TEST NOT PASSED!" -> "SOME TEST DID NOT PASS!"
  • Loading branch information
neomantra committed Jul 12, 2019
1 parent a3c33b0 commit 595b272
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions runtest-moduleapi
Expand Up @@ -14,3 +14,6 @@ fi

make -C tests/modules && \
$TCLSH tests/test_helper.tcl --single unit/moduleapi/commandfilter "${@}"

make -C src/modules && \
$TCLSH tests/test_helper.tcl --single unit/moduleapi/testmodule "${@}"
5 changes: 5 additions & 0 deletions src/Makefile
Expand Up @@ -254,13 +254,18 @@ clean:

distclean: clean
-(cd ../deps && $(MAKE) distclean)
-(cd modules && $(MAKE) clean)
-(cd ../tests/modules && $(MAKE) clean)
-(rm -f .make-*)

.PHONY: distclean

test: $(REDIS_SERVER_NAME) $(REDIS_CHECK_AOF_NAME)
@(cd ..; ./runtest)

test-modules: $(REDIS_SERVER_NAME)
@(cd ..; ./runtest-moduleapi)

test-sentinel: $(REDIS_SENTINEL_NAME)
@(cd ..; ./runtest-sentinel)

Expand Down
2 changes: 1 addition & 1 deletion src/modules/testmodule.c
Expand Up @@ -469,7 +469,7 @@ int TestIt(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {

fail:
RedisModule_ReplyWithSimpleString(ctx,
"SOME TEST NOT PASSED! Check server logs");
"SOME TEST DID NOT PASS! Check server logs");
return REDISMODULE_OK;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/modules/.gitignore
@@ -0,0 +1,2 @@
*.so
*.xo
3 changes: 3 additions & 0 deletions tests/modules/Makefile
Expand Up @@ -22,3 +22,6 @@ commandfilter.xo: ../../src/redismodule.h

commandfilter.so: commandfilter.xo
$(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LIBS) -lc

clean:
rm -rf *.xo *.so
3 changes: 2 additions & 1 deletion tests/unit/moduleapi/commandfilter.tcl
Expand Up @@ -81,4 +81,5 @@ start_server {tags {"modules"}} {
assert_equal {} [r lrange log-key 0 -1]
}

}
r module unload commandfilter
}
13 changes: 13 additions & 0 deletions tests/unit/moduleapi/testmodule.tcl
@@ -0,0 +1,13 @@
set testmodule [file normalize src/modules/testmodule.so]


# TEST.CTXFLAGS requires RDB to be disabled, so override save file
start_server {tags {"modules"} overrides {save ""}} {
r module load $testmodule

test {TEST.IT runs successfully} {
r test.it
} "ALL TESTS PASSED"

r module unload test
}

0 comments on commit 595b272

Please sign in to comment.