Rename directory "tests" to "test" (#2094)

If you use a ./test/local directory, you need to create it again:
$ make clean bats-build bats-fixture
This commit is contained in:
mmetc 2023-03-03 15:54:49 +01:00 committed by GitHub
parent 85ab9c68a2
commit a19748ae35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
223 changed files with 42 additions and 42 deletions

View file

@ -67,7 +67,7 @@ jobs:
run: make bats-test-hub
- name: "Collect hub coverage"
run: ./tests/bin/collect-hub-coverage >> $GITHUB_ENV
run: ./test/bin/collect-hub-coverage >> $GITHUB_ENV
- name: "Create Parsers badge"
uses: schneegans/dynamic-badges-action@v1.6.0

View file

@ -90,10 +90,10 @@ jobs:
# In case you need to inspect the database status after the failure of a given test
#
# - name: "Run specified tests"
# run: ./tests/run-tests tests/bats/<filename>.bats -f "<test name>"
# run: ./test/run-tests test/bats/<filename>.bats -f "<test name>"
- name: Show database dump
run: ./tests/instance-db dump /dev/fd/1
run: ./test/instance-db dump /dev/fd/1
env:
DB_BACKEND: mysql
MYSQL_HOST: 127.0.0.1
@ -107,7 +107,7 @@ jobs:
if: ${{ always() }}
- name: "Show crowdsec logs"
run: for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
run: for file in $(find ./test/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
if: ${{ always() }}
- name: "Show database logs"

View file

@ -110,7 +110,7 @@ jobs:
if: ${{ always() }}
- name: "Show crowdsec logs"
run: for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
run: for file in $(find ./test/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
if: ${{ always() }}
- name: "Show database logs"

View file

@ -69,12 +69,12 @@ jobs:
# In case you need to inspect the database status after the failure of a given test
#
# - name: "Run specified tests"
# run: ./tests/run-tests tests/bats/<filename>.bats -f "<test name>"
# run: ./test/run-tests test/bats/<filename>.bats -f "<test name>"
- name: "Show database dump"
run: |
./tests/instance-crowdsec stop
sqlite3 ./tests/local/var/lib/crowdsec/data/crowdsec.db '.dump'
./test/instance-crowdsec stop
sqlite3 ./test/local/var/lib/crowdsec/data/crowdsec.db '.dump'
if: ${{ always() }}
- name: "Show stack traces"
@ -82,17 +82,17 @@ jobs:
if: ${{ always() }}
- name: "Show crowdsec logs"
run: for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
run: for file in $(find ./test/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
if: ${{ always() }}
- name: Upload crowdsec coverage to codecov
uses: codecov/codecov-action@v3
with:
files: ./tests/local/var/lib/coverage/coverage-crowdsec.out
files: ./test/local/var/lib/coverage/coverage-crowdsec.out
flags: func-crowdsec
- name: Upload cscli coverage to codecov
uses: codecov/codecov-action@v3
with:
files: ./tests/local/var/lib/coverage/coverage-cscli.out
files: ./test/local/var/lib/coverage/coverage-cscli.out
flags: func-cscli

10
.gitmodules vendored
View file

@ -1,16 +1,16 @@
[submodule "tests/lib/bats-core"]
path = tests/lib/bats-core
path = test/lib/bats-core
url = https://github.com/crowdsecurity/bats-core.git
branch = v1.7.0
[submodule "tests/lib/bats-file"]
path = tests/lib/bats-file
path = test/lib/bats-file
url = https://github.com/crowdsecurity/bats-file.git
[submodule "tests/lib/bats-assert"]
path = tests/lib/bats-assert
path = test/lib/bats-assert
url = https://github.com/crowdsecurity/bats-assert.git
[submodule "tests/lib/bats-support"]
path = tests/lib/bats-support
path = test/lib/bats-support
url = https://github.com/crowdsecurity/bats-support.git
[submodule "tests/lib/bats-mock"]
path = tests/lib/bats-mock
path = test/lib/bats-mock
url = https://github.com/crowdsecurity/bats-mock.git

View file

@ -159,11 +159,11 @@ test: goversion
.PHONY: localstack
localstack:
docker-compose -f tests/localstack/docker-compose.yml up
docker-compose -f test/localstack/docker-compose.yml up
.PHONY: localstack-stop
localstack-stop:
docker-compose -f tests/localstack/docker-compose.yml down
docker-compose -f test/localstack/docker-compose.yml down
package-common:
@echo "Building Release to dir $(RELDIR)"
@ -215,11 +215,11 @@ windows_installer: build
chocolatey: windows_installer
@.\make_chocolatey.ps1 -version $(BUILD_VERSION)
# Include tests/bats.mk only if it exists
# Include test/bats.mk only if it exists
# to allow building without a test/ directory
# (i.e. inside docker)
ifeq (,$(wildcard tests/bats.mk))
ifeq (,$(wildcard test/bats.mk))
bats-clean:
else
include tests/bats.mk
include test/bats.mk
endif

View file

View file

@ -77,10 +77,10 @@ To repeat test runs without rebuilding crowdsec, use `make bats-test`.
## Debugging tests
See `./tests/run-tests --help` to run/debug specific tests.
See `./test/run-tests --help` to run/debug specific tests.
Example: `./tests/run-tests tests/bats/02_nolapi.bats -f "cscli config backup"` (the string is a regexp).
You need to provide a path for a test file or directory (even if it's the full 'tests/bats') to use the `-f` option.
Example: `./test/run-tests test/bats/02_nolapi.bats -f "cscli config backup"` (the string is a regexp).
You need to provide a path for a test file or directory (even if it's the full 'test/bats') to use the `-f` option.
# How does it work?
@ -218,7 +218,7 @@ This doesn't mean you can't do that, just that you're on your own if the is an e
For the purpose of functional tests, crowdsec and its companions (cscli, plugin
notifiers, bouncers) are installed in a local environment, which means tests
should not install or touch anything outside a `./tests/local` directory. This
should not install or touch anything outside a `./test/local` directory. This
includes binaries, configuration files, databases, data downloaded from
internet, logs... The use of `/tmp` is tolerated, but BATS also provides [three
useful
@ -401,8 +401,8 @@ A mysql-client package is required as well.
## troubleshooting
- CAPI is disabled, why?
Most tests don't need it. Helper scripts are provided in `tests/enable-capi`
and `tests/disable-capi` for interactive use, and two library functions
Most tests don't need it. Helper scripts are provided in `test/enable-capi`
and `test/disable-capi` for interactive use, and two library functions
`config_enable_capi` and `config_disable_capi` to call inside the tests.
You still need to call `cscli capi register` after enabling it.

View file

@ -15,10 +15,10 @@
name: crowdsecurity.testing.extract_sources_from_zip
when: sources_zip | length > 0
- name: "Create crowdsec tests/local dir"
- name: "Create crowdsec test/local dir"
become: false
ansible.builtin.file:
path: "{{ ansible_env.HOME }}/crowdsec/tests/local"
path: "{{ ansible_env.HOME }}/crowdsec/test/local"
state: directory
mode: 0o755

View file

@ -19,7 +19,7 @@
ansible.builtin.command:
cmd: "{{ make_cmd }} bats-build bats-fixture"
chdir: "{{ ansible_env.HOME }}/crowdsec"
creates: "{{ ansible_env.HOME }}/crowdsec/tests/local-init/init-config-data.tar"
creates: "{{ ansible_env.HOME }}/crowdsec/test/local-init/init-config-data.tar"
environment:
DB_BACKEND: "{{ lookup('ansible.builtin.env', 'DB_BACKEND') }}"
# daemonize -> /usr/bin or /usr/local/sbin
@ -29,7 +29,7 @@
rescue:
- name: "Read crowdsec.log"
ansible.builtin.slurp:
path: "{{ ansible_env.HOME }}/crowdsec/tests/local/var/log/crowdsec.log"
path: "{{ ansible_env.HOME }}/crowdsec/test/local/var/log/crowdsec.log"
register: crowdsec_log
- name: "Show crowdsec.log"
ansible.builtin.fail:
@ -43,7 +43,7 @@
ansible.builtin.command:
cmd: "{{ make_cmd }} bats-environment bats-check-requirements bats-fixture"
chdir: "{{ ansible_env.HOME }}/crowdsec"
creates: "{{ ansible_env.HOME }}/crowdsec/tests/local-init/init-config-data.tar"
creates: "{{ ansible_env.HOME }}/crowdsec/test/local-init/init-config-data.tar"
environment:
PACKAGE_TESTING: "{{ package_testing }}"
DB_BACKEND: "{{ lookup('ansible.builtin.env', 'DB_BACKEND') }}"
@ -66,7 +66,7 @@
block:
- name: "Look for .environment.sh"
ansible.builtin.slurp:
src: "{{ ansible_env.HOME }}/crowdsec/tests/.environment.sh"
src: "{{ ansible_env.HOME }}/crowdsec/test/.environment.sh"
changed_when: true
register: envfile
- name: "Show .environment.sh"

View file

@ -31,7 +31,7 @@
block:
- name: "Look for .environment.sh"
ansible.builtin.slurp:
src: "{{ ansible_env.HOME }}/crowdsec/tests/.environment.sh"
src: "{{ ansible_env.HOME }}/crowdsec/test/.environment.sh"
changed_when: true
register: envfile
- name: "Show .environment.sh"
@ -41,7 +41,7 @@
- name: "Search for test scripts"
become: false
ansible.builtin.find:
paths: "{{ ansible_env.HOME }}/crowdsec/tests/bats"
paths: "{{ ansible_env.HOME }}/crowdsec/test/bats"
pattern: "*.bats"
register: testfiles
@ -50,7 +50,7 @@
block:
- name: "Run test scripts"
ansible.builtin.command:
cmd: tests/run-tests {{ item.path }}
cmd: test/run-tests {{ item.path }}
chdir: "{{ ansible_env.HOME }}/crowdsec"
with_items: "{{ testfiles.files | sort(attribute='path') }}"
loop_control:
@ -66,7 +66,7 @@
rescue:
- name: "Read crowdsec.log"
ansible.builtin.slurp:
path: "{{ ansible_env.HOME }}/crowdsec/tests/local/var/log/crowdsec.log"
path: "{{ ansible_env.HOME }}/crowdsec/test/local/var/log/crowdsec.log"
register: crowdsec_log
- name: "Show crowdsec.log"
ansible.builtin.fail:
@ -79,7 +79,7 @@
block:
- name: "Run test scripts"
ansible.builtin.command:
cmd: tests/run-tests {{ item.path }}
cmd: test/run-tests {{ item.path }}
chdir: "{{ ansible_env.HOME }}/crowdsec"
with_items: "{{ testfiles.files | sort(attribute='path') }}"
loop_control:

View file

@ -12,4 +12,4 @@
become: true
ansible.builtin.command:
chdir: "/home/{{ ansible_user }}"
cmd: "./crowdsec/tests/run-tests crowdsec/tests/bats-detect"
cmd: "./crowdsec/test/run-tests crowdsec/test/bats-detect"

View file

@ -1,5 +1,5 @@
# vim: set ft=yaml.ansible:
---
golang_version: "1.19.1"
golang_version: "1.20.1"
golang_install_dir: "/opt/go/{{ golang_version }}"

Some files were not shown because too many files have changed in this diff Show more