Skip to content

Commit d36d94a

Browse files
committed
v3: fix remaining macOS CI failures
1 parent 9bb5b5b commit d36d94a

136 files changed

Lines changed: 1723 additions & 463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎cmd/tools/vretry.v‎

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,33 @@ fn quote_arg(arg string) string {
4242
}
4343
}
4444

45-
// windows_quote_arg applies the backslash-and-quote rules Windows uses when it
46-
// rebuilds argv from a command line. Wrapping in quotes is not enough on its own: a
47-
// trailing backslash would escape the closing quote, so `C:\work space\` has to come
48-
// out as `"C:\work space\\"` or it swallows the argument after it. This is the same
49-
// escaping `os.Process` does in vlib/os/process_windows.c.v.
50-
fn windows_quote_arg(arg string) string {
51-
mut out := '"'
52-
mut pending_backslashes := 0
53-
for c in arg {
54-
if c == `\\` {
55-
pending_backslashes++
56-
continue
57-
}
58-
if c == `"` {
59-
// Each backslash run before a quote is doubled, and the quote escaped.
60-
out += '\\'.repeat(pending_backslashes * 2 + 1) + '"'
45+
$if windows {
46+
// windows_quote_arg applies the backslash-and-quote rules Windows uses when it
47+
// rebuilds argv from a command line. Wrapping in quotes is not enough on its own: a
48+
// trailing backslash would escape the closing quote, so `C:\work space\` has to come
49+
// out as `"C:\work space\\"` or it swallows the argument after it. This is the same
50+
// escaping `os.Process` does in vlib/os/process_windows.c.v.
51+
fn windows_quote_arg(arg string) string {
52+
mut out := '"'
53+
mut pending_backslashes := 0
54+
for c in arg {
55+
if c == `\\` {
56+
pending_backslashes++
57+
continue
58+
}
59+
if c == `"` {
60+
// Each backslash run before a quote is doubled, and the quote escaped.
61+
out += '\\'.repeat(pending_backslashes * 2 + 1) + '"'
62+
pending_backslashes = 0
63+
continue
64+
}
65+
out += '\\'.repeat(pending_backslashes) + c.ascii_str()
6166
pending_backslashes = 0
62-
continue
6367
}
64-
out += '\\'.repeat(pending_backslashes) + c.ascii_str()
65-
pending_backslashes = 0
68+
// The run that ends the argument is doubled, so none of it escapes the closing quote.
69+
out += '\\'.repeat(pending_backslashes * 2) + '"'
70+
return out
6671
}
67-
// The run that ends the argument is doubled, so none of it escapes the closing quote.
68-
out += '\\'.repeat(pending_backslashes * 2) + '"'
69-
return out
7072
}
7173

7274
// seconds_to_duration converts a fractional number of seconds, as given on the

‎cmd/tools/vsetup-freetype.v‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module main
22

3-
import os
3+
$if windows {
4+
import os
5+
}
46

57
fn main() {
68
$if windows {

‎examples/eventbus/some_module/some_module.v‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub fn do_work() {
2020
println('working...')
2121
if i == 5 {
2222
event_metadata := &EventMetadata{'Iteration ' + i.str()}
23-
eb.publish('event_foo', duration, event_metadata)
24-
eb.publish('event_bar', duration, event_metadata)
23+
eb.publish('event_foo', &duration, event_metadata)
24+
eb.publish('event_bar', &duration, event_metadata)
2525
}
2626
}
2727
eb.publish('event_baz', &Duration{42}, &EventMetadata{'Additional data at the end.'})

‎examples/pendulum-simulation/sim/runner.v‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module sim
22

33
import benchmark
4-
import term
54

65
pub type SimRequestHandler = fn (request &SimRequest) !
76

@@ -50,7 +49,7 @@ pub fn run(params SimParams, settings RunnerSettings) {
5049
mut bmark := benchmark.new_benchmark()
5150
for y in 0 .. height {
5251
$if verbose ? {
53-
term.clear_previous_line()
52+
clear_verbose_line()
5453
}
5554
log(@MOD + '.' + @FN + ': y: ${y + 1}')
5655
for x in 0 .. width {

‎vlib/builtin/ownership_interface_d_v3_backend.v‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct OwnershipV3InterfacePayload {
1010
fn drop_owned_v3_interface[T](value T) {
1111
$if T.unaliased_typ is $interface {
1212
mut owned := value
13-
raw_interface := unsafe { &OwnershipV3InterfacePayload(&owned) }
13+
raw_interface := unsafe { &OwnershipV3InterfacePayload(voidptr(&owned)) }
1414
if raw_interface.is_boxed {
1515
// The v3 C backend recognizes builtin.drop_owned as an intrinsic and uses
1616
// the interface type id to destroy the concrete value before freeing its box.
@@ -26,7 +26,7 @@ fn drop_owned_interface[T](value T) {
2626
fn drop_owned_result_error_interface(err IError) {
2727
// Pointer-backed errors remain borrowed; only boxed concrete values are owned.
2828
mut owned := err
29-
raw_interface := unsafe { &OwnershipV3InterfacePayload(&owned) }
29+
raw_interface := unsafe { &OwnershipV3InterfacePayload(voidptr(&owned)) }
3030
if raw_interface.is_boxed {
3131
drop_owned(owned)
3232
}

‎vlib/fasthttp/fasthttp_bsd.c.v‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ struct Conn {
157157
mut:
158158
read_buf [buf_size]u8
159159
read_len int
160-
read_extra []u8 // dynamic overflow buffer for large requests (e.g. chunked uploads)
161-
write_buf []u8
160+
read_extra []u8 = []u8{} // dynamic overflow buffer for large requests (e.g. chunked uploads)
161+
write_buf []u8 = []u8{}
162162
write_pos int
163163
request_active bool
164-
read_start i64 // monotonic timestamp (in microseconds) when first data was received
164+
read_start i64 // monotonic timestamp when request data was last received
165165
write_start i64 // monotonic timestamp while a response is blocked on the socket
166166
read_eof bool
167167

@@ -656,6 +656,7 @@ fn handle_read(server &Server, kq int, c_ptr voidptr, mut clients map[int]voidpt
656656
if c.request_active {
657657
return
658658
}
659+
previous_total := c.total_read_len()
659660

660661
// Drain the socket for this kqueue notification. EV_CLEAR only rearms once
661662
// all readable data has been consumed.
@@ -703,8 +704,9 @@ fn handle_read(server &Server, kq int, c_ptr voidptr, mut clients map[int]voidpt
703704
return
704705
}
705706

706-
// Record when we first started receiving data for this request
707-
if c.read_start == 0 {
707+
// Treat the request timeout as an idle timeout. Active uploads can take longer
708+
// than the configured interval as long as each read makes progress.
709+
if total > previous_total {
708710
c.read_start = time.sys_mono_now()
709711
}
710712

‎vlib/fasthttp/fasthttp_bsd_regression_test.c.v‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,48 @@ fn test_keep_alive_completion_rearms_kqueue_read_after_consumed_edge() ! {
6060
assert event.ident == u64(server_fd)
6161
close_conn(server, kq, conn, mut clients)
6262
}
63+
64+
fn test_request_read_progress_refreshes_idle_timeout() ! {
65+
server := new_server(ServerConfig{
66+
family: .ip
67+
port: 0
68+
max_request_buffer_size: 8192
69+
handler: bsd_reregistration_test_handler
70+
})!
71+
kq := C.kqueue()
72+
assert kq >= 0
73+
defer {
74+
C.close(kq)
75+
}
76+
mut sockets := [2]i32{}
77+
assert C.socketpair(C.AF_UNIX, C.SOCK_STREAM, 0, &sockets[0]) == 0
78+
server_fd := int(sockets[0])
79+
client_fd := int(sockets[1])
80+
defer {
81+
C.close(client_fd)
82+
}
83+
set_nonblocking(server_fd)
84+
mut conn := &Conn{
85+
fd: server_fd
86+
file_fd: -1
87+
read_start: 1
88+
}
89+
mut clients := {
90+
server_fd: voidptr(conn)
91+
}
92+
assert C.write(client_fd, c'GET ', 4) == 4
93+
94+
handle_read(server, kq, conn, mut clients)
95+
96+
assert conn.total_read_len() == 4
97+
assert conn.read_start > 1
98+
close_conn(server, kq, conn, mut clients)
99+
}
100+
101+
fn test_conn_dynamic_buffers_are_initialized() {
102+
mut conn := &Conn{}
103+
conn.read_extra << u8(1)
104+
conn.write_buf << u8(2)
105+
assert conn.read_extra == [u8(1)]
106+
assert conn.write_buf == [u8(2)]
107+
}

‎vlib/json2/tests/decode_struct_test.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn test_error_conditions() {
204204

205205
mut error_count := 0
206206
for case in invalid_cases {
207-
result := json.decode[JsonU8](case) or {
207+
_ := json.decode[JsonU8](case) or {
208208
error_count++
209209
continue // Expected failure, error handling works correctly
210210
}

‎vlib/json2/tests/decoder_test.v‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@ fn test_decode_missing_comma() {
117117
"telnr": "+32333"
118118
}
119119
}'
120-
user := json.decode[User](data) or { return }
120+
_ := json.decode[User](data) or { return }
121+
assert false
121122
}

‎vlib/json2/tests/json_sumtype_test.v‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ fn test_any_sum_type() {
123123
}
124124

125125
fn test_sum_type_struct() {
126-
if x := json.decode[Animal]('{"cat_name": "Tom"}') {
126+
if _ := json.decode[Animal]('{"cat_name": "Tom"}') {
127127
assert false
128128
}
129-
if x := json.decode[Animal]('{"dog_name": "Rex"}') {
129+
if _ := json.decode[Animal]('{"dog_name": "Rex"}') {
130130
assert false
131131
}
132132
assert json.decode[Animal]('{"dog_name": "Rex", "_type": "Dog"}')! == Animal(Dog{'Rex'})
@@ -155,13 +155,13 @@ fn test_sum_type_mixed() {
155155
// to be implemented
156156
fn test_sum_type_options_fail() {
157157
assert json.decode[Maybes]('null')! == Maybes(?int(none))
158-
if x := json.decode[Maybes]('99') {
158+
if _ := json.decode[Maybes]('99') {
159159
assert false
160160
}
161-
if x := json.decode[Maybes]('hi') {
161+
if _ := json.decode[Maybes]('hi') {
162162
assert false
163163
}
164-
if x := json.decode[Maybes]('true') {
164+
if _ := json.decode[Maybes]('true') {
165165
assert false
166166
}
167167
}

0 commit comments

Comments
 (0)