(t *testing.T)
| 133 | } |
| 134 | |
| 135 | func TestRuntimeManager_Execute(t *testing.T) { |
| 136 | manager := NewRuntimeManager(nil) |
| 137 | |
| 138 | // 检查可用语言 |
| 139 | langs := manager.AvailableLanguages() |
| 140 | if len(langs) == 0 { |
| 141 | t.Skip("No runtimes available") |
| 142 | } |
| 143 | |
| 144 | ctx := context.Background() |
| 145 | |
| 146 | // 测试每个可用的运行时 |
| 147 | for _, lang := range langs { |
| 148 | t.Run(string(lang), func(t *testing.T) { |
| 149 | var code string |
| 150 | switch lang { |
| 151 | case LangPython: |
| 152 | code = "print('test')" |
| 153 | case LangNodeJS: |
| 154 | code = "console.log('test')" |
| 155 | case LangBash: |
| 156 | code = "echo test" |
| 157 | } |
| 158 | |
| 159 | result, err := manager.Execute(ctx, lang, code, nil) |
| 160 | if err != nil { |
| 161 | t.Fatalf("Execute failed: %v", err) |
| 162 | } |
| 163 | |
| 164 | if !result.Success { |
| 165 | t.Errorf("expected success, got error: %s", result.Error) |
| 166 | } |
| 167 | }) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | func TestRuntime_Timeout(t *testing.T) { |
| 172 | config := &RuntimeConfig{ |
nothing calls this directly
no test coverage detected