Skip to content

Commit

Permalink
fix and run interpreter smoke tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Mar 21, 2023
1 parent c79f0db commit c9b6727
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: make -j8 build

- name: Test
run: make test
run: make ci

- name: Upload coverage report
uses: codecov/codecov-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

- name: Run Tests
run: |
make test
make ci
make lint-github-actions
- name: Config git
Expand Down
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ ifneq ($(linters),)
LINTERS = -E $(linters)
endif


.PHONY: test
test:
# test all packages
GO111MODULE=on go test -coverprofile=coverage.txt -covermode=atomic -parallel 8 -race -coverpkg $(COVERPKGS) ./...
# remove coverage of empty functions from report
sed -i -e 's/^.* 0 0$$//' coverage.txt

.PHONY: fast-test
fast-test:
# test all packages
GO111MODULE=on go test -parallel 8 ./...

.PHONY: build
build: build-tools ./runtime/cmd/parse/parse ./runtime/cmd/parse/parse.wasm ./runtime/cmd/check/check ./runtime/cmd/main/main

Expand All @@ -68,6 +55,20 @@ build-analysis:
build-batch-script:
(cd ./tools/batch-script && go build .)

.PHONY: ci
ci:
# test all packages
go test -coverprofile=coverage.txt -covermode=atomic -parallel 8 -race -coverpkg $(COVERPKGS) ./...
# run interpreter smoke tests. results from run above are reused, so no tests runs are duplicated
go test -count=5 ./runtime/tests/interpreter/... -runSmokeTests=true -validateAtree=false
# remove coverage of empty functions from report
sed -i -e 's/^.* 0 0$$//' coverage.txt

.PHONY: test
test:
# test all packages
go test -parallel 8 ./...

.PHONY: lint-github-actions
lint-github-actions: build-linter
tools/golangci-lint/golangci-lint run --out-format=colored-line-number,github-actions --timeout=5m -v ./...
Expand Down
1 change: 1 addition & 0 deletions runtime/interpreter/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func ConvertStoredValue(gauge common.MemoryGauge, value atree.Value) (Value, err
panic(errors.NewUnreachableError())
}
return newArrayValueFromConstructor(gauge, staticType, value.Count(), func() *atree.Array { return value }), nil

case *atree.OrderedMap:
typeInfo := value.Type()
switch typeInfo := typeInfo.(type) {
Expand Down
5 changes: 4 additions & 1 deletion runtime/interpreter/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -14955,7 +14955,10 @@ func (v *CompositeValue) Clone(interpreter *Interpreter) Value {
return nil, nil, nil
}

key := MustConvertStoredValue(interpreter, atreeKey).Clone(interpreter)
// The key is always interpreter.StringAtreeValue,
// an "atree-level string", not an interpreter.Value.
// Thus, we do not, and cannot, convert.
key := atreeKey
value := MustConvertStoredValue(interpreter, atreeValue).Clone(interpreter)

return key, value, nil
Expand Down
26 changes: 22 additions & 4 deletions runtime/tests/interpreter/values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var validateAtree = flag.Bool("validateAtree", true, "Enable atree validation")

func TestRandomMapOperations(t *testing.T) {
if !*runSmokeTests {
t.SkipNow()
t.Skip("smoke tests are disabled")
}

t.Parallel()
Expand Down Expand Up @@ -357,7 +357,25 @@ func TestRandomMapOperations(t *testing.T) {
t.Run("random insert & remove", func(t *testing.T) {
keyValues := make([][2]interpreter.Value, numberOfValues)
for i := 0; i < numberOfValues; i++ {
keyValues[i][0] = randomHashableValue(inter)
// Generate unique key
var key interpreter.Value
for {
key = randomHashableValue(inter)

var foundConflict bool
for j := 0; j < i; j++ {
existingKey := keyValues[j][0]
if key.(interpreter.EquatableValue).Equal(inter, interpreter.EmptyLocationRange, existingKey) {
foundConflict = true
break
}
}
if !foundConflict {
break
}
}

keyValues[i][0] = key
keyValues[i][1] = randomStorableValue(inter, 0)
}

Expand Down Expand Up @@ -497,7 +515,7 @@ func TestRandomMapOperations(t *testing.T) {

func TestRandomArrayOperations(t *testing.T) {
if !*runSmokeTests {
t.SkipNow()
t.Skip("smoke tests are disabled")
}

seed := time.Now().UnixNano()
Expand Down Expand Up @@ -861,7 +879,7 @@ func TestRandomArrayOperations(t *testing.T) {

func TestRandomCompositeValueOperations(t *testing.T) {
if !*runSmokeTests {
t.SkipNow()
t.Skip("smoke tests are disabled")
}

seed := time.Now().UnixNano()
Expand Down

0 comments on commit c9b6727

Please sign in to comment.