MCPcopy
hub / github.com/lmorg/murex / Run

Method Run

lang/test_units.go:66–114  ·  view source on GitHub ↗

Run all unit tests against a specific murex function

(p *Process, function string)

Source from the content-addressed store, hash-verified

64
65// Run all unit tests against a specific murex function
66func (ut *UnitTests) Run(p *Process, function string) bool {
67 ut.mutex.Lock()
68 utCopy := make([]*unitTest, len(ut.units))
69 copy(utCopy, ut.units)
70 ut.mutex.Unlock()
71
72 var (
73 passed = true
74 exists bool
75 )
76
77 autoreport, err := p.Config.Get("test", "auto-report", "bool")
78 if err != nil {
79 autoreport = true
80 }
81
82 for i := range utCopy {
83 if function == "*" || utCopy[i].Function == function {
84 passed = runTest(p.Tests.Results, utCopy[i].FileRef, utCopy[i].TestPlan, utCopy[i].Function) && passed
85 exists = true
86 }
87
88 if autoreport.(bool) {
89 p.Tests.WriteResults(p.Config, p.Stdout)
90 }
91 }
92
93 if !exists {
94 passed = false
95 p.Tests.Results.Add(&TestResult{
96 Exec: function,
97 TestName: testName,
98 Status: TestError,
99 Message: fmt.Sprintf("No unit tests exist for: `%s`", function),
100 })
101
102 if autoreport.(bool) {
103 p.Tests.WriteResults(p.Config, p.Stdout)
104 }
105 }
106
107 if passed {
108 p.ExitNum = 0
109 } else {
110 p.ExitNum = 1
111 }
112
113 return passed
114}
115
116// Dump the defined unit tests in a JSONable structure
117func (ut *UnitTests) Dump() any {

Callers 6

runTestsFunction · 0.80
TestRunTestNotATestFunction · 0.80
TestRunTestNotAFunctionFunction · 0.80
testRunTestFunction · 0.80
previewFileFunction · 0.80
testUnitRunFunction · 0.80

Calls 7

copyFunction · 0.85
runTestFunction · 0.85
WriteResultsMethod · 0.80
AddMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
GetMethod · 0.45

Tested by 3

TestRunTestNotATestFunction · 0.64
TestRunTestNotAFunctionFunction · 0.64
testRunTestFunction · 0.64