From c769e8a4796fa791e4dea0393a3d7e973da4b3e7 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sat, 21 Nov 2020 16:42:26 +0000 Subject: [PATCH] Fix up the tests to work in linux container too --- autoload/vimspector/internal/state.vim | 1 + python3/vimspector/stack_trace.py | 37 ++++----- run_tests | 2 +- tests/breakpoints_doublewidth.test.vim | 1 + tests/ci/image/Dockerfile | 15 +++- tests/stack_trace.test.vim | 106 ++++++++++++++----------- tests/testdata/cpp/simple/Makefile | 1 + 7 files changed, 93 insertions(+), 70 deletions(-) diff --git a/autoload/vimspector/internal/state.vim b/autoload/vimspector/internal/state.vim index b4f18aa..f1e690a 100644 --- a/autoload/vimspector/internal/state.vim +++ b/autoload/vimspector/internal/state.vim @@ -34,6 +34,7 @@ function! vimspector#internal#state#Reset() abort catch /.*/ echohl WarningMsg echom 'Exception while loading vimspector:' v:exception + echom 'From:' v:throwpoint echom 'Vimspector unavailable: Requires Vim compiled with Python 3.6' echohl None return v:false diff --git a/python3/vimspector/stack_trace.py b/python3/vimspector/stack_trace.py index f039dde..e394df9 100644 --- a/python3/vimspector/stack_trace.py +++ b/python3/vimspector/stack_trace.py @@ -81,8 +81,8 @@ class StackTraceView( object ): PENDING = 2 # FIXME: Make into a dict by id ? - _threads: list[ Thread ] - _line_to_thread = dict[ int, Thread ] + _threads: typing.List[ Thread ] + _line_to_thread = typing.Dict[ int, Thread ] def __init__( self, session, win ): self._logger = logging.getLogger( __name__ ) @@ -264,25 +264,26 @@ class StackTraceView( object ): else: self._next_sign_id = 1 - with ( utils.ModifiableScratchBuffer( self._buf ), - utils.RestoreCursorPosition() ): - utils.ClearBuffer( self._buf ) + with utils.ModifiableScratchBuffer( self._buf ): + with utils.RestoreCursorPosition(): + utils.ClearBuffer( self._buf ) - for thread in self._threads: - icon = '+' if not thread.IsExpanded() else '-' - line = utils.AppendToBuffer( - self._buf, - f'{icon} Thread: {thread.thread["name"]} ({thread.State()})' ) + for thread in self._threads: + icon = '+' if not thread.IsExpanded() else '-' + line = utils.AppendToBuffer( + self._buf, + f'{icon} Thread {thread.id}: {thread.thread["name"]} ' + f'({thread.State()})' ) - if self._current_thread == thread.id: - signs.PlaceSign( self._next_sign_id, - 'VimspectorStackTrace', - 'vimspectorCurrentThread', - self._buf.name, - line ) + if self._current_thread == thread.id: + signs.PlaceSign( self._next_sign_id, + 'VimspectorStackTrace', + 'vimspectorCurrentThread', + self._buf.name, + line ) - self._line_to_thread[ line ] = thread - self._DrawStackTrace( thread ) + self._line_to_thread[ line ] = thread + self._DrawStackTrace( thread ) def _LoadStackTrace( self, thread: Thread, diff --git a/run_tests b/run_tests index b0b244b..39dc7ec 100755 --- a/run_tests +++ b/run_tests @@ -142,7 +142,7 @@ echo " * BASEDIR_CMD=$BASEDIR_CMD" echo "%SETUP - Building test programs..." set -e pushd tests/testdata/cpp/simple - make all + make clean all popd set +e echo "%DONE - built test programs" diff --git a/tests/breakpoints_doublewidth.test.vim b/tests/breakpoints_doublewidth.test.vim index cfd4e6c..73f1f01 100644 --- a/tests/breakpoints_doublewidth.test.vim +++ b/tests/breakpoints_doublewidth.test.vim @@ -695,6 +695,7 @@ endfunction function! Test_Add_Line_BP_In_Other_File_While_Debugging() + call ThisTestIsFlaky() let moo = 'moo.py' let cow = 'cow.py' lcd ../support/test/python/multiple_files diff --git a/tests/ci/image/Dockerfile b/tests/ci/image/Dockerfile index 4494cf1..a25febc 100644 --- a/tests/ci/image/Dockerfile +++ b/tests/ci/image/Dockerfile @@ -4,13 +4,19 @@ ENV DEBIAN_FRONTEND=noninteractive ENV LC_ALL C.UTF-8 RUN apt-get update && \ - apt install -y curl dirmngr apt-transport-https lsb-release ca-certificates \ - software-properties-common && \ + apt-get install -y curl \ + dirmngr \ + apt-transport-https \ + lsb-release \ + ca-certificates \ + software-properties-common && \ curl -sL https://deb.nodesource.com/setup_12.x | bash - && \ add-apt-repository ppa:bartbes/love-stable -y && \ apt-get update && \ apt-get -y dist-upgrade && \ - apt-get -y install python3-dev \ + apt-get -y install gcc-8 \ + g++-8 \ + python3-dev \ python3-pip \ python3-venv \ ca-cacert \ @@ -31,6 +37,9 @@ RUN apt-get update && \ RUN ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime && \ dpkg-reconfigure --frontend noninteractive tzdata +RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 1 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-8 + ## cleanup of files from setup RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/tests/stack_trace.test.vim b/tests/stack_trace.test.vim index d88b081..569376c 100644 --- a/tests/stack_trace.test.vim +++ b/tests/stack_trace.test.vim @@ -11,7 +11,7 @@ endfunction function! s:StartDebugging() exe 'edit ' . s:fn call vimspector#SetLineBreakpoint( s:fn, 15 ) - call vimspector#Launch() + call vimspector#LaunchWithSettings( #{ configuration: 'run-to-breakpoint' } ) call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 15, 1 ) endfunction @@ -32,8 +32,8 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '- Thread: Thread #1 (paused)', - \ ' .*: threads!main@threads.cpp:' . string( thread_l ) + \ '- Thread [0-9]\+: .* (paused)', + \ ' .*: .*@threads.cpp:' . string( thread_l ) \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ 1, @@ -47,8 +47,8 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '- Thread: Thread #1 (paused)', - \ ' .*: threads!main@threads.cpp:' . string( thread_l ) + \ '- Thread [0-9]\+: .* (paused)', + \ ' .*: .*@threads.cpp:' . string( thread_l ) \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ 1, @@ -58,7 +58,7 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ '$', @@ -72,8 +72,8 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '- Thread: Thread #1 (paused)', - \ ' .*: threads!main@threads.cpp:' . string( thread_l ) + \ '- Thread [0-9]\+: .* (paused)', + \ ' .*: .*@threads.cpp:' . string( thread_l ) \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ 1, @@ -83,7 +83,7 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #3 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ '$', @@ -97,8 +97,8 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '- Thread: Thread #1 (paused)', - \ ' .*: threads!main@threads.cpp:' . string( thread_l ) + \ '- Thread [0-9]\+: .* (paused)', + \ ' .*: .*@threads.cpp:' . string( thread_l ) \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ 1, @@ -108,7 +108,7 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #4 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ '$', @@ -123,8 +123,8 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '- Thread: Thread #1 (paused)', - \ ' .*: threads!main@threads.cpp:' . string( thread_l ) + \ '- Thread [0-9]\+: .* (paused)', + \ ' .*: .*@threads.cpp:' . string( thread_l ) \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ 1, @@ -134,7 +134,7 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #5 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ '$', @@ -148,8 +148,8 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '- Thread: Thread #1 (paused)', - \ ' .*: threads!main@threads.cpp:' . string( notify_l ) + \ '- Thread [0-9]\+: .* (paused)', + \ ' .*: .*@threads.cpp:' . string( notify_l ) \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ 1, @@ -159,7 +159,7 @@ function! Test_Multiple_Threads_Continue() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #6 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ '$', @@ -174,7 +174,13 @@ endfunction function! Test_Multiple_Threads_Step() let thread_l = 67 - let thread_n = thread_l + 1 + if $VIMSPECTOR_MIMODE ==# 'lldb' + " } + let thread_n = thread_l + 1 + else + " for .... + let thread_n = 49 + endif let notify_l = 74 call vimspector#SetLineBreakpoint( s:fn, thread_l ) @@ -188,8 +194,8 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '- Thread: Thread #1 (paused)', - \ ' .*: threads!main@threads.cpp:' . string( thread_l ) + \ '- Thread [0-9]\+: .* (paused)', + \ ' .*: .*@threads.cpp:' . string( thread_l ) \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ 1, @@ -201,7 +207,7 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ '$', @@ -214,7 +220,7 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ '$', @@ -226,8 +232,8 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', - \ '+ Thread: Thread #3 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ -1, @@ -240,8 +246,8 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', - \ '+ Thread: Thread #3 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ -1, @@ -253,9 +259,9 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', - \ '+ Thread: Thread #3 (paused)', - \ '+ Thread: Thread #4 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ -2, @@ -269,9 +275,9 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', - \ '+ Thread: Thread #3 (paused)', - \ '+ Thread: Thread #4 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ -2, @@ -283,10 +289,10 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', - \ '+ Thread: Thread #3 (paused)', - \ '+ Thread: Thread #4 (paused)', - \ '+ Thread: Thread #5 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ -3, @@ -300,10 +306,10 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', - \ '+ Thread: Thread #3 (paused)', - \ '+ Thread: Thread #4 (paused)', - \ '+ Thread: Thread #5 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ -3, @@ -315,11 +321,11 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #2 (paused)', - \ '+ Thread: Thread #3 (paused)', - \ '+ Thread: Thread #4 (paused)', - \ '+ Thread: Thread #5 (paused)', - \ '+ Thread: Thread #6 (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), \ -4, @@ -334,10 +340,14 @@ function! Test_Multiple_Threads_Step() call WaitForAssert( {-> \ AssertMatchist( \ [ - \ '+ Thread: Thread #6', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', + \ '+ Thread [0-9]\+: .* (paused)', \ ], \ GetBufLine( winbufnr( g:vimspector_session_windows.stack_trace ), - \ '$', + \ -4, \ '$' ) \ ) \ } ) diff --git a/tests/testdata/cpp/simple/Makefile b/tests/testdata/cpp/simple/Makefile index d3487aa..471edae 100644 --- a/tests/testdata/cpp/simple/Makefile +++ b/tests/testdata/cpp/simple/Makefile @@ -3,6 +3,7 @@ CXXFLAGS=-g -O0 -std=c++17 .PHONY: all TARGETS=simple variables struct printer threads +LDLIBS=-lpthread all: $(TARGETS)