diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2021-09-05 13:38:27 -0500 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2021-09-05 13:38:27 -0500 |
| commit | 243c7db4b094fdb25c54d0017712a655da138eef (patch) | |
| tree | 50f9ef6b8f5982ef15eec252865b95b34f867eb7 | |
| parent | 4d99cb9eb30ffe235196a75b566e1b8b9a5e6d0d (diff) | |
Preserve original ordering
| -rw-r--r-- | fs.go | 1 | ||||
| -rw-r--r-- | runner.go | 3 | ||||
| -rw-r--r-- | testcase.go | 9 |
3 files changed, 13 insertions, 0 deletions
@@ -77,6 +77,7 @@ func collectUnits(root string, cfgs []AdapterConfig) []TestCase { for i := range tcs { tcs[i].Cname = Cname(root, tcs[i].Path) + tcs[i].readIdx = i } return tcs @@ -4,6 +4,7 @@ import ( "log" "os" "path" + "sort" ) type Runner struct { @@ -128,6 +129,8 @@ func (r Runner) Evaluate(tcs []TestCase) []TestResult { for range testSets { results = append(results, (<-c)...) } + + sort.Sort(ByReadIdx(results)) safeCd(r.dirs.Config()) diff --git a/testcase.go b/testcase.go index 19f1e58..d1db292 100644 --- a/testcase.go +++ b/testcase.go @@ -45,8 +45,17 @@ type TestCase struct { Cname string Config TestCaseConfig + + // Reorder according to original read order after concurrent operation + readIdx int } func (tc TestCase) AdapterConfig() InheritableConfig { return tc.Config.adapters_[*tc.Config.Adapter] } + +type ByReadIdx []TestResult + +func (a ByReadIdx) Len() int { return len(a) } +func (a ByReadIdx) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByReadIdx) Less(i, j int) bool { return a[i].Tc.readIdx < a[j].Tc.readIdx } |
