aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-03-23 15:44:43 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-03-23 15:44:43 -0400
commit674375e78d29ec6abf3c0ae8ba230c619229c7ce (patch)
treed1de220aa5d3ba1f0f834c70b62647f1b4b6e5cc /src
parentf8fc742043c749768266e6b9d432b4cfeb861b28 (diff)
downloadtextadept-674375e78d29ec6abf3c0ae8ba230c619229c7ce.tar.gz
textadept-674375e78d29ec6abf3c0ae8ba230c619229c7ce.zip
Added unit tests for core code in textadept.c.
Most of the core is exercised by the Lua test suite, but coverage lapses can be uncovered using the GCC compiler flags "-fprofile-arcs -ftest-coverage"..
Diffstat (limited to 'src')
-rw-r--r--src/Makefile8
-rw-r--r--src/textadept.c6
2 files changed, 11 insertions, 3 deletions
diff --git a/src/Makefile b/src/Makefile
index 2dc53fab..330bacc4 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -146,7 +146,13 @@ cdk_objs = $(addprefix cdk-, binding.o buttonbox.o cdk.o cdk_display.o \
slider.o traverse.o version.o)
# Add debugging symbols and disable optimizations when DEBUG=1.
-# Note: In order to profile with gprof (-pg), do not retain symbols in LDFLAGS.
+# Notes:
+# In order to profile with gprof (-pg), do not retain symbols in LDFLAGS.
+# In order to report code coverage with gcov (-fprofile-arcs -ftest-coverage):
+# Run test suite with textadept, run gcov textadept.c, then examine
+# textadept.c.gcov
+# Run test suite with textadept-curses, run gcov textadept-curses.c, then
+# examine textadept.c.gcov.
ifdef DEBUG
CFLAGS += -g -O0
CXXFLAGS += -g -O0
diff --git a/src/textadept.c b/src/textadept.c
index a2e663ba..ac9743f7 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -230,7 +230,9 @@ static int emit(lua_State *L, const char *name, ...) {
}
va_end(ap);
if (lua_pcall(L, n, 1, 0) != LUA_OK) {
- emit(L, "error", LUA_TSTRING, lua_tostring(L, -1), -1);
+ // An error occurred within `events.emit()` itself, not an event handler.
+ const char *argv[] = {"--title", "Error", "--text", lua_tostring(L, -1)};
+ free(gtdialog(GTDIALOG_TEXTBOX, 4, argv));
return (lua_pop(L, 2), FALSE); // result, events
}
ret = lua_toboolean(L, -1);
@@ -1413,7 +1415,7 @@ static int run_file(lua_State *L, const char *filename) {
const char *argv[] = {
"--title", "Initialization Error", "--text", lua_tostring(L, -1)
};
- free(gtdialog(GTDIALOG_TEXTBOX, 7, argv));
+ free(gtdialog(GTDIALOG_TEXTBOX, 4, argv));
lua_settop(L, 0);
}
free(file);