This repository was archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSpecificationTestsuite.jl
114 lines (88 loc) · 3.3 KB
/
SpecificationTestsuite.jl
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
module SpecificationTestsuite
# Include general helpers
include("StringHelpers.jl")
export ALL_IMPLEMENTATIONS, ALL_FIXTURES, Config, execute
"List of all known implementations"
const ALL_IMPLEMENTATIONS = [
"substrate"
"kagome"
"gossamer"
]
module Config
import ..SpecificationTestsuite: ALL_IMPLEMENTATIONS
import ..StringHelpers: StringList, CmdString, CmdStringList, cmdjoin
"By default we log on a warning level."
verbose = false
"By default command are run on host."
docker = false
"Default containers to use in docker mode"
containers = Dict{String,String}(
"substrate" => "parity/polkadot:v0.8.5",
#"kagome" => "docker.pkg.github.com/w3f/polkadot-spec/kagome:xxxxxxx",
#"gossamer" => "docker.pkg.github.com/w3f/polkadot-spec/gossamer:xxxxxxx",
)
"By default all implementations are enabled."
implementations = ALL_IMPLEMENTATIONS
"By default no additional arguments are passed."
extra_args = ``
"Path of folder containing all fixtures."
function fixdir()::String
return "$(@__DIR__)/../fixtures"
end
"All subfolders of the fixture folder (i.e. all available fixtures)."
function fixsubdirs()::StringList
return first(walkdir(fixdir()))[2]
end
"By default all fixtures are enabled."
fixtures = fixsubdirs()
"Update verbose setting in config"
function set_verbose(enabled::Bool)
global verbose = enabled
end
"Update selected implementations in config"
function set_implementations(selected::StringList)
global implementations = selected
end
"Update selected fixtures in config"
function set_fixtures(selected::StringList)
global fixtures = selected
end
"Update additional arguments to pass to executable"
function set_extra_args(selected::CmdString)
global extra_args = selected
end
"Update additional arguments to pass to executable"
function set_extra_args(selected::CmdStringList)
set_extra_args(cmdjoin(selected))
end
"Update docker settings in config"
function set_docker(enabled::Bool)
global docker = enabled
end
"Retrieve docker image name to use in docker mode"
function get_container(implementation::String)::String
if !(implementation in ALL_IMPLEMENTATIONS)
@error "Unknown implementation '$implementation'"
end
return get(containers, implementation, "")
end
end
"List of all available fixtures"
const ALL_FIXTURES = Config.fixsubdirs()
# Include fixture helpers
include("AdapterFixture.jl")
include("HostFixture.jl")
"Run specific fixture for configure implementations"
function run_fixture(fixture::String)
if !(fixture in ALL_FIXTURES)
error("Unknown fixture: " * fixture)
end
@time include(Config.fixdir() * "/$fixture/include.jl")
end
"Run all configured fixtures"
function execute()
for fixture in Config.fixtures
run_fixture(fixture)
end
end
end