Skip to content

Commit

Permalink
Make python tests not executables (elastic#5449) (elastic#5726)
Browse files Browse the repository at this point in the history
* Make python tests not executables

Turns out that if a `test_*.py` file is executable, nosetests
doesn't pick it up, so the tests are not executed on Linux/Mac.
This was the case with two files in Filebeat.

This adds a `make check` check to look for such files, so this
doesn't happen in the future.

(cherry picked from commit baa09e8)
  • Loading branch information
ruflin authored and exekias committed Nov 28, 2017
1 parent f26f797 commit b3cb125
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions filebeat/tests/system/test_prospector.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from filebeat import BaseTest
import os
import time
import unittest

from beat.beat import Proc

Expand Down Expand Up @@ -582,6 +583,7 @@ def test_skip_symlinks(self):
# Make sure there is only one entry, means it didn't follow the symlink
assert len(data) == 1

@unittest.skip("Flaky due to race. Opened https://github.com/elastic/beats/issues/5458")
def test_harvester_limit(self):
"""
Test if harvester_limit applies
Expand Down Expand Up @@ -714,8 +716,3 @@ def test_restart_recursive_glob(self):
name="output contains 'entry2'")

filebeat.check_kill_and_wait()


if __name__ == '__main__':
import unittest
unittest.main()
5 changes: 0 additions & 5 deletions filebeat/tests/system/test_registrar.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1384,8 +1384,3 @@ def test_registrar_files_with_prospector_level_processors(self):
"inode": stat.st_ino,
"device": stat.st_dev,
}, file_state_os)


if __name__ == '__main__':
import unittest
unittest.main()
2 changes: 2 additions & 0 deletions libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ BUILDID?=$(shell git rev-parse HEAD) ## @Building The build ID
VIRTUALENV_PARAMS?=
INTEGRATION_TESTS?=
FIND=. ${PYTHON_ENV}/bin/activate; find . -type f -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*"
PERM_EXEC=$(shell [ `uname -s` = "Darwin" ] && echo "+111" || echo "/a+x")

# Cross compiling targets
CGO?=true ## @building if true, Build with C Go support
Expand Down Expand Up @@ -104,6 +105,7 @@ check: python-env ## @build Checks project and source code if everything is acco
@go get $(GOIMPORTS_REPO)
@goimports -local ${GOIMPORTS_LOCAL_PREFIX} -l ${GOFILES_NOVENDOR} | (! grep . -q) || (echo "Code differs from goimports' style" && false)
@${FIND} -name *.py -exec autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false)
@${FIND} -wholename "*tests/system/test_*.py" -perm ${PERM_EXEC} -exec false {} + || (echo "Python test files shouldn't be executable, otherwise nose doesn't find them" && false)

.PHONY: fmt
fmt: python-env ## @build Runs `goimports -l -w` and `autopep8`on the project's source code, modifying any files that do not match its style.
Expand Down

0 comments on commit b3cb125

Please sign in to comment.