Skip to content

Commit

Permalink
TOOL-1907 fix flaky CI test case (#712)
Browse files Browse the repository at this point in the history
* fix flaky ci

* add removed testcase back
  • Loading branch information
trapacska authored Mar 27, 2020
1 parent 182f561 commit 1ca1a1f
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 75 deletions.
2 changes: 1 addition & 1 deletion bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ workflows:
- script:
title: Go test
inputs:
- content: go test $BITRISE_GO_PACKAGES
- content: go test -p 1 $BITRISE_GO_PACKAGES
- script:
title: Run integration tests
inputs:
Expand Down
149 changes: 75 additions & 74 deletions bitrise/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/bitrise-io/bitrise/configs"
envmanModels "github.com/bitrise-io/envman/models"
stepmanModels "github.com/bitrise-io/stepman/models"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -136,80 +137,80 @@ func TestTimeToFormattedSeconds(t *testing.T) {
}
}

// func TestRemoveConfigRedundantFieldsAndFillStepOutputs(t *testing.T) {
// // setup
// require.NoError(t, configs.InitPaths())

// configStr := `
// format_version: 1.3.0
// default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"

// workflows:
// remove_test:
// steps:
// - script:
// inputs:
// - content: |
// #!/bin/bash
// set -v
// exit 2
// opts:
// is_expand: true
// - timestamp:
// title: Generate timestamps
// `

// config, warnings, err := ConfigModelFromYAMLBytes([]byte(configStr))
// require.Equal(t, nil, err)
// require.Equal(t, 0, len(warnings))

// require.Equal(t, nil, RemoveConfigRedundantFieldsAndFillStepOutputs(&config))

// for workflowID, workflow := range config.Workflows {
// if workflowID == "remove_test" {
// for _, stepListItem := range workflow.Steps {
// for stepID, step := range stepListItem {
// if stepID == "script" {
// for _, input := range step.Inputs {
// key, _, err := input.GetKeyValuePair()
// require.Equal(t, nil, err)

// if key == "content" {
// opts, err := input.GetOptions()
// require.Equal(t, nil, err)

// // script content should keep is_expand: true, because it's different from spec default
// require.Equal(t, true, *opts.IsExpand)
// }
// }
// } else if stepID == "timestamp" {
// // timestamp title should be nil, because it's the same as spec value
// require.Equal(t, (*string)(nil), step.Title)

// for _, output := range step.Outputs {
// key, _, err := output.GetKeyValuePair()
// require.Equal(t, nil, err)

// if key == "UNIX_TIMESTAMP" {
// // timestamp outputs should filled with key-value & opts.Title
// opts, err := output.GetOptions()
// require.Equal(t, nil, err)

// require.Equal(t, "unix style", *opts.Title)
// require.Equal(t, (*bool)(nil), opts.IsExpand)
// require.Equal(t, (*bool)(nil), opts.IsDontChangeValue)
// require.Equal(t, (*bool)(nil), opts.IsRequired)
// }
// }
// }
// }
// }
// }
// }

// // timestamp outputs should filled with key-value & opts.Title

// }
func TestRemoveConfigRedundantFieldsAndFillStepOutputs(t *testing.T) {
// setup
require.NoError(t, configs.InitPaths())

configStr := `
format_version: 1.3.0
default_step_lib_source: "https://github.com/bitrise-io/bitrise-steplib.git"
workflows:
remove_test:
steps:
- script:
inputs:
- content: |
#!/bin/bash
set -v
exit 2
opts:
is_expand: true
- timestamp:
title: Generate timestamps
`

config, warnings, err := ConfigModelFromYAMLBytes([]byte(configStr))
require.Equal(t, nil, err)
require.Equal(t, 0, len(warnings))

require.Equal(t, nil, RemoveConfigRedundantFieldsAndFillStepOutputs(&config))

for workflowID, workflow := range config.Workflows {
if workflowID == "remove_test" {
for _, stepListItem := range workflow.Steps {
for stepID, step := range stepListItem {
if stepID == "script" {
for _, input := range step.Inputs {
key, _, err := input.GetKeyValuePair()
require.Equal(t, nil, err)

if key == "content" {
opts, err := input.GetOptions()
require.Equal(t, nil, err)

// script content should keep is_expand: true, because it's different from spec default
require.Equal(t, true, *opts.IsExpand)
}
}
} else if stepID == "timestamp" {
// timestamp title should be nil, because it's the same as spec value
require.Equal(t, (*string)(nil), step.Title)

for _, output := range step.Outputs {
key, _, err := output.GetKeyValuePair()
require.Equal(t, nil, err)

if key == "UNIX_TIMESTAMP" {
// timestamp outputs should filled with key-value & opts.Title
opts, err := output.GetOptions()
require.Equal(t, nil, err)

require.Equal(t, "unix style", *opts.Title)
require.Equal(t, (*bool)(nil), opts.IsExpand)
require.Equal(t, (*bool)(nil), opts.IsDontChangeValue)
require.Equal(t, (*bool)(nil), opts.IsRequired)
}
}
}
}
}
}
}

// timestamp outputs should filled with key-value & opts.Title

}

func TestSsStringSliceWithSameElements(t *testing.T) {
s1 := []string{}
Expand Down

0 comments on commit 1ca1a1f

Please sign in to comment.