ci: run `v vet` over cmd/tools and cmd/v too
parent
9322e91d1b
commit
d67e177733
|
@ -25,6 +25,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
./v vet vlib/sqlite
|
./v vet vlib/sqlite
|
||||||
./v vet vlib/v
|
./v vet vlib/v
|
||||||
|
./v vet cmd/v
|
||||||
|
./v vet cmd/tools
|
||||||
- name: v fmt -verify
|
- name: v fmt -verify
|
||||||
run: |
|
run: |
|
||||||
./v fmt -verify vlib/builtin/array.v
|
./v fmt -verify vlib/builtin/array.v
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
|
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
|
||||||
// Use of this source code is governed by an MIT license
|
// Use of this source code is governed by an MIT license
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -23,18 +22,17 @@ fn main() {
|
||||||
mut commit_hash := exec('git rev-parse HEAD')
|
mut commit_hash := exec('git rev-parse HEAD')
|
||||||
commit_hash = commit_hash[..8]
|
commit_hash = commit_hash[..8]
|
||||||
if os.exists('last_commit.txt') {
|
if os.exists('last_commit.txt') {
|
||||||
last_commit := os.read_file('last_commit.txt')?
|
last_commit := os.read_file('last_commit.txt') ?
|
||||||
if last_commit.trim_space() == commit_hash.trim_space() {
|
if last_commit.trim_space() == commit_hash.trim_space() {
|
||||||
println('No new commits to benchmark. Commit $commit_hash has already been processed.')
|
println('No new commits to benchmark. Commit $commit_hash has already been processed.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
commit_hash = last_commit.trim_space()
|
commit_hash = last_commit.trim_space()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !os.exists('table.html') {
|
if !os.exists('table.html') {
|
||||||
os.create('table.html')?
|
os.create('table.html') ?
|
||||||
}
|
}
|
||||||
mut table := os.read_file('table.html')?
|
mut table := os.read_file('table.html') ?
|
||||||
/*
|
/*
|
||||||
// Do nothing if it's already been processed.
|
// Do nothing if it's already been processed.
|
||||||
if table.contains(commit_hash) {
|
if table.contains(commit_hash) {
|
||||||
|
@ -67,14 +65,13 @@ fn main() {
|
||||||
diff2 := measure('$vdir/vprod -cc clang -o v2 $vdir/cmd/v', 'v2')
|
diff2 := measure('$vdir/vprod -cc clang -o v2 $vdir/cmd/v', 'v2')
|
||||||
diff3 := measure('$vdir/vprod -x64 $vdir/cmd/tools/1mil.v', 'x64 1mil')
|
diff3 := measure('$vdir/vprod -x64 $vdir/cmd/tools/1mil.v', 'x64 1mil')
|
||||||
diff4 := measure('$vdir/vprod -cc clang $vdir/examples/hello_world.v', 'hello.v')
|
diff4 := measure('$vdir/vprod -cc clang $vdir/examples/hello_world.v', 'hello.v')
|
||||||
//println('Building V took ${diff}ms')
|
// println('Building V took ${diff}ms')
|
||||||
commit_date := exec('git log -n1 --pretty="format:%at" $commit')
|
commit_date := exec('git log -n1 --pretty="format:%at" $commit')
|
||||||
date := time.unix(commit_date.int())
|
date := time.unix(commit_date.int())
|
||||||
mut out := os.create('table.html')?
|
mut out := os.create('table.html') ?
|
||||||
// Place the new row on top
|
// Place the new row on top
|
||||||
table =
|
table = '<tr>
|
||||||
'<tr>
|
<td>$date.format()</td>
|
||||||
<td>${date.format()}</td>
|
|
||||||
<td><a target=_blank href="https://github.com/vlang/v/commit/$commit">$commit</a></td>
|
<td><a target=_blank href="https://github.com/vlang/v/commit/$commit">$commit</a></td>
|
||||||
<td>$message</td>
|
<td>$message</td>
|
||||||
<td>${diff1}ms</td>
|
<td>${diff1}ms</td>
|
||||||
|
@ -86,28 +83,30 @@ fn main() {
|
||||||
out.writeln(table)
|
out.writeln(table)
|
||||||
out.close()
|
out.close()
|
||||||
// Regenerate index.html
|
// Regenerate index.html
|
||||||
header := os.read_file('header.html')?
|
header := os.read_file('header.html') ?
|
||||||
footer := os.read_file('footer.html')?
|
footer := os.read_file('footer.html') ?
|
||||||
mut res := os.create('index.html')?
|
mut res := os.create('index.html') ?
|
||||||
res.writeln(header)
|
res.writeln(header)
|
||||||
res.writeln(table)
|
res.writeln(table)
|
||||||
res.writeln(footer)
|
res.writeln(footer)
|
||||||
res.close()
|
res.close()
|
||||||
}
|
}
|
||||||
exec('git checkout master')
|
exec('git checkout master')
|
||||||
os.write_file('last_commit.txt', commits[commits.len-1])?
|
os.write_file('last_commit.txt', commits[commits.len - 1]) ?
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec(s string) string {
|
fn exec(s string) string {
|
||||||
e := os.exec(s) or { panic(err) }
|
e := os.exec(s) or {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
return e.output.trim_right('\r\n')
|
return e.output.trim_right('\r\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns milliseconds
|
// returns milliseconds
|
||||||
fn measure(cmd, description string) int {
|
fn measure(cmd string, description string) int {
|
||||||
println(' Measuring $description')
|
println(' Measuring $description')
|
||||||
println(' Warming up...')
|
println(' Warming up...')
|
||||||
for _ in 0..3 {
|
for _ in 0 .. 3 {
|
||||||
exec(cmd)
|
exec(cmd)
|
||||||
}
|
}
|
||||||
println(' Building...')
|
println(' Building...')
|
||||||
|
|
|
@ -6,25 +6,25 @@ import vgit
|
||||||
const (
|
const (
|
||||||
tool_version = '0.0.3'
|
tool_version = '0.0.3'
|
||||||
tool_description = ' Checkout an old V and compile it as it was on specific commit.
|
tool_description = ' Checkout an old V and compile it as it was on specific commit.
|
||||||
This tool is useful, when you want to discover when something broke.
|
| This tool is useful, when you want to discover when something broke.
|
||||||
It is also useful, when you just want to experiment with an older historic V.
|
| It is also useful, when you just want to experiment with an older historic V.
|
||||||
|
|
|
||||||
The VCOMMIT argument can be a git commitish like HEAD or master and so on.
|
| The VCOMMIT argument can be a git commitish like HEAD or master and so on.
|
||||||
When oldv is used with git bisect, you probably want to give HEAD. For example:
|
| When oldv is used with git bisect, you probably want to give HEAD. For example:
|
||||||
git bisect start
|
| git bisect start
|
||||||
git bisect bad
|
| git bisect bad
|
||||||
git checkout known_good_commit
|
| git checkout known_good_commit
|
||||||
git bisect good
|
| git bisect good
|
||||||
## Now git will automatically checkout a middle commit between the bad and the good
|
| ## Now git will automatically checkout a middle commit between the bad and the good
|
||||||
cmd/tools/oldv HEAD --command="run commands in oldv folder, to verify if the commit is good or bad"
|
| cmd/tools/oldv HEAD --command="run commands in oldv folder, to verify if the commit is good or bad"
|
||||||
## See what the result is, and either do: ...
|
| ## See what the result is, and either do: ...
|
||||||
git bisect good
|
| git bisect good
|
||||||
## ... or do:
|
| ## ... or do:
|
||||||
git bisect bad
|
| git bisect bad
|
||||||
## Now you just repeat the above steps, each time running oldv with the same command, then mark the result as good or bad,
|
| ## Now you just repeat the above steps, each time running oldv with the same command, then mark the result as good or bad,
|
||||||
## until you find the commit, where the problem first occurred.
|
| ## until you find the commit, where the problem first occurred.
|
||||||
## When you finish, do not forget to do:
|
| ## When you finish, do not forget to do:
|
||||||
git bisect reset'
|
| git bisect reset'.strip_margin()
|
||||||
)
|
)
|
||||||
|
|
||||||
struct Context {
|
struct Context {
|
||||||
|
|
|
@ -6,9 +6,9 @@ import vgit
|
||||||
const (
|
const (
|
||||||
tool_version = '0.0.5'
|
tool_version = '0.0.5'
|
||||||
tool_description = " Compares V executable size and performance,
|
tool_description = " Compares V executable size and performance,
|
||||||
between 2 commits from V\'s local git history.
|
| between 2 commits from V\'s local git history.
|
||||||
When only one commit is given, it is compared to master.
|
| When only one commit is given, it is compared to master.
|
||||||
"
|
| ".strip_margin()
|
||||||
)
|
)
|
||||||
|
|
||||||
struct Context {
|
struct Context {
|
||||||
|
|
|
@ -87,12 +87,12 @@ fn (r &Repl) current_source_code(should_add_temp_lines bool) string {
|
||||||
fn repl_help() {
|
fn repl_help() {
|
||||||
println(util.full_v_version(false))
|
println(util.full_v_version(false))
|
||||||
println('
|
println('
|
||||||
help Displays this information.
|
|help Displays this information.
|
||||||
list Show the program so far.
|
|list Show the program so far.
|
||||||
reset Clears the accumulated program, so you can start a fresh.
|
|reset Clears the accumulated program, so you can start a fresh.
|
||||||
Ctrl-C, Ctrl-D, exit Exits the REPL.
|
|Ctrl-C, Ctrl-D, exit Exits the REPL.
|
||||||
clear Clears the screen.
|
|clear Clears the screen.
|
||||||
')
|
'.strip_margin())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_repl(workdir string, vrepl_prefix string) {
|
fn run_repl(workdir string, vrepl_prefix string) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import os
|
||||||
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
// Defines actions to execute
|
// Defines actions to execute
|
||||||
enum Action {
|
enum Action {
|
||||||
eof
|
eof
|
||||||
|
@ -134,7 +133,7 @@ pub fn (mut r Readline) read_line_utf8(prompt string) ?ustring {
|
||||||
|
|
||||||
// Returns the string from the utf8 ustring
|
// Returns the string from the utf8 ustring
|
||||||
pub fn (mut r Readline) read_line(prompt string) ?string {
|
pub fn (mut r Readline) read_line(prompt string) ?string {
|
||||||
s := r.read_line_utf8(prompt)?
|
s := r.read_line_utf8(prompt) ?
|
||||||
return s.s
|
return s.s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ pub fn (mut r Readline) read_line(prompt string) ?string {
|
||||||
// Returns utf8 based ustring
|
// Returns utf8 based ustring
|
||||||
pub fn read_line_utf8(prompt string) ?ustring {
|
pub fn read_line_utf8(prompt string) ?ustring {
|
||||||
mut r := Readline{}
|
mut r := Readline{}
|
||||||
s := r.read_line_utf8(prompt)?
|
s := r.read_line_utf8(prompt) ?
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +149,7 @@ pub fn read_line_utf8(prompt string) ?ustring {
|
||||||
// Return string from utf8 ustring
|
// Return string from utf8 ustring
|
||||||
pub fn read_line(prompt string) ?string {
|
pub fn read_line(prompt string) ?string {
|
||||||
mut r := Readline{}
|
mut r := Readline{}
|
||||||
s := r.read_line(prompt)?
|
s := r.read_line(prompt) ?
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,8 +180,7 @@ fn (r Readline) analyse(c int) Action {
|
||||||
Action.insert_character
|
Action.insert_character
|
||||||
} else {
|
} else {
|
||||||
Action.nothing
|
Action.nothing
|
||||||
}
|
} }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +284,7 @@ fn get_screen_columns() int {
|
||||||
return cols
|
return cols
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shift_cursor(xpos, yoffset int) {
|
fn shift_cursor(xpos int, yoffset int) {
|
||||||
if yoffset != 0 {
|
if yoffset != 0 {
|
||||||
if yoffset > 0 {
|
if yoffset > 0 {
|
||||||
term.cursor_down(yoffset)
|
term.cursor_down(yoffset)
|
||||||
|
@ -295,10 +293,10 @@ fn shift_cursor(xpos, yoffset int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Absolute X position
|
// Absolute X position
|
||||||
print('\x1b[${xpos+1}G')
|
print('\x1b[${xpos + 1}G')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_screen_position(x_in, y_in, screen_columns, char_count int, inp []int) []int {
|
fn calculate_screen_position(x_in int, y_in int, screen_columns int, char_count int, inp []int) []int {
|
||||||
mut out := inp
|
mut out := inp
|
||||||
mut x := x_in
|
mut x := x_in
|
||||||
mut y := y_in
|
mut y := y_in
|
||||||
|
@ -451,7 +449,10 @@ fn (mut r Readline) switch_overwrite() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut r Readline) clear_screen() {
|
fn (mut r Readline) clear_screen() {
|
||||||
term.set_cursor_position(x:1, y:1)
|
term.set_cursor_position({
|
||||||
|
x: 1
|
||||||
|
y: 1
|
||||||
|
})
|
||||||
term.erase_clear()
|
term.erase_clear()
|
||||||
r.refresh_line()
|
r.refresh_line()
|
||||||
}
|
}
|
||||||
|
@ -481,7 +482,6 @@ fn (mut r Readline) history_next() {
|
||||||
|
|
||||||
fn (mut r Readline) suspend() {
|
fn (mut r Readline) suspend() {
|
||||||
is_standalone := os.getenv('VCHILD') != 'true'
|
is_standalone := os.getenv('VCHILD') != 'true'
|
||||||
|
|
||||||
r.disable_raw_mode()
|
r.disable_raw_mode()
|
||||||
if !is_standalone {
|
if !is_standalone {
|
||||||
// We have to SIGSTOP the parent v process
|
// We have to SIGSTOP the parent v process
|
||||||
|
|
Loading…
Reference in New Issue