Commit Graph

112 Commits

Author SHA1 Message Date
Uli Schlachter 4c53f9cbc6 spec/beautiful: Don't print noise (#2612)
This gets rid of the following output when running the unit tests:

2019-01-26 18:31:44 E: awesome: beautiful: error loading theme: got an empty table
2019-01-26 18:31:44 E: awesome: beautiful: error loading theme: got an empty table from: ./spec/beautiful/tests/Bad_1.lua
2019-01-26 18:31:44 E: awesome: beautiful: error loading theme: got a function from: ./spec/beautiful/tests/Bad_2.lua
2019-01-26 18:31:44 E: awesome: beautiful: error loading theme: got a number from: ./spec/beautiful/tests/Bad_3.lua
2019-01-26 18:31:44 E: awesome: beautiful: error loading theme: got a nil from: ./spec/beautiful/tests/Bad_4.lua
2019-01-26 18:31:44 E: awesome: Error during a protected call: ./spec/beautiful/tests/Bad_5.lua:2: attempt to index local 'var' (a nil value)
stack traceback:
	./spec/beautiful/tests/Bad_5.lua:2: in main chunk
	[C]: in function 'dofile'
	[C]: in function 'xpcall'
	lib/gears/protected_call.lua:36: in function <lib/gears/protected_call.lua:35>
	(...tail calls...)
	lib/beautiful/init.lua:224: in function 'init'
	spec/beautiful/init_spec.lua:56: in function <spec/beautiful/init_spec.lua:25>
	[C]: in function 'xpcall'
	/usr/share/lua/5.2/busted/core.lua:178: in function 'safe'
	/usr/share/lua/5.2/busted/init.lua:40: in function 'executor'
	...
	/usr/share/lua/5.2/busted/core.lua:312: in function 'execute'
	/usr/share/lua/5.2/busted/block.lua:155: in function 'execute'
	/usr/share/lua/5.2/busted/init.lua:7: in function 'executor'
	/usr/share/lua/5.2/busted/core.lua:312: in function </usr/share/lua/5.2/busted/core.lua:312>
	[C]: in function 'xpcall'
	/usr/share/lua/5.2/busted/core.lua:178: in function 'safe'
	/usr/share/lua/5.2/busted/core.lua:312: in function 'execute'
	/usr/share/lua/5.2/busted/execute.lua:58: in function 'execute'
	/usr/share/lua/5.2/busted/runner.lua:174: in function </usr/share/lua/5.2/busted/runner.lua:11>
	/usr/bin/busted:3: in main chunk
	[C]: in ?
2019-01-26 18:31:44 E: awesome: beautiful: error loading theme: got a nil from: ./spec/beautiful/tests/Bad_5.lua
2019-01-26 18:31:44 E: awesome: Error during a protected call: cannot open ./spec/beautiful/tests/NO_FILE: No such file or directory
stack traceback:
	[C]: in function 'dofile'
	[C]: in function 'xpcall'
	lib/gears/protected_call.lua:36: in function <lib/gears/protected_call.lua:35>
	(...tail calls...)
	lib/beautiful/init.lua:224: in function 'init'
	spec/beautiful/init_spec.lua:57: in function <spec/beautiful/init_spec.lua:25>
	[C]: in function 'xpcall'
	/usr/share/lua/5.2/busted/core.lua:178: in function 'safe'
	/usr/share/lua/5.2/busted/init.lua:40: in function 'executor'
	/usr/share/lua/5.2/busted/core.lua:312: in function </usr/share/lua/5.2/busted/core.lua:312>
	...
	/usr/share/lua/5.2/busted/core.lua:312: in function 'execute'
	/usr/share/lua/5.2/busted/block.lua:155: in function 'execute'
	/usr/share/lua/5.2/busted/init.lua:7: in function 'executor'
	/usr/share/lua/5.2/busted/core.lua:312: in function </usr/share/lua/5.2/busted/core.lua:312>
	[C]: in function 'xpcall'
	/usr/share/lua/5.2/busted/core.lua:178: in function 'safe'
	/usr/share/lua/5.2/busted/core.lua:312: in function 'execute'
	/usr/share/lua/5.2/busted/execute.lua:58: in function 'execute'
	/usr/share/lua/5.2/busted/runner.lua:174: in function </usr/share/lua/5.2/busted/runner.lua:11>
	/usr/bin/busted:3: in main chunk
	[C]: in ?
2019-01-26 18:31:44 E: awesome: beautiful: error loading theme: got a nil from: ./spec/beautiful/tests/NO_FILE

Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-01-26 12:54:31 -05:00
mergify[bot] e8bf75ef3c
Merge pull request #2592 from Sorky/patch-1
beautiful.init: Fix return values and improve doco. fixes: #2588
2019-01-25 15:41:15 +00:00
Sorky 366be2105a beautiful.init: Fix return values and improve doco. fixes: #2588 #2592
squashing updates from review by blueyed

Added busted tests

Fixed test files EOF

Remove Travis warning
2019-01-25 22:56:41 +11:00
Sorky f31fbe1220
menubar.utils.lua - remove "function is_format_supported" by making i… #2601
Removing an end of comment block that got left in by accident
2019-01-24 19:46:56 +11:00
Sorky 9927b7a88d squash 2019-01-21 21:37:45 +11:00
Daniel Hahler a732301306 tests: add basic tests for gears.string.split 2019-01-03 18:33:34 +01:00
Uli Schlachter 55639547a2 menubar.utils: Remove some (basically) dead code
This removes unused public functions from menubar.utils. This is not an
API break, because these functions were only added in commit
8d34201ec3, which is after v4.2. These new functions became
unused in commit e88f1e8735, not long after they were added.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-11-07 13:23:25 +01:00
Uli Schlachter c80bf6f46e wibox.layout.flex: Do not leave empty space behind
It is not possible to distribute 100px to three widgets equally. The
current version of wibox.layout.flex tries to do that anyway, by giving
each widget 33px and leaving one pixel outside of any widget. Thus, if
the widgets e.g. have a common background, this leads to a one pixel gap
in the background.

This patch changes the flex layout so that the extra pixel is assigned
to some widget instead. It does so by basically keeping a sum of
space_per_item for the widgets that was assigned so far. This sum is
rounded and when this leads to rounding, the corresponding child widget
gets an extra pixel.

More precisely, this tracks a pos as before. Widgets get their position
still assigned based on rounding pos. However, this now also remembers
this rounded position for the next iteration of the loop. This allows to
assign the size of widgets based on the difference between the current
and last rounded position.

(Possibly) fixes: https://github.com/awesomeWM/awesome/issues/2461
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-11-05 10:13:18 +01:00
Uli Schlachter 4744a744f0 gears.table.join: Ignore nil arguments (#2440)
When calling join with e.g. arguments (nil, {"a"}), then everything past
the nil was ignored, because the code internally used ipairs() to
iterate over the arguments and this stops at the first nil it
encounters.

Fix this by using select() to iterate over the arguments.

This also adds a unit test for this problem.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-10-16 10:17:45 -04:00
Emmanuel Lepage Vallee 980c47d775 tests: Mock capi.keygrabger
It will now run "static code" when the module is loaded, so need
to exist.
2018-07-29 10:45:40 -04:00
Aire-One c58e7d4fc8 add busted tests for signal "property::value" 2018-04-24 00:24:06 +02:00
Emmanuel Lepage Vallee 20db37f892 tests: Test the gears.sort module 2018-03-04 01:34:33 -05:00
get 5b882f3b2e Add unit tests for #2152
Adds unit tests for menubar.utils.lookup_icon_uncached.

Tests that icons and themes are found in the icon base directories, and
icons are resolved with the correct priority.

Creates directories and symlinks in spec/menubar/{home,usr} as test
data.
2018-01-15 23:47:20 +01:00
Uli Schlachter 8cc469322f ensure_pango_color: Support hex values with alpha
Reference: https://github.com/awesomeWM/awesome/pull/2129#discussion_r155397507
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-01-13 02:15:30 +01:00
Uli Schlachter 9b6cea5a13 Add unit tests for gears.color.ensure_pango_color
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-01-13 02:15:30 +01:00
Daniel Hahler 678ead2634 Add client.object.immobilized_{horizontal,vertical} (#2066)
ewmh.client_geometry_requests: ignore immobilized clients

Fixes https://github.com/awesomeWM/awesome/issues/1676.
Fixes https://github.com/awesomeWM/awesome/issues/2036.
2017-10-25 15:36:00 +02:00
Zach Peltzer 8d34201ec3 Unescape strings when parsing desktop entries (#2043)
* Unescape strings when parsing desktop entries

* Fix unused value warning in menubar/utils.lua

* Move menubar.utils.unescape() tests

* Clean up menubar.utils.unescape() function

* Fix warning for using "_" in a non-local context

* Do not ignore trailing whitespace in menubar.utils.parse_list()
2017-09-28 22:57:39 +02:00
Uli Schlachter e7bf8de081 Add tests for gears.string.startswith and endswith
Signed-off-by: Uli Schlachter <uli.schlachter@informatik.uni-oldenburg.de>
2017-08-21 09:05:37 +02:00
Florian Gamböck da987582a6 Check for correct ordering of completed items
The correct and consistent ordering is lexicographic. Not mtime, not
ctime, but pure lexicographic ordering.
2017-08-09 21:47:07 +02:00
Florian Gamböck 7ab57e1953 Check for not completing lone directories
Even if there is a sole directory with the name of the current
completion item, if it does not start with `./` then do not complete it!
2017-08-09 21:47:07 +02:00
Florian Gamböck 51e5381b67 Check for local directory completion
A directory in the current working directory (starting with `./`) should
be completed with a slash appended.
2017-08-09 21:47:07 +02:00
Florian Gamböck 79bdcc9ee1 Create some directories with ambiguous prefix
The chaotic order is intended. Some completion algorithms tend to sort
their results by modification time or something similar.

The "huge" number of directories is also intended. With more items the
chance is higher to hit a bug if no sorting took place.

Since Zsh just completes non-empty directories, some files have to be
created, too.
2017-08-09 21:47:07 +02:00
Florian Gamböck 8a13f1cb75 Check for command with directory in PWD
Even if there is a directory in the current working directory with the
same name as a command, the directory must not be completed.

So, if we want to complete "true" and there is a directory "true" in the
current working directory, the completion list has to be just {"true"},
not {"true", "true/"}, or anything else!
2017-08-09 21:44:55 +02:00
Florian Gamböck c296a0b91d Remove obsolete redefinition of popen
With the directory being changed via luafilesystem, there is no need to
redefine internal functions.
2017-08-09 21:44:55 +02:00
Florian Gamböck 8e2d844f60 Use luafilesystem to change directory
In some circumstances, if not every syscall was somehow redefined, the
directory was not changed correctly. With luafilesystem.chdir it is
assured that we are in the wanted directory afterwards.
2017-08-09 21:44:55 +02:00
Florian Gamböck c279dd32ce Make some directories in testing area 2017-08-09 21:44:55 +02:00
Florian Gamböck 13b3a18a75 Extend prefix for local file
Since we want some folders in the testing area, we need to be a bit more
explicit about the file completion.
2017-08-09 21:44:14 +02:00
Florian Gamböck 829e887806 Create and destroy temp PATH in tests
Since busted seems to spawn isolated child processes for every test
suite, the temporary PATH directories have to be created at the
beginning and destroyed at the end of a test suite.
2017-08-07 19:44:27 +02:00
Florian Gamböck a716009caa Set up isolated PATH directory for testing
We cannot possibly know what is in the PATH of a user. The completion
test cases however assume that there is nothing else in the PATH that
starts with `true` other than `true` itself.

These two methods create or respectively destroy a temporary PATH
directory especially for testing. We can put commands in there via
symlinks and verify the correct functionality of the complete commands.
The PATH environment variable is set and reset via GLib.
2017-08-07 19:44:27 +02:00
morethanoneanimal 5ddbfe1aa7 Tests for awful.prompt (#1916) 2017-07-14 21:32:21 +02:00
Daniel Hahler 9938fc8a05 spec/awful/completion_spec.lua: handle missing bash/zsh (#1889)
Fixes https://github.com/awesomeWM/awesome/issues/1882.

tests: spec/awful/completion_spec.lua: fix teardown for dirs

Fixes https://github.com/awesomeWM/awesome/issues/1888.
2017-07-03 21:28:13 +02:00
Daniel Hahler 4eddfacf51 lib/awful/completion.lua: handle missing SHELL environ var (#1897) 2017-07-03 19:26:10 +02:00
Daniel Hahler 0c97d1aa95 Add spec/awful/completion_spec.lua 2017-06-26 22:45:11 +02:00
Uli Schlachter c8dc563ce1 Add tests for get_children of containers
Fixes: https://github.com/awesomeWM/awesome/issues/1672
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-06-08 17:00:44 +02:00
Uli Schlachter 72c2f06c01 Add tests for get_children of layouts
Partially-fixes: https://github.com/awesomeWM/awesome/issues/1672
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-06-08 17:00:44 +02:00
Emmanuel Lepage Vallée 06a7818c09 tests: Test imagebox:set_image(nil) 2017-03-26 17:51:11 +02:00
Emmanuel Lepage Vallée 901df65eb0 Merge pull request #1629 from psychon/geometry_spec
Some small-ish work on gears.geometry
2017-03-12 15:45:00 -04:00
Emmanuel Lepage Vallée 957966d636 Merge pull request #1646 from psychon/systray_removal
Partly fix removal of systray from a wibox
2017-03-12 15:43:40 -04:00
Uli Schlachter da276dc8fb Add some tests for gears.geometry.rectangle.area_remove
This tests are not-really-good because they are overly specific. They
test for the current behaviour of the implementation, but I guess that a
valid implementation could also behave slightly different. However, for
now this will have to be enough.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-03-12 17:01:45 +01:00
Uli Schlachter 7dcbd62264 Add tests for gears.rectangle.get_in_direction
These tests are basically just copied from the tests for
awful.screen.get_next_in_direction.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-03-12 17:01:45 +01:00
Uli Schlachter 7511ae5075 Add some tests for gears.geometry
get_in_direction and area_remove are still missing.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-03-12 17:01:45 +01:00
Kevin Zander 2f105eac86 Move string functions out of awful.util into new gears.string (#1584)
Update deprecated awful.util string function calls to gears.string calls
2017-03-11 18:57:32 -05:00
Uli Schlachter 13dbc558fc wibox.hierarchy: Only count "really visible" widgets
Widgets with width or height zero cannot really be counted as visible,
so do not do so.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-03-11 18:44:56 +01:00
Uli Schlachter e1fe1de98f wibox.hierarchy: Add ability to count widgets
This adds new code so that we can count how often a specific widget is
visible inside of all widget hierarchies.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-03-11 13:55:57 +01:00
Kevin Zander c3461b535c gears: Move awful.util.table to gears.table (#1641)
* Move table functions out of awful.util into new gears.table

* travis: Use v9999 prefix for full requests

Make sure no newly deprecated functions are used

* Move all `awful.util.table.*` calls to `gears.table.*` calls
Move table test functions from awful/util_spec to new gears/table_spec
Change awful.util.subsets call to gears.math.subsets in awful/key.lua
2017-03-08 15:18:33 -05:00
Christoph Mertz 9cb60b8130 awful.screen: extract screen:get_next_in_direction() (#1597)
This extracts the code for finding the next screen
from focus_bydirection to a separate method on
the screen object.

The main reason was to use the finding code without
actually changing the screen focus but this should
incidentally make the code slightly easier to test
as well since both concerns can be tested in
isolation.

Signed-off-by: Christoph Mertz <chris@nimel.de>
2017-03-04 22:16:15 -05:00
Kevin Zander 3f6df8ddee Fix Luacheck 0.19.0 release Travis breaks 2017-03-03 16:41:12 -06:00
Kevin Zander 7f6763fb00 Add awesome.version to globals for tests. Will always show util.deprecate output 2017-03-02 18:15:59 -06:00
Uli Schlachter 844bd1eb05 Test that beautiful is not used too early (#1471)
For loading a theme, beautiful.init() has to be called. We do not handle
dynamic changes of the theme, so if the theme is changed after something
was already queried, this change will not apply. This also means that
before the theme is loaded, nothing useful can be returned. In fact,
code that tries to access the theme during require() will never get a
useful value from beautiful, but just nils.

To catch this, one Travis build is modified so that an error is raised
if the theme is accessed before beautiful.init() was called.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-02-15 00:46:27 +01:00
Daniel Hahler 6aee6c2053 ci: overhaul coverage processing
- Execute the tests without compiling, and don't mess with the source
   files when coverage is enabled.
   This ensures that the coverage report lines are correct.
   This disables the doc tests, as their results would be unused.
   Hack: it still expands macros on util.lua, because of
   `util.get_themes_dir()` and `util.get_awesome_icon_dir()`, which might
   be moved later.  Ref:
   https://github.com/awesomeWM/awesome/pull/1239#discussion_r93828178.
 - ensure that BUILD_APIDOC and DO_COVERAGE are not used together
 - awesomeConfig.cmake: add DO_COVERAGE as an option
 - Travis: only install codecov with DO_COVERAGE=codecov
 - Travis: do not use set -v; use set -x with DO_COVERAGE
 - do not use trailing slashes with dirs in tests/examples/CMakeLists.txt / .luacov
 - Use latest luacov (0.12.0-1) again
   This reverts parts of 4cc6a815.
   I think it is better to fix any failure that 4cc6a815 tried to work around.
 - Travis: simplify/fix require('luacov') for functionaltests
 - tests/examples/CMakeLists.txt: resolve ../.. in SOURCE_DIR
 - tests/examples/CMakeLists.txt: add DO_COVERAGE to env
 - Cleanup/simplify .luacov: work with SOURCE_DIRECTORY alone
 - tests/run.sh: pass through / set SOURCE_DIRECTORY when running awesome
 - tests/run.sh: resolve source_dir
 - use DO_COVERAGE from env only
2017-01-08 20:34:13 +01:00