github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/runtime/runtime_test.go (about)

     1  package cmdruntime_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	_ "github.com/lmorg/murex/builtins"
     7  	cmdruntime "github.com/lmorg/murex/builtins/core/runtime"
     8  	"github.com/lmorg/murex/lang"
     9  	"github.com/lmorg/murex/test"
    10  	"github.com/lmorg/murex/utils/json"
    11  )
    12  
    13  func marshalHelp(t *testing.T) string {
    14  	t.Helper()
    15  
    16  	b, err := json.Marshal(cmdruntime.Help(), false)
    17  	if err != nil {
    18  		t.Errorf("Cannot marshal help(): %s", err)
    19  	}
    20  	return string(b)
    21  }
    22  
    23  func TestRuntimeHelp(t *testing.T) {
    24  	tests := []test.MurexTest{
    25  		{
    26  			Block:  `runtime --help`,
    27  			Stdout: marshalHelp(t),
    28  		},
    29  	}
    30  
    31  	test.RunMurexTests(tests, t)
    32  }
    33  
    34  func TestRuntimeNoPanic(t *testing.T) {
    35  	lang.InitEnv()
    36  
    37  	tests := []test.MurexTest{
    38  		{
    39  			Block:  `runtime @{runtime --help}`,
    40  			Stdout: `^.+$`,
    41  		},
    42  	}
    43  
    44  	test.RunMurexTestsRx(tests, t)
    45  }