Skip to content

Commit

Permalink
tasks: add tests for PR #912
Browse files Browse the repository at this point in the history
The tests cover:

- If there are no tasks defined
- If there are tasks with long names
- If the minimum alignment is respected for very short names
  • Loading branch information
kraptor authored and dom96 committed Apr 26, 2021
1 parent 8e5cd62 commit 6d74bde
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/tasks/empty/tasks.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Package

version = "0.1.0"
author = "David Anes <kraptor>"
description = "A new awesome nimble package"
license = "MIT"
srcDir = "src"
bin = @["run"]


# Dependencies

requires "nim >= 0.19.0"
23 changes: 23 additions & 0 deletions tests/tasks/max/tasks.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Package

version = "0.1.0"
author = "David Anes <kraptor>"
description = "A new awesome nimble package"
license = "MIT"
srcDir = "src"
bin = @["run"]


# Dependencies

requires "nim >= 0.19.0"


task task1, "Description1":
echo "blah"

task very_long_task, "This is a task with a long name":
echo "blah"

task aaa, "A task with a small name":
echo "blah"
17 changes: 17 additions & 0 deletions tests/tasks/min/tasks.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Package

version = "0.1.0"
author = "David Anes <kraptor>"
description = "A new awesome nimble package"
license = "MIT"
srcDir = "src"
bin = @["run"]


# Dependencies

requires "nim >= 0.19.0"


task a, "Description for a":
echo "blah blah"
17 changes: 17 additions & 0 deletions tests/tasks/nodesc/tasks.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Package

version = "0.1.0"
author = "David Anes <kraptor>"
description = "A new awesome nimble package"
license = "MIT"
srcDir = "src"
bin = @["run"]


# Dependencies

requires "nim >= 0.19.0"


task nodesc, "":
echo "A task with no description"
26 changes: 26 additions & 0 deletions tests/tester.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1283,3 +1283,29 @@ suite "issues":
let lines = output.strip.processOutput()
check exitCode != QuitSuccess
check inLines(lines, "Nothing to build")

suite "nimble tasks":
test "can list tasks even with no tasks defined in nimble file":
cd "tasks/empty":
let (_, exitCode) = execNimble("tasks")
check exitCode == QuitSuccess

test "tasks with no descriptions are correctly displayed":
cd "tasks/nodesc":
let (output, exitCode) = execNimble("tasks")
check output.contains("nodesc")
check exitCode == QuitSuccess

test "task descriptions are correctly aligned to longer name":
cd "tasks/max":
let (output, exitCode) = execNimble("tasks")
check output.contains("task1 Description1")
check output.contains("very_long_task This is a task with a long name")
check output.contains("aaa A task with a small name")
check exitCode == QuitSuccess

test "task descriptions are correctly aligned to minimum (10 chars)":
cd "tasks/min":
let (output, exitCode) = execNimble("tasks")
check output.contains("a Description for a")
check exitCode == QuitSuccess

0 comments on commit 6d74bde

Please sign in to comment.