Commit Graph

121 Commits

Author SHA1 Message Date
Seth Barberee 9e3c418a03 add gears.table.cycle_value (#2942) 2019-12-12 22:10:10 -08:00
Emmanuel Lepage Vallee a8dcd3b2a2 tests: Add capi.client to the prompt unit tests.
It will be needed later.
2019-12-04 01:40:32 -05:00
Seth Barberee 5d499db3d0 add tests for find_keys and hasitem 2019-11-25 14:09:29 -06:00
Emmanuel Lepage Vallee 86d8ef3142 awful.button: Turn into an object. 2019-11-09 16:43:12 -05:00
Emmanuel Lepage Vallee 21ae9c1edb awful.key: Turn into an object. 2019-11-09 16:43:12 -05:00
Emmanuel Lepage Vallee 8ffafe4690 tests: Test gears.geometry.rectangle.are_equal. 2019-09-04 13:11:54 -04:00
Emmanuel Lepage Vallee 260078bf3c tests: Add capi.screen.connect_signal to the spec 2019-04-15 15:20:38 -04:00
Sorky 4831a46590 Add get_random_file_from_dir to gears.filesystem
Ref #2596
2019-02-16 13:58:24 -05:00
Sorky 3f26624160 Aligning 'regex' with other PR / Minor readability improvements
https://github.com/awesomeWM/awesome/issues/2596

Re-matched regex used elsewhere & updated test cases for "." in filename

Allowed for alternative extensions to be found even if specified

Reverted the change of behaviour but adjusted code for readability

Small readability change

Avoided delay searches that would never work

Untabify

Reverted possible [unlikely/undesired] behaviour changes

Untabify
2019-02-09 19:21:46 +11:00
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