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

Function testRunTest

lang/test_units_test.go:37–86  ·  view source on GitHub ↗
(t *testing.T, plans []testUTPs)

Source from the content-addressed store, hash-verified

35}
36
37func testRunTest(t *testing.T, plans []testUTPs) {
38 t.Helper()
39 count.Tests(t, len(plans)*2)
40
41 lang.InitEnv()
42 lang.ShellProcess.Config.Set("test", "auto-report", false, nil)
43
44 var pubPriv string
45
46 for i := range plans {
47 for j := 1; j < 3; j++ { // test public functions the private functions
48
49 fileRef := &ref.File{
50 Source: &ref.Source{
51 Filename: "foobar.mx",
52 Module: fmt.Sprintf("foobar/mod-%d-%d-%d", atomic.AddInt32(&uniq, 1), i, j),
53 DateTime: time.Now(),
54 },
55 }
56
57 if j == 1 {
58 lang.MxFunctions.Define(plans[i].Function, nil, []rune(plans[i].TestBlock), fileRef)
59 pubPriv = "public"
60 } else {
61 lang.PrivateFunctions.Define(plans[i].Function, nil, []rune(plans[i].TestBlock), fileRef)
62 plans[i].Function = fileRef.Source.Module + "/" + plans[i].Function
63 pubPriv = "private"
64 }
65
66 ut := new(lang.UnitTests)
67 ut.Add(plans[i].Function, &plans[i].UTP, fileRef)
68
69 if ut.Run(lang.ShellProcess, plans[i].Function) != plans[i].Passed {
70 if plans[i].Passed {
71 t.Errorf("Unit test %s %d failed", pubPriv, i)
72 b, err := json.MarshalIndent(lang.ShellProcess.Tests.Results.Dump(), "", " ")
73 if err != nil {
74 panic(err)
75 }
76
77 t.Logf(" Test report:\n%s", b)
78
79 } else {
80 t.Errorf("Unit test %s %d passed when expected to fail", pubPriv, i)
81 }
82 }
83 lang.ShellProcess.Tests.Results = new(lang.TestResults)
84 }
85 }
86}

Callers 7

TestRunTestVarScopingFunction · 0.85
TestRunTestParametersFunction · 0.85
TestRunTestDataTypesFunction · 0.85
TestRunTestStdinFunction · 0.85
TestRunTestExitNumberFunction · 0.85
TestRunTestRegexStdoutFunction · 0.85
TestRunTestRegexStderrFunction · 0.85

Calls 7

TestsFunction · 0.92
InitEnvFunction · 0.92
RunMethod · 0.80
SetMethod · 0.65
AddMethod · 0.65
DumpMethod · 0.65
DefineMethod · 0.45

Tested by

no test coverage detected