github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/cmd/gno/run_test.go (about)

     1  package main
     2  
     3  import "testing"
     4  
     5  func TestRunApp(t *testing.T) {
     6  	tc := []testMainCase{
     7  		{
     8  			args:        []string{"run"},
     9  			errShouldBe: "flag: help requested",
    10  		},
    11  		{
    12  			args:                []string{"run", "../../tests/integ/run_main/main.gno"},
    13  			stdoutShouldContain: "hello world!",
    14  		},
    15  		{
    16  			args:                []string{"run", "../../tests/integ/run_main/"},
    17  			stdoutShouldContain: "hello world!",
    18  		},
    19  		{
    20  			args:             []string{"run", "../../tests/integ/does_not_exist"},
    21  			errShouldContain: "no such file or directory",
    22  		},
    23  		{
    24  			args:                []string{"run", "../../tests/integ/run_namedpkg/main.gno"},
    25  			stdoutShouldContain: "hello, other world!",
    26  		},
    27  		{
    28  			args:                 []string{"run", "../../tests/integ/run_package"},
    29  			recoverShouldContain: "name main not declared",
    30  		},
    31  		{
    32  			args:                []string{"run", "-expr", "Hello()", "../../tests/integ/run_package"},
    33  			stdoutShouldContain: "called Hello",
    34  		},
    35  		{
    36  			args:                []string{"run", "-expr", "World()", "../../tests/integ/run_package"},
    37  			stdoutShouldContain: "called World",
    38  		},
    39  		{
    40  			args:                []string{"run", "-expr", "otherFile()", "../../tests/integ/run_package"},
    41  			stdoutShouldContain: "hello from package2.gno",
    42  		},
    43  		{
    44  			args: []string{
    45  				"run", "-expr", "otherFile()",
    46  				"../../tests/integ/run_package/package.gno",
    47  			},
    48  			recoverShouldContain: "name otherFile not declared",
    49  		},
    50  		{
    51  			args: []string{
    52  				"run", "-expr", "otherFile()",
    53  				"../../tests/integ/run_package/package.gno",
    54  				"../../tests/integ/run_package/package2.gno",
    55  			},
    56  			stdoutShouldContain: "hello from package2.gno",
    57  		},
    58  		{
    59  			args:                []string{"run", "-expr", "WithArg(1)", "../../tests/integ/run_package"},
    60  			stdoutShouldContain: "one",
    61  		},
    62  		{
    63  			args:                []string{"run", "-expr", "WithArg(-255)", "../../tests/integ/run_package"},
    64  			stdoutShouldContain: "out of range!",
    65  		},
    66  		{
    67  			args:                 []string{"run", "../../tests/integ/undefined_variable_test/undefined_variables_test.gno"},
    68  			recoverShouldContain: "--- preprocess stack ---", // should contain preprocess debug stack trace
    69  		},
    70  		{
    71  			args:                []string{"run", "-debug", "../../tests/integ/debugger/sample.gno"},
    72  			stdoutShouldContain: "Welcome to the Gnovm debugger",
    73  		},
    74  		{
    75  			args:             []string{"run", "-debug-addr", "invalidhost:17538", "../../tests/integ/debugger/sample.gno"},
    76  			errShouldContain: "listen tcp: lookup invalidhost",
    77  		},
    78  		// TODO: a test file
    79  		// TODO: args
    80  		// TODO: nativeLibs VS stdlibs
    81  		// TODO: with gas meter
    82  		// TODO: verbose
    83  		// TODO: logging
    84  	}
    85  	testMainCaseRun(t, tc)
    86  }