8000 Make testing with the multi-binary platform independent by syrmel · Pull Request #181 · vlang/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make testing with the multi-binary platform independent #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
echo "adding '${PWD}' to PATH"
echo "${PWD}" >> $GITHUB_PATH
- name: Download uutils/coreutils
uses: engineerd/configurator@v0.0.8
uses: engineerd/configurator@v0.0.10
with:
name: 'coreutils.exe'
url: 'https://github.com/uutils/coreutils/releases/download/0.0.17/coreutils-0.0.17-x86_64-pc-windows-msvc.zip'
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
shell: bash
run: |
# Run tests
cd coreutils && v test .
cd coreutils && USE_MULTI_BINARY_TO_TEST=coreutils v test .

ubuntu-fast-build:
runs-on: ubuntu-latest
Expand All @@ -74,7 +74,6 @@ jobs:
uses: actions/checkout@v2
with:
path: coreutils

- name: V doctor
run: v doctor
- name: Ensure everything is formatted
Expand All @@ -100,7 +99,6 @@ jobs:
uses: actions/checkout@v2
with:
path: coreutils

- name: Build all with -prod
run: cd coreutils && v run build.vsh -prod
- name: Run tests
Expand All @@ -120,10 +118,8 @@ jobs:
uses: actions/checkout@v2
with:
path: coreutils

- name: Build all
run: cd coreutils && v run build.vsh

- name: Native utils diagnostics (before GNU coreutils)
run: |
sleep --version
Expand All @@ -132,6 +128,5 @@ jobs:
uses: ShenTengTu/setup-gnu-coreutils-action@v1
- name: Test GNU coreutils uptime
run: uptime --version

- name: Run tests
run: cd coreutils && GNU_COREUTILS_INSTALLED=1 make test
1 change: 1 addition & 0 deletions common/testing/testing.v
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pub fn command_fails(cmd string) !os.Result {
}

const gnu_coreutils_installed = os.getenv('GNU_COREUTILS_INSTALLED').int() == 1
const use_multi_binary_to_test = os.getenv('USE_MULTI_BINARY_TO_TEST')

// same_results/2 executes the given commands, and ensures that
// their results are exactly the same, both for their exit codes,
Expand Down
34 changes: 9 additions & 25 deletions common/testing/testrig.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const small_diff_size = 64
pub struct TestRig {
pub:
util string
platform_util string
platform_util_call string
platform_util_path string
executable_under_test string
temp_dir string
Expand All @@ -30,18 +30,14 @@ pub fn (rig TestRig) call_for_test(args string) os.Result {
}

pub fn prepare_rig(config TestRigConfig) TestRig {
call_util := $if !windows {
config.util
} $else {
'coreutils'
}
call_util := if use_multi_binary_to_test != '' { use_multi_binary_to_test } else { config.util }

platform_util_path := os.find_abs_path_of_executable(call_util) or {
eprintln("ERROR: Local platform util '${call_util}' not found!")
exit(1)
}

platform_util := if call_util == 'coreutils' {
platform_util := if use_multi_binary_to_test != '' {
'${call_util} ${config.util}'
} else {
call_util
Expand All @@ -53,7 +49,7 @@ pub fn prepare_rig(config TestRigConfig) TestRig {
os.chdir(temp_dir) or { panic('Unable to set working directory: ${temp_dir}') }
rig := TestRig{
util: config.util
platform_util: platform_util
platform_util_call: platform_util
platform_util_path: platform_util_path
cmd: new_paired_command(platform_util, exec_under_test)
executable_under_test: exec_under_test
Expand All @@ -70,13 +66,9 @@ pub fn (rig TestRig) clean_up() {
}

pub fn (rig TestRig) assert_platform_util() {
platform_ver := $if !windows {
os.execute('${rig.platform_util_path} --version')
} $else {
os.execute('${rig.platform_util_path} ${rig.util} --version')
}
platform_ver := os.execute('${rig.platform_util_call} --version')
eprintln('Platform util version: [${platform_ver.output}]')
assert platform_ver.exit_code == 0
eprintln('Platform util version: ${platform_ver.output}')

if platform_ver.output.len > rig.util.len {
assert platform_ver.output[..rig.util.len] == rig.util
Expand All @@ -99,11 +91,7 @@ pub fn (rig TestRig) assert_platform_util() {
}

pub fn (rig TestRig) call_orig(args string) os.Result {
return $if !windows {
os.execute('${rig.platform_util_path} ${args}')
} $else {
os.execute('${rig.platform_util_path} ${rig.util} ${args}')
}
return os.execute('${rig.platform_util_call} ${args}')
}

pub fn (rig TestRig) call_new(args string) os.Result {
Expand All @@ -127,18 +115,14 @@ pub fn (rig TestRig) assert_same_results(args string) {

// If the name of the executable appears in the returned message, shorten it to the util
// name because the paths are different for GNU coreutil and v-coreutil
cmd1_output := $if !windows {
cmd1_res.output.replace(rig.platform_util_path, rig.util)
} $else {
cmd1_res.output.replace('${rig.platform_util_path} ${rig.util}', '${rig.util}')
}
cmd1_output := cmd1_res.output.replace(rig.platform_util_call, rig.util)
cmd2_output := cmd2_res.output.replace(rig.executable_under_test, rig.util)
mut noutput1 := normalise(cmd1_output)
mut noutput2 := normalise(cmd2_output)

$if trace_same_results ? {
eprintln('------------------------------------')
eprintln('>> same_results cmd1: "${rig.platform_util_path} ${args}"')
eprintln('>> same_results cmd1: "${rig.platform_util_call} ${args}"')
eprintln('>> same_results cmd2: "${rig.executable_under_test} ${args}"')
eprintln(' cmd1_res.exit_code: ${cmd1_res.exit_code}')
eprintln(' cmd2_res.exit_code: ${cmd2_res.exit_code}')
Expand Down
Binary file added coreutils-8.32-x64-win.zip
Binary file not shown.
Loading
0