ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / notebook-renderers / src / test / stackTraceHelper.test.ts 165 строк · изменён 14 нояб., 04:52
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import { formatStackTrace } from '../stackTraceHelper' ;
import * as assert from 'assert' ;
suite ( 'StackTraceHelper' , ( ) => {
test ( 'Non Ipython stack trace is left alone' , ( ) => {
const stack = 'DivideError: integer division error\n' +
'Stacktrace:\n' +
'[1] divide_by_zero(x:: Int64)\n' +
'@Main c:\\src\\test\\3\\otherlanguages\\julia.ipynb: 3\n' +
'[2] top - level scope\n' +
'@c:\\src\\test\\3\\otherlanguages\\julia.ipynb: 1; ' ;
assert. stack formattedStack stack
formatSequence
text
text formatSequence
stack
formattedStack errorLocation stack
cleanStack formattedStack
assert cleanStack cleanStack
assert cleanStack cleanStack
assert cleanStack cleanStack
assert errorLocation
stack
formattedStack errorLocation stack
cleanStack formattedStack
assert cleanStack cleanStack
assert cleanStack cleanStack
assert errorLocation
stack
formattedStack errorLocation stack
cleanStack formattedStack
assert cleanStack cleanStack
assert cleanStack cleanStack
assert errorLocation
stack
formattedLines stack formattedStack
formattedLines line assert line line
stack
formattedStack stack
formatted formattedStack
assert formatted formatted
assert formatted formatted
assert formatted formatted
stack
formatted stack formattedStack
assert formatted formatted
stack
formattedLines stack formattedStack
assert formattedLines formattedLines
formattedLines line assert line line
stack
formattedLines stack formattedStack
assert formattedLines formattedLines
formattedLines line assert line line
equal
(
formatStackTrace
(
,
true
)
.
,
)
;
}
)
;
const
=
/ \u001b \[ . +? m/ g
;
function
stripAsciiFormatting
(
:
string
)
{
return
.
replace
(
,
''
)
;
}
test
(
'IPython stack line numbers are linkified for IPython 8.3.6'
,
(
)
=>
{
const
=
'\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n'
+
'\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n'
+
'Cell \u001b[1;32mIn[3], line 2\u001b[0m\n'
+
'\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmyLib\u001b[39;00m\n'
+
'\u001b[1;32m----> 2\u001b[0m \u001b[43mmyLib\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mthrowEx\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n'
+
'\n'
+
'File \u001b[1;32mC:\\venvs\\myLib.py:2\u001b[0m, in \u001b[0;36mthrowEx\u001b[1;34m()\u001b[0m\n'
+
'\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mthrowEx\u001b[39m():\n'
+
'\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m\n\n'
+
'\u001b[1;31mException\u001b[0m\n:'
;
const
{
,
}
=
formatStackTrace
(
,
true
)
;
const
=
stripAsciiFormatting
(
)
;
.
ok
(
.
indexOf
(
'Cell In[3], <a href=\'vscode-notebook-cell:?execution_count=3&line=2\'>line 2</a>'
)
>
0
,
'Missing line link in '
+
)
;
.
ok
(
.
indexOf
(
'<a href=\'vscode-notebook-cell:?execution_count=3&line=2\'>2</a>'
)
>
0
,
'Missing frame link in '
+
)
;
.
ok
(
.
indexOf
(
'<a href=\'C:\\venvs\\myLib.py:2\'>2</a>'
)
>
0
,
'Missing frame link in '
+
)
;
.
equal
(
,
'<a href=\'vscode-notebook-cell:?execution_count=3&line=2\'>line 2</a>'
)
;
}
)
;
test
(
'IPython stack line numbers are linkified for IPython 9.0.0'
,
(
)
=>
{
const
=
'\u001b[31m---------------------------------------------------------------------------\u001b[39m\n'
+
'\u001b[31mTypeError\u001b[39m Traceback (most recent call last)\n'
+
'\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 2\u001b[39m\n'
+
'\u001b[32m 1\u001b[39m x = firstItem((\u001b[32m1\u001b[39m, \u001b[32m2\u001b[39m, \u001b[32m3\u001b[39m, \u001b[32m5\u001b[39m))\n'
+
'\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m y = \u001b[43mx\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m1\u001b[39;49m\n'
+
'\u001b[32m 3\u001b[39m \u001b[38;5;28mprint\u001b[39m(y)\n'
+
'\n'
+
'\u001b[31mTypeError\u001b[39m: unsupported operand type(s) for +: "NoneType" and "int"\n'
;
const
{
,
}
=
formatStackTrace
(
,
true
)
;
const
=
stripAsciiFormatting
(
)
;
.
ok
(
.
indexOf
(
'Cell In[3], <a href=\'vscode-notebook-cell:?execution_count=3&line=2\'>line 2</a>'
)
>
0
,
'Missing line link in '
+
)
;
.
ok
(
.
indexOf
(
'<a href=\'vscode-notebook-cell:?execution_count=3&line=2\'>2</a>'
)
>
0
,
'Missing frame link in '
+
)
;
.
equal
(
,
'<a href=\'vscode-notebook-cell:?execution_count=3&line=2\'>line 2</a>'
)
;
}
)
;
test
(
'Does not have catastrophic backtracking https://github.com/microsoft/vscode/issues/251731'
,
(
)
=>
{
const
=
'\u001b[31m---------------------------------------------------------------------------\u001b[39m\n'
+
'\u001b[31mZeroDivisionError\u001b[39m Traceback (most recent call last)\n'
+
'\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m raw_str = \u001b[33mr\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m\\\u001b[39m\u001b[33ma\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mc\u001b[39m\u001b[33m\\\u001b[39m\u001b[33me\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mf\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mg\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mh\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mi\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mk\u001b[39m\u001b[33m\\\u001b[39m\u001b[33ml\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mm\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mn\u001b[39m\u001b[33m\\\u001b[39m\u001b[33mo\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m \u001b[32;43m1\u001b[39;49m\u001b[43m/\u001b[49m\u001b[32;43m0\u001b[39;49m\n\n'
+
'\u001b[31mZeroDivisionError\u001b[39m: division by zero\n'
;
const
{
,
}
=
formatStackTrace
(
,
true
)
;
const
=
stripAsciiFormatting
(
)
;
.
ok
(
.
indexOf
(
'Cell In[1], <a href=\'vscode-notebook-cell:?execution_count=1&line=2\'>line 2</a>'
)
>
0
,
'Missing line link in '
+
)
;
.
ok
(
.
indexOf
(
'<a href=\'vscode-notebook-cell:?execution_count=1&line=2\'>2</a>'
)
>
0
,
'Missing frame link in '
+
)
;
.
equal
(
,
'<a href=\'vscode-notebook-cell:?execution_count=1&line=2\'>line 2</a>'
)
;
}
)
;
test
(
'Stack trace is not linkified when HTML is not trusted'
,
(
)
=>
{
const
=
'\u001b[31m---------------------------------------------------------------------------\u001b[39m\n'
+
'\u001b[31mTypeError\u001b[39m Traceback (most recent call last)\n'
+
'\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 2\u001b[39m\n'
+
'\u001b[32m 1\u001b[39m x = firstItem((\u001b[32m1\u001b[39m, \u001b[32m2\u001b[39m, \u001b[32m3\u001b[39m, \u001b[32m5\u001b[39m))\n'
+
'\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m y = \u001b[43mx\u001b[49m\u001b[43m \u001b[49m\u001b[43m+\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m1\u001b[39;49m\n'
+
'\u001b[32m 3\u001b[39m \u001b[38;5;28mprint\u001b[39m(y)\n'
+
'\n'
+
'\u001b[31mTypeError\u001b[39m: unsupported operand type(s) for +: "NoneType" and "int"\n'
;
const
=
formatStackTrace
(
,
false
)
.
.
split
(
'\n'
)
;
.
forEach
(
=>
.
ok
(
!
/ <a href=. * > /
.
test
(
)
,
'line should not contain a link: '
+
)
)
;
}
)
;
test
(
'IPython stack line numbers are linkified for IPython 8.3'
,
(
)
=>
{
const
=
'\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n'
+
'\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n'
+
'Input \u001b[1;32mIn [2]\u001b[0m, in \u001b[0;36m<cell line: 5>\u001b[1;34m()\u001b[0m\n'
+
'\u001b[0;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\'\u001b[39m\u001b[38;5;124mipykernel\u001b[39m\u001b[38;5;124m\'\u001b[39m, ipykernel\u001b[38;5;241m.\u001b[39m__version__)\n'
+
'\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\'\u001b[39m\u001b[38;5;124mipython\u001b[39m\u001b[38;5;124m\'\u001b[39m, IPython\u001b[38;5;241m.\u001b[39m__version__)\n'
+
'\u001b[1;32m----> 5\u001b[0m \u001b[43mmyfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n'
+
'\n\n'
+
'Input \u001b[1;32mIn [1]\u001b[0m, in \u001b[0;36mmyfunc\u001b[1;34m()\u001b[0m\n'
+
'\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mmyfunc\u001b[39m():\n'
+
'\u001b[1;32m----> 4\u001b[0m \u001b[43mmyLib\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mthrowEx\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n'
+
'\n\n'
+
'File \u001b[1;32mC:\\venvs\\myLib.py:2\u001b[0m, in \u001b[0;36mthrowEx\u001b[1;34m()\u001b[0m\n'
+
'\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mthrowEx\u001b[39m():\n'
+
'\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m\n'
+
'\n'
+
'\u001b[1;31mException\u001b[0m:\n'
;
const
{
}
=
formatStackTrace
(
,
true
)
;
const
=
stripAsciiFormatting
(
)
;
.
ok
(
.
indexOf
(
'Input <a href=\'vscode-notebook-cell:?execution_count=2\'>In [2]</a>, in <cell line: 5>'
)
>
0
,
'Missing cell link in '
+
)
;
.
ok
(
.
indexOf
(
'Input <a href=\'vscode-notebook-cell:?execution_count=1\'>In [1]</a>, in myfunc()'
)
>
0
,
'Missing cell link in '
+
)
;
.
ok
(
.
indexOf
(
'<a href=\'vscode-notebook-cell:?execution_count=2&line=5\'>5</a>'
)
>
0
,
'Missing frame link in '
+
)
;
}
)
;
test
(
'IPython stack trace lines without associated location are not linkified'
,
(
)
=>
{
const
=
'\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n'
+
'\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n'
+
'Cell \u001b[1;32mIn[3], line 2\u001b[0m\n'
+
'\n'
+
'unknown source\n'
+
'\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mthrowEx\u001b[39m():\n'
+
'\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m\n\n'
+
'\u001b[1;31mException\u001b[0m\n:'
;
const
=
formatStackTrace
(
,
true
)
.
;
.
ok
(
!
/ <a href=. * >\d <\/ a> /
.
test
(
)
,
)
;
}
)
;
test
(
'IPython stack without line numbers are not linkified'
,
(
)
=>
{
const
=
'\u001b[1;36m Cell \u001b[1;32mIn[6], line 1\u001b[1;36m\u001b[0m\n'
+
'\u001b[1;33m print(\u001b[0m\n'
+
'\u001b[1;37m ^\u001b[0m\n'
+
'\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m incomplete input\n'
+
'1 print(\n'
+
'a 1 print(\n'
+
' 1a print(\n'
;
const
=
formatStackTrace
(
,
true
)
.
.
split
(
'\n'
)
;
.
ok
(
/ <a href='vscode-notebook-cell. * > /
.
test
(
[
0
]
)
,
'line should contain a link: '
+
[
0
]
)
;
.
slice
(
1
)
.
forEach
(
=>
.
ok
(
!
/ <a href=. * > /
.
test
(
)
,
'line should not contain a link: '
+
)
)
;
}
)
;
test
(
'background (40-49) ANSI colors are removed'
,
(
)
=>
{
const
=
'open\u001b[39;49m\u001b[43m(\u001b[49m\u001b[33;43m\'\u001b[39;49m\u001b[33;43minput.txt\u001b[39;49m\u001b[33;43m\'\u001b[39;49m\u001b[43m)\u001b[49m;'
;
const
=
formatStackTrace
(
,
true
)
.
.
split
(
'\n'
)
;
.
ok
(
!
/ 4\d /
.
test
(
[
0
]
)
,
'should not contain background colors '
+
[
0
]
)
;
.
slice
(
1
)
.
forEach
(
=>
.
ok
(
!
/ <a href=. * > /
.
test
(
)
,
'line should not contain a link: '
+
)
)
;
}
)
;
}
)
;