Skip to content

Commit 6d74bde

Browse files
kraptordom96
authored andcommitted
tasks: add tests for PR #912
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
1 parent 8e5cd62 commit 6d74bde

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

tests/tasks/empty/tasks.nimble

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Package
2+
3+
version = "0.1.0"
4+
author = "David Anes <kraptor>"
5+
description = "A new awesome nimble package"
6+
license = "MIT"
7+
srcDir = "src"
8+
bin = @["run"]
9+
10+
11+
# Dependencies
12+
13+
requires "nim >= 0.19.0"

tests/tasks/max/tasks.nimble

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Package
2+
3+
version = "0.1.0"
4+
author = "David Anes <kraptor>"
5+
description = "A new awesome nimble package"
6+
license = "MIT"
7+
srcDir = "src"
8+
bin = @["run"]
9+
10+
11+
# Dependencies
12+
13+
requires "nim >= 0.19.0"
14+
15+
16+
task task1, "Description1":
17+
echo "blah"
18+
19+
task very_long_task, "This is a task with a long name":
20+
echo "blah"
21+
22+
task aaa, "A task with a small name":
23+
echo "blah"

tests/tasks/min/tasks.nimble

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Package
2+
3+
version = "0.1.0"
4+
author = "David Anes <kraptor>"
5+
description = "A new awesome nimble package"
6+
license = "MIT"
7+
srcDir = "src"
8+
bin = @["run"]
9+
10+
11+
# Dependencies
12+
13+
requires "nim >= 0.19.0"
14+
15+
16+
task a, "Description for a":
17+
echo "blah blah"

tests/tasks/nodesc/tasks.nimble

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Package
2+
3+
version = "0.1.0"
4+
author = "David Anes <kraptor>"
5+
description = "A new awesome nimble package"
6+
license = "MIT"
7+
srcDir = "src"
8+
bin = @["run"]
9+
10+
11+
# Dependencies
12+
13+
requires "nim >= 0.19.0"
14+
15+
16+
task nodesc, "":
17+
echo "A task with no description"

tests/tester.nim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,3 +1283,29 @@ suite "issues":
12831283
let lines = output.strip.processOutput()
12841284
check exitCode != QuitSuccess
12851285
check inLines(lines, "Nothing to build")
1286+
1287+
suite "nimble tasks":
1288+
test "can list tasks even with no tasks defined in nimble file":
1289+
cd "tasks/empty":
1290+
let (_, exitCode) = execNimble("tasks")
1291+
check exitCode == QuitSuccess
1292+
1293+
test "tasks with no descriptions are correctly displayed":
1294+
cd "tasks/nodesc":
1295+
let (output, exitCode) = execNimble("tasks")
1296+
check output.contains("nodesc")
1297+
check exitCode == QuitSuccess
1298+
1299+
test "task descriptions are correctly aligned to longer name":
1300+
cd "tasks/max":
1301+
let (output, exitCode) = execNimble("tasks")
1302+
check output.contains("task1 Description1")
1303+
check output.contains("very_long_task This is a task with a long name")
1304+
check output.contains("aaa A task with a small name")
1305+
check exitCode == QuitSuccess
1306+
1307+
test "task descriptions are correctly aligned to minimum (10 chars)":
1308+
cd "tasks/min":
1309+
let (output, exitCode) = execNimble("tasks")
1310+
check output.contains("a Description for a")
1311+
check exitCode == QuitSuccess

0 commit comments

Comments
 (0)