Commit Graph

95 Commits

Author SHA1 Message Date
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
MoreThanOneAnimal 495e579fdb parse_color function refactoring:
- simplified parsing logic,
- return nil for incorrect input,
- update tests and doc.
2016-11-28 20:22:39 -08:00
Uli Schlachter f71592a00a gears.matrix: Add create_rotate_at() (#1181)
We already have a variant of this function for transforming an actual
matrix. This adds the corresponding static factory.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-10-25 15:37:49 +02:00
Uli Schlachter 4bb02d1b53 wibox.hierarchy: Fix the matrix_to/from_device
Matrix operations are hard. Apparently I always keep confusing the order
that transformations are applied in the matrix resulting from a matrix
multiplication.

This commit fixes things in wibox.hierarchy that were wrong due to the
wrong order and changes a unit test so that it would now catch the
breakage (and makes sure that it does not happen again).

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-10-05 20:07:19 +02:00
Uli Schlachter 6956b9f6fa gears.object: Implement read-only properties
If a getter exists, but there is no setter, then this means that the property is
read-only.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-06-08 20:28:30 +02:00
Uli Schlachter 0ac9a67d07 spec: Use assert.is.equal
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-06-08 20:28:30 +02:00
Uli Schlachter 0857f6f1b5 Lua: Remove calls to add_signal()
The requirement to call add_signal() was added to catch typos. However, this
requirement became increasingly annoying with property::<name> signals and e.g.
gears.object allowing arbitrary properties to be changed.

All of this ended up in a single commit because tests/examples fails if I first
let add_signal() emit a deprecation warning.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-06-04 18:23:48 +02:00
Emmanuel Lepage Vallee 72c437a7c8 test: Fix widget cache 2016-05-30 23:12:39 -04:00
Emmanuel Lepage Vallee adb2f88383 objects: Add a table for private elements
Provide a standardized place for them rather than having each
widgets use their own conventions.
2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee 625a5dd407 tests: Test gears.object optional features 2016-05-18 01:24:59 -04:00
Uli Schlachter ae738db58a Fix awful.screen.getbycoord when no screens exist
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-05-15 14:43:25 +02:00
Uli Schlachter 13bce88fa0 Fix awful.screen.getbycoord() for top-left corner of a screen
The problem was that get_square_distance() made the screen one pixel larger to
the bottom/right than it really was. Thus, the (x+0,y+0)-pixel of a screen that
was below or to the right of some other screen had distance zero to both of
these screens.

This commit fixes the screen size computation and adds a small unit test for
getbycoord() and get_square_distance().

Reported by Elv13 here:
https://github.com/awesomeWM/awesome/pull/878#issuecomment-219272864

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-05-15 14:40:00 +02:00
Abdo Roig-Maranges 20bfcdc614 add test for us(altgr+intl) keyboard layout 2016-03-30 17:03:47 +02:00
Emmanuel Lepage Vallée 3be5343e83 Merge pull request #709 from psychon/implement-set-children-sanely
Implement set children sanely
2016-03-03 02:06:58 -05:00
Daniel Hahler f874b0ad2e Merge pull request #712 from psychon/protected_calls
Protected calls (gears.protected_call)
2016-02-28 22:16:13 +01:00
Uli Schlachter 01f11003d6 Add gears.protected_call
This library is a wrapper around pcall() / xpcall() that prints an error message
via gears.debug.print_error() in case of errors.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-28 12:07:02 +01:00
Uli Schlachter 923d0b8767 Add some unit tests for errors in :setup()
This adds a test that checks that :setup{ false } filters out the false, just
like it already filters out nil values. Then, this also adds a test that checks
that properties (:setup{ foo = false }) are not filtered out, because the first
version of me check did that accidentally.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-28 11:09:21 +01:00
Uli Schlachter 9900cdacd6 Add a unit test that I have laying around
Weird, no idea why this isn't in Git and where it should have been committed...

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-28 10:43:48 +01:00