Skip to content

Update test suite to run on macOS and Windows #7

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
37 changes: 24 additions & 13 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,33 @@ jobs:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

os:
- ubuntu-latest
- macos-latest
- windows-latest
vim:
- 'v9.0.2189'
- 'v8.2.4286'

steps:
- uses: actions/[email protected]
- name: Install dependencies
- uses: actions/checkout@v4
with:
submodules: true
- name: Install coverage dependencies
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev libelf-dev libdw-dev cmake vim kcov
sudo apt-get install -y libcurl4-openssl-dev libelf-dev libdw-dev cmake kcov
- uses: thinca/action-setup-vim@v1
with:
vim_version: ${{ matrix.vim }}
- name: Ensure vim installed
run: vim --version
- name: Smoke test of vims
run: echo "Hello" | ./vims ''
- name: Run tests
run: |
mkdir -p coverage
TEST_DIR=$(pwd)/test VIMS=./vims kcov coverage ./test/test.sh
- name: Upload coverage
run: bash <(curl -s https://codecov.io/bash) -s coverage


run: VIMS=$PWD/vims ./test/bats/bin/bats ./test/test.bats
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "test/bats"]
path = test/bats
url = https://github.com/bats-core/bats-core.git
[submodule "test/test_helper/bats-support"]
path = test/test_helper/bats-support
url = https://github.com/bats-core/bats-support.git
[submodule "test/test_helper/bats-assert"]
path = test/test_helper/bats-assert
url = https://github.com/bats-core/bats-assert.git
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vims

[![CI](https://github.com/MilesCranmer/vim-stream/actions/workflows/CI.yml/badge.svg)](https://github.com/MilesCranmer/vim-stream/actions/workflows/CI.yml) [![Codecov branch](https://img.shields.io/codecov/c/github/MilesCranmer/vim-stream/master.svg)](https://codecov.io/gh/MilesCranmer/vim-stream)
[![CI](https://github.com/MilesCranmer/vim-stream/actions/workflows/CI.yml/badge.svg)](https://github.com/MilesCranmer/vim-stream/actions/workflows/CI.yml)

![Demo](https://i.imgur.com/dntK3MP.gif)

Expand Down
1 change: 1 addition & 0 deletions test/bats
Submodule bats added at 3d3f63
80 changes: 80 additions & 0 deletions test/test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bats

setup() {
load "test_helper/bats-support/load"
load "test_helper/bats-assert/load"

DIR=$(dirname "${BATS_TEST_FILENAME}")
TEST_DIR=${TEST_DIR:-$DIR}
VIMS=${VIMS:-$DIR/../vims}
}

teardown() {
rm -f .tmp
}

@test "Identity" {
run cat $TEST_DIR/test_files/python.py | run $VIMS '' > .tmp
run diff -b .tmp $TEST_DIR/test_files/python.py
assert_output ""
}

@test "Move init to bottom" {
run cat $TEST_DIR/test_files/python.py | run $VIMS -e '^\s\+def __init__' 'V/^\\s\\+def\<enter>kdGp' | run cat > .tmp
run diff -b .tmp $TEST_DIR/test_files/python_init_at_bottom.py
assert_output ""
}

@test "Print last 4 lines" {
run cat $TEST_DIR/test_files/python.py | run $VIMS -n '$-3,$p' | run cat > .tmp
run diff -b .tmp $TEST_DIR/test_files/python_last_4_lines.py
assert_output ""
}

@test "Do one long 'simple' command" {
run cat $TEST_DIR/test_files/python.py | run $VIMS -s '/^class\<enter>O# This class is for Bifrost\<esc>Go\<enter># This file does not run!' | run cat > .tmp
run diff -b .tmp $TEST_DIR/test_files/python_with_extra_comments.py
assert_output ""
}

@test "Do one short 'simple' command" {
run cat $TEST_DIR/test_files/python.py | run $VIMS -s 'x' | run cat > .tmp
run diff -b .tmp $TEST_DIR/test_files/python_minus_one_char.py
assert_output ""
}

@test "Reverse a file with exe" {
run cat $TEST_DIR/test_files/python.py | run $VIMS -e '.*' ':m0\<enter>' | run cat > .tmp
run diff -b .tmp $TEST_DIR/test_files/python_reversed.py
assert_output ""
}

@test "Reverse a file in normal mode" {
run cat $TEST_DIR/test_files/python.py | run $VIMS '%g/.*/m0' | run cat > .tmp
run diff -b .tmp $TEST_DIR/test_files/python_reversed.py
assert_output ""
}

@test "Turn back off exe mode" {
run cat $TEST_DIR/test_files/numbers.txt | run $VIMS -e '^5$' 'dd' -t '%g/^3$/t$' | run cat > .tmp
run diff -b .tmp $TEST_DIR/test_files/numbers_5_gone_3_bottom.txt
assert_output ""
}

@test "Run multi-mode commands" {
run cat $TEST_DIR/test_files/numbers.txt | run $VIMS -e '^5$' 'dd' -s ':%g/^3$/t$\<enter>' | run cat > .tmp
run diff -b .tmp $TEST_DIR/test_files/numbers_5_gone_3_bottom.txt
assert_output ""
}

@test "Execute command on every line" {
run cat $TEST_DIR/test_files/numbers.txt | run $VIMS -l '10\<c-x>' > .tmp
run diff -b .tmp $TEST_DIR/test_files/numbers_all_decreased.txt
assert_output ""
}

@test "Delete all numbers not 1" {
run cat $TEST_DIR/test_files/numbers.txt | run $VIMS -r '^1$' 'dd' > .tmp
run diff -b .tmp $TEST_DIR/test_files/numbers_delete_all_not_1.txt
assert_output ""
}
91 changes: 0 additions & 91 deletions test/test.sh

This file was deleted.

1 change: 1 addition & 0 deletions test/test_helper/bats-assert
Submodule bats-assert added at e2d855
1 change: 1 addition & 0 deletions test/test_helper/bats-support
Submodule bats-support added at 9bf10e