From 129525af21d069943bb062e69a2a174e01a2c0e4 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 13 May 2012 20:19:02 -0700 Subject: Fix for https://github.com/ridiculousfish/fishfish/issues/3 cd's special autosuggestion was broken, now fixed. Also, there's some tests for it now. --- common.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'common.cpp') diff --git a/common.cpp b/common.cpp index c283bc7a..787e9ed2 100644 --- a/common.cpp +++ b/common.cpp @@ -84,7 +84,9 @@ parts of fish. struct termios shell_modes; +// Note we foolishly assume that pthread_t is just a primitive. But it might be a struct. static pthread_t main_thread_id = 0; +static bool thread_assertions_configured_for_testing = false; wchar_t ellipsis_char; @@ -1926,6 +1928,10 @@ void set_main_thread() { main_thread_id = pthread_self(); } +void configure_thread_assertions_for_testing(void) { + thread_assertions_configured_for_testing = true; +} + /* Notice when we've forked */ static pid_t initial_pid; @@ -1950,7 +1956,7 @@ bool is_main_thread() { void assert_is_main_thread(const char *who) { - if (! is_main_thread()) { + if (! is_main_thread() && ! thread_assertions_configured_for_testing) { fprintf(stderr, "Warning: %s called off of main thread. Break on debug_thread_error to debug.\n", who); debug_thread_error(); } @@ -1966,7 +1972,7 @@ void assert_is_not_forked_child(const char *who) void assert_is_background_thread(const char *who) { - if (is_main_thread()) { + if (is_main_thread() && ! thread_assertions_configured_for_testing) { fprintf(stderr, "Warning: %s called on the main thread (may block!). Break on debug_thread_error to debug.\n", who); debug_thread_error(); } -- cgit v1.2.3