Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix_immutable_to_mu…
Browse files Browse the repository at this point in the history
…table
  • Loading branch information
felipensp committed Nov 7, 2024
2 parents 54fc630 + dab25ca commit b75f10a
Show file tree
Hide file tree
Showing 169 changed files with 3,896 additions and 823 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
clang:
strategy:
matrix:
os: [macos-12, macos-14]
os: [macos-14]
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 121
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/more_extensive_but_slower_tests_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
more-tests:
strategy:
matrix:
os: [ubuntu-latest, macos-12, macos-14, windows-latest]
os: [ubuntu-latest, macos-14, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 121
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/native_backend_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
native-backend:
strategy:
matrix:
os: [ubuntu-20.04, macos-12, windows-2019]
os: [ubuntu-20.04, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
fi
macos:
runs-on: macos-12
runs-on: macos-14
strategy:
matrix:
cc: [clang]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/v_apps_and_modules_compile_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
common:
strategy:
matrix:
os: [ubuntu-latest, macos-12, macos-14]
os: [ubuntu-latest, macos-14]
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 121
Expand Down Expand Up @@ -226,7 +226,7 @@ jobs:
vsl:
strategy:
matrix:
os: [ubuntu-20.04, macos-12, macos-14]
os: [ubuntu-20.04, macos-14]
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 121
Expand Down Expand Up @@ -257,7 +257,7 @@ jobs:
vtl:
strategy:
matrix:
os: [ubuntu-20.04, macos-12, macos-14]
os: [ubuntu-20.04, macos-14]
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 121
Expand Down Expand Up @@ -291,7 +291,7 @@ jobs:
vpm-site:
strategy:
matrix:
os: [ubuntu-20.04, macos-12, macos-14]
os: [ubuntu-20.04, macos-14]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/vpm_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
setup:
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-12]
os: [ubuntu-20.04, windows-2019, macos-14]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -54,8 +54,6 @@ jobs:
cc: gcc
- os: windows-2019
cc: msvc
- os: macos-12
cc: clang
- os: macos-14
cc: clang
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/install_wabt.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
platform := $if windows {
'windows'
} $else $if macos {
'macos-12'
'macos-14'
} $else $if linux {
'ubuntu'
} $else {
Expand Down
21 changes: 17 additions & 4 deletions cmd/tools/modules/testing/common.v
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,10 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
details := get_test_details(file)
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
for retry := 1; retry <= details.retry; retry++ {
ts.append_message(.info, ' [stats] retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...',
mtc)
if !details.hide_retries {
ts.append_message(.info, ' [stats] retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...',
mtc)
}
os.setenv('VTEST_RETRY', '${retry}', true)

ts.append_message(.cmd_begin, cmd, mtc)
Expand Down Expand Up @@ -679,8 +681,10 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
failure_output.writeln(trimmed_output)
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
for retry = 1; retry <= details.retry; retry++ {
ts.append_message(.info, ' retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...',
mtc)
if !details.hide_retries {
ts.append_message(.info, ' retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...',
mtc)
}
os.setenv('VTEST_RETRY', '${retry}', true)

ts.append_message(.cmd_begin, run_cmd, mtc)
Expand All @@ -702,6 +706,10 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
full_failure_output := failure_output.str().trim_space()
if details.flaky && !fail_flaky {
ts.append_message(.info, '>>> flaky failures so far:', mtc)
for line in full_failure_output.split_into_lines() {
ts.append_message(.info, '>>>>>> ${line}', mtc)
}
ts.append_message(.info, ' *FAILURE* of the known flaky test file ${relative_file} is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: ${details.retry} .\n comp_cmd: ${cmd}\n run_cmd: ${run_cmd}',
mtc)
unsafe {
Expand Down Expand Up @@ -862,6 +870,8 @@ pub struct TestDetails {
pub mut:
retry int
flaky bool // when flaky tests fail, the whole run is still considered successful, unless VTEST_FAIL_FLAKY is 1
//
hide_retries bool // when true, all retry tries are silent; used by `vlib/v/tests/retry_test.v`
}

pub fn get_test_details(file string) TestDetails {
Expand All @@ -874,6 +884,9 @@ pub fn get_test_details(file string) TestDetails {
if line.starts_with('// vtest flaky:') {
res.flaky = line.all_after(':').trim_space().bool()
}
if line.starts_with('// vtest hide_retries') {
res.hide_retries = true
}
}
return res
}
Expand Down
1 change: 1 addition & 0 deletions cmd/tools/vast/vast.v
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,7 @@ fn (t Tree) call_expr(node ast.CallExpr) &Node {
obj.add('is_keep_alive', t.bool_node(node.is_keep_alive))
obj.add_terse('is_noreturn', t.bool_node(node.is_noreturn))
obj.add_terse('is_ctor_new', t.bool_node(node.is_ctor_new))
obj.add_terse('is_return_used', t.bool_node(node.is_return_used))
obj.add('should_be_skipped', t.bool_node(node.should_be_skipped))
obj.add_terse('free_receiver', t.bool_node(node.free_receiver))
obj.add('scope', t.number_node(int(node.scope)))
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vcover/cover_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn test_simple() {
// Run both tests. The coverage should be combined and == 100%
r3 := os.execute('${os.quoted_path(vexe)} -coverage ${os.quoted_path(t3)} test cmd/tools/vcover/testdata/simple/')
assert r3.exit_code == 0, r3.str()
assert r3.output.trim_space().contains('Summary for all V _test.v files: 2 passed'), r3.str()
assert r3.output.trim_space().contains('Summary for all V _test.v files: '), r3.str()
assert os.exists(t3), t3
filter3 := os.execute('${os.quoted_path(vexe)} cover ${os.quoted_path(t3)} --filter simple/')
assert filter3.exit_code == 0, filter3.str()
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/vdoctor.v
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ fn (mut a App) collect_info() {
a.line('Git vroot status', a.git_info())
a.line('.git/config present', os.is_file('.git/config').str())
a.println('')

a.line('CC version', a.cmd(command: 'cc --version'))
a.line('emcc version', a.cmd(command: 'emcc --version'))
a.report_tcc_version('thirdparty/tcc')
}

Expand All @@ -134,7 +134,7 @@ struct CmdConfig {

fn (mut a App) cmd(c CmdConfig) string {
x := os.execute(c.command)
if x.exit_code < 0 {
if x.exit_code < 0 || x.exit_code == 127 {
return 'N/A'
}
if x.exit_code == 0 {
Expand Down
4 changes: 4 additions & 0 deletions examples/assets/v.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions examples/assets/v_16x16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion examples/veb/veb_assets/assets/v-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion examples/vweb/server_sent_events/assets/v-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion examples/vweb_fullstack/src/assets/v-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions vlib/bitfield/bitfield.v
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,32 @@ pub fn (instance BitField) rotate(offset int) BitField {
return output
}

// shift_left shift-left the bits by `count` positions.
pub fn (instance BitField) shift_left(count int) BitField {
size := instance.size
if count <= 0 {
return instance
} else if count >= size {
// return zeroes
return new(size)
}
zeroes := new(count)
return join(instance.slice(count, size), zeroes)
}

// shift_right shift-right the bits by `count` positions.
pub fn (instance BitField) shift_right(count int) BitField {
size := instance.size
if count <= 0 {
return instance
} else if count >= size {
// return zeroes
return new(size)
}
zeroes := new(count)
return join(zeroes, instance.slice(0, size - count))
}

// Internal functions
// clear_tail clears the extra bits that are not part of the bitfield, but yet are allocated
@[inline]
Expand Down
14 changes: 14 additions & 0 deletions vlib/bitfield/bitfield_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,17 @@ fn test_bf_printing() {
println(input)
assert true
}

fn test_bf_shift() {
str := '0001001101111111'
bf := bitfield.from_str(str)
bf_left := bf.shift_left(4)
assert bf_left.str() == '0011011111110000'
bf_right := bf.shift_right(4)
assert bf_right.str() == '0000000100110111'

bf_large_left := bf.shift_left(100)
bf_large_right := bf.shift_right(100)
assert bf_large_left.str() == '0000000000000000'
assert bf_large_right.str() == '0000000000000000'
}
20 changes: 20 additions & 0 deletions vlib/builtin/fixed_array_any_all_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,51 @@ fn test_any_all_of_ints() {

assert ia.any(it > 2)
assert ia.any(|x| x > 2)
assert [1, 2, 3]!.any(it > 2)
assert [1, 2, 3]!.any(|x| x > 2)

assert !ia.all(it > 1)
assert !ia.all(|x| x > 1)
assert ![1, 2, 3]!.all(it > 1)
assert ![1, 2, 3]!.all(|x| x > 1)

assert ia.any(it == 2)
assert ia.any(|x| x == 2)
assert [1, 2, 3]!.any(it == 2)
assert [1, 2, 3]!.any(|x| x == 2)

assert !ia.all(it == 3)
assert !ia.all(|x| x == 3)
assert ![1, 2, 3]!.all(it == 3)
assert ![1, 2, 3]!.all(|x| x == 3)
}

fn test_any_all_of_strings() {
sa := ['a', 'b', 'c']!

assert sa.any(it == 'b')
assert sa.any(|x| x == 'b')
assert ['a', 'b', 'c']!.any(it == 'b')
assert ['a', 'b', 'c']!.any(|x| x == 'b')

assert !sa.all(it == 'c')
assert !sa.all(|x| x == 'c')
assert !['a', 'b', 'c']!.all(it == 'c')
assert !['a', 'b', 'c']!.all(|x| x == 'c')
}

fn test_any_all_of_voidptrs() {
pa := [voidptr(123), voidptr(45), voidptr(99)]!

assert pa.any(it == voidptr(45))
assert pa.any(|x| x == voidptr(45))
assert [voidptr(123), voidptr(45), voidptr(99)]!.any(it == voidptr(45))
assert [voidptr(123), voidptr(45), voidptr(99)]!.any(|x| x == voidptr(45))

assert !pa.all(it == voidptr(123))
assert !pa.all(|x| x == voidptr(123))
assert ![voidptr(123), voidptr(45), voidptr(99)]!.all(it == voidptr(123))
assert ![voidptr(123), voidptr(45), voidptr(99)]!.all(|x| x == voidptr(123))
}

fn a() {}
Expand All @@ -47,7 +63,11 @@ fn test_any_all_of_fns() {

assert fa.any(it == b)
assert fa.any(|x| x == b)
assert [a, b, c]!.any(it == b)
assert [a, b, c]!.any(|x| x == b)

assert !fa.all(it == v)
assert !fa.all(|x| x == v)
assert ![a, b, c]!.all(it == v)
assert ![a, b, c]!.all(|x| x == v)
}
8 changes: 8 additions & 0 deletions vlib/builtin/fixed_array_contains_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@ fn test_contains_of_ints() {
mut ii := ia.contains(2)
dump(ii)
assert ii
assert [1, 2, 3]!.contains(2)

ii = ia.contains(5)
dump(ii)
assert !ii
assert ![1, 2, 3]!.contains(5)
}

fn test_contains_of_strings() {
sa := ['a', 'b', 'c']!
mut si := sa.contains('b')
dump(si)
assert si
assert ['a', 'b', 'c']!.contains('b')

si = sa.contains('v')
dump(si)
assert !si
assert !['a', 'b', 'c']!.contains('v')
}

fn test_contains_of_voidptrs() {
pa := [voidptr(123), voidptr(45), voidptr(99)]!
mut pi := pa.contains(voidptr(45))
dump(pi)
assert pi
assert [voidptr(123), voidptr(45), voidptr(99)]!.contains(voidptr(45))

pi = pa.contains(unsafe { nil })
dump(pi)
assert !pi
assert ![voidptr(123), voidptr(45), voidptr(99)]!.contains(unsafe { nil })
}

fn a() {}
Expand All @@ -44,8 +50,10 @@ fn test_contains_of_fns() {
mut fi := fa.contains(b)
dump(fi)
assert fi
assert [a, b, c]!.contains(b)

fi = fa.contains(v)
dump(fi)
assert !fi
assert ![a, b, c]!.contains(v)
}
Loading

0 comments on commit b75f10a

Please sign in to comment.