(t *testing.T, tables []struct {
in string
out string
}, rc *RunContext)
| 269 | } |
| 270 | |
| 271 | func updateTestExpressionWorkflow(t *testing.T, tables []struct { |
| 272 | in string |
| 273 | out string |
| 274 | }, rc *RunContext) { |
| 275 | var envs string |
| 276 | keys := make([]string, 0, len(rc.Env)) |
| 277 | for k := range rc.Env { |
| 278 | keys = append(keys, k) |
| 279 | } |
| 280 | sort.Strings(keys) |
| 281 | for _, k := range keys { |
| 282 | envs += fmt.Sprintf(" %s: %s\n", k, rc.Env[k]) |
| 283 | } |
| 284 | |
| 285 | // editorconfig-checker-disable |
| 286 | workflow := fmt.Sprintf(` |
| 287 | name: "Test how expressions are handled on GitHub" |
| 288 | on: push |
| 289 | |
| 290 | env: |
| 291 | %s |
| 292 | |
| 293 | jobs: |
| 294 | test-espressions: |
| 295 | runs-on: ubuntu-latest |
| 296 | steps: |
| 297 | `, envs) |
| 298 | // editorconfig-checker-enable |
| 299 | for _, table := range tables { |
| 300 | expressionPattern := regexp.MustCompile(`\${{\s*(.+?)\s*}}`) |
| 301 | |
| 302 | expr := expressionPattern.ReplaceAllStringFunc(table.in, func(match string) string { |
| 303 | return fmt.Sprintf("€{{ %s }}", expressionPattern.ReplaceAllString(match, "$1")) |
| 304 | }) |
| 305 | name := fmt.Sprintf(`%s -> %s should be equal to %s`, expr, table.in, table.out) |
| 306 | echo := `run: echo "Done "` |
| 307 | workflow += fmt.Sprintf("\n - name: %s\n %s\n", name, echo) |
| 308 | } |
| 309 | |
| 310 | file, err := os.Create("../../.github/workflows/test-expressions.yml") |
| 311 | if err != nil { |
| 312 | t.Fatal(err) |
| 313 | } |
| 314 | |
| 315 | _, err = file.WriteString(workflow) |
| 316 | if err != nil { |
| 317 | t.Fatal(err) |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | func TestRewriteSubExpression(t *testing.T) { |
| 322 | table := []struct { |
no test coverage detected
searching dependent graphs…