-
Notifications
You must be signed in to change notification settings - Fork 249
/
submit_standalone.bats
executable file
·73 lines (61 loc) · 2.27 KB
/
submit_standalone.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bats
# These tests can be run without a working DOMjudge API endpoint.
load 'assert'
setup() {
export SUBMITBASEHOST="domjudge.example.org"
export SUBMITBASEURL="https://${SUBMITBASEHOST}/somejudge"
}
@test "version output" {
run ./submit --version
assert_success
assert_regex "^submit -- part of DOMjudge"
assert_line "Written by the DOMjudge developers"
}
@test "baseurl set in environment" {
run ./submit
assert_failure 1
assert_regex "$SUBMITBASEHOST.*/api(/.*)?/contests.*\[Errno -2\] Name or service not known"
}
@test "baseurl via parameter overrides environment" {
run ./submit --url https://domjudge.example.edu
assert_failure 1
assert_regex "domjudge.example.edu.*/api(/.*)?/contests.*\[Errno -2\] Name or service not known"
run ./submit -u https://domjudge3.example.edu
assert_failure 1
assert_regex "domjudge3.example.edu.*/api(/.*)?/contests.*\[Errno -2\] Name or service not known"
}
@test "baseurl can end in slash" {
run ./submit --url https://domjudge.example.edu/domjudge/
assert_failure 1
assert_regex "domjudge.example.edu.*/api(/.*)?/contests.*\[Errno -2\] Name or service not known"
}
@test "display basic usage information" {
run ./submit --help
assert_success
assert_line "usage: submit [--version] [-h] [-c CONTEST] [-p PROBLEM] [-l LANGUAGE] [-e ENTRY_POINT]"
assert_line " [-v [{DEBUG,INFO,WARNING,ERROR,CRITICAL}]] [-q] [-y] [-u URL]"
# The help printer does print this differently on versions of argparse for nargs=*.
assert_regex " (filename )?[filename ...]"
assert_line "Submit a solution for a problem."
}
@test "usage information displays API url" {
run ./submit --help
assert_success
assert_line "The (pre)configured URL is '$SUBMITBASEURL/'"
}
@test "netrc is mentioned in usage documentation" {
run ./submit --help
assert_success
assert_regex "~/\\.netrc"
}
@test "nonexistent option shows error" {
run ./submit --doesnotexist
assert_failure 2
# Do not count from the start, but take the last line.
assert_line "submit: error: unrecognized arguments: --doesnotexist"
}
@test "verbosity option defaults to INFO" {
run ./submit -v
assert_failure 1
assert_partial "set verbosity to INFO"
}