Skip to content

Commit f4305d3

Browse files
committed
Add saving unit module config
1 parent 3fa76ab commit f4305d3

File tree

5 files changed

+62
-33
lines changed

5 files changed

+62
-33
lines changed

src/main/Application.ms

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ _msunit_include_add(closure() {
3939
}
4040

4141
@app['registerTester'] = closure(@m, @self, string @id, array @moduleSetting) {
42+
if(array_index_exists(@self['testers'], @id)) {
43+
throw(Exception, "That module '@id' already registered")
44+
}
45+
4246
@options = _msunit_import_options()
4347
@self['testers'][@id] = _msunit_new_tester(@id, @moduleSetting, @options)
4448
}

src/main/api/registration/register.ms

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ proc _msunit_register_module(array @settings) {
4848
@moduleSetting['settingGroups'] = @root.'/'.@settings['setting_groups']
4949

5050
} else {
51-
@moduleSetting['settingGroups'] = "@root/settings.yml"
51+
@moduleSetting['settingGroups'] = "@root/groups.yml"
5252
}
5353

5454
if (array_index_exists(@settings, 'extension')) {
@@ -104,6 +104,12 @@ proc _msunit_register_module(array @settings) {
104104
@app = _msunit_get_application()
105105
_method('registerTester', @app, @id, @moduleSetting)
106106
}
107+
108+
@saveSettings = @moduleSetting[]
109+
@saveSettings['usedBy'] = 'msunit'
110+
array_remove(@saveSettings, 'outs')
111+
@pathToSetting = "@root/settings.yml"
112+
write_file(@pathToSetting, yml_encode(@saveSettings, true), 'OVERWRITE')
107113
}
108114

109115
void proc _msunit_set_options(array @options) {

src/main/core/Tester.ms

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ _msunit_include_add(closure() {
8686
@self['countTests'] = @countTests
8787
}
8888

89-
closure proc _msunit_build_task(@self, string @script, string @formatScript, array @testFilter, array @scriptResult, array @flags) {
89+
proc _msunit_build_task(@self, string @script, string @formatScript, array @testFilter, array @scriptResult, array @flags) {
9090
include(@script)
9191
@newProcs = get_procedures()
9292
@procs = _msunit_static_method('filter', 'ProcsFilter', @newProcs)

src/test/groups.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
assert_boolean_test:
2+
- all
3+
- assert
4+
assert_booleanish_test:
5+
- all
6+
- assert
7+
assert_capacity_test:
8+
- all
9+
- assert
10+
assert_empty_test:
11+
- all
12+
- assert
13+
assert_eq_test:
14+
- all
15+
- assert
16+
assert_null_test:
17+
- all
18+
- assert
19+
assert_out_test:
20+
- all
21+
- assert
22+
assert_throw_test:
23+
- all
24+
- assert
25+
assert_type_test:
26+
- all
27+
- assert
28+
before_after_test:
29+
- all
30+
other_test:
31+
- all

src/test/settings.yml

+19-31
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
1-
assert_boolean_test:
2-
- all
3-
- assert
4-
assert_booleanish_test:
5-
- all
6-
- assert
7-
assert_capacity_test:
8-
- all
9-
- assert
10-
assert_empty_test:
11-
- all
12-
- assert
13-
assert_eq_test:
14-
- all
15-
- assert
16-
assert_null_test:
17-
- all
18-
- assert
19-
assert_out_test:
20-
- all
21-
- assert
22-
assert_throw_test:
23-
- all
24-
- assert
25-
assert_type_test:
26-
- all
27-
- assert
28-
before_after_test:
29-
- all
30-
other_test:
31-
- all
1+
extension: C:\Users\Anatoliy\Dev\minecraft\1.15.2\plugins\CommandHelper\unit\src\test\extension\main.ms
2+
root: C:\Users\Anatoliy\Dev\minecraft\1.15.2\plugins\CommandHelper\unit\src\test
3+
rootData: C:\Users\Anatoliy\Dev\minecraft\1.15.2\plugins\CommandHelper\unit\src\test/data
4+
rootExtension: C:\Users\Anatoliy\Dev\minecraft\1.15.2\plugins\CommandHelper\unit\src\test\extension
5+
rootResources: C:\Users\Anatoliy\Dev\minecraft\1.15.2\plugins\CommandHelper\unit\src\test\resources
6+
rootTests: C:\Users\Anatoliy\Dev\minecraft\1.15.2\plugins\CommandHelper\unit\src\test\ms
7+
settingGroups: C:\Users\Anatoliy\Dev\minecraft\1.15.2\plugins\CommandHelper\unit\src\test\groups.yml
8+
testsSetting:
9+
assertTimeout: 5
10+
attentionTime: 1000000000
11+
procs:
12+
afterAll: ^_after_all.*
13+
afterEach: ^_after_each.*
14+
beforeAll: ^_before_all.*
15+
beforeEach: ^_before_each.*
16+
test: ^_test.*
17+
scriptPattern: .*_test\.ms$
18+
testTimeout: 10
19+
usedBy: msunit

0 commit comments

Comments
 (0)