Skip to content

Commit

Permalink
internal/core/export: use matrix for SelfContained
Browse files Browse the repository at this point in the history
Tests that do not update due to errors have been excluded.

Issue #3060

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I5f56ae29e9dda5b4de9b6d651afdb2b161469f1d
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194184
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed May 3, 2024
1 parent 78e9e12 commit 3f52195
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/core/export/self_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"cuelang.org/go/cue/errors"
"cuelang.org/go/cue/format"
"cuelang.org/go/internal/core/export"
"cuelang.org/go/internal/cuetdtest"
"cuelang.org/go/internal/cuetxtar"
"cuelang.org/go/internal/diff"
"cuelang.org/go/internal/types"
Expand All @@ -36,11 +37,20 @@ func TestSelfContained(t *testing.T) {
test := cuetxtar.TxTarTest{
Name: "self",
Root: "./testdata/selfcontained",
}

r := cuecontext.New()
Matrix: cuetdtest.FullMatrix,

ToDo: map[string]string{
"self-v3/selfcontained/errors": "reordering",
"self-v3/selfcontained/import": `wa: reference "_hidden_567475F3" not found:`,
"self-v3/selfcontained/splitcomprehension": "reference not found",
"self-v3-noshare/selfcontained/splitcomprehension": "reference not found",
},
}

test.Run(t, func(t *cuetxtar.Test) {
r := t.Context()

a := t.Instances()

v := buildFile(t.T, r, a[0])
Expand Down
97 changes: 97 additions & 0 deletions internal/core/export/testdata/selfcontained/import.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,103 @@ wa: pkg.w.a
// Never expand builtin packages.
run: exec.Run
_hidden: int
-- out/self-v3-noshare/expand_imports --
import "tool/exec"

// Can be inlined.
v: V

// Do not simplify because of multiple usages of enclosing struct.
x: B.c
y: B

// Cannot simplify because of definition.
z: F.#x

// Two references to package, but since the second is a scalar, it can be
// hoisted and only one reference remains. So there is still no need for
// a helper.
// TODO: fix this to eliminate the helper.
w: W
wa: W.a

// Never expand builtin packages.
run: exec.Run
_hidden: int

//cue:path: "mod.test/a/pkg".v.v
let V = {
x: 3
y: x
}

//cue:path: "mod.test/a/pkg".a.b
let B = {
c: {
d: int
}
}

//cue:path: "mod.test/a/pkg".#Def.f
let F = {
#x: {
g: int
}
}

//cue:path: "mod.test/a/pkg".w
let W = {
a: _hidden_567475F3
_hidden_567475F3: {
a: b
}
b: 1
x: {
_hidden2_567475F3: _hidden_567475F3
y: _hidden2_567475F3
}
}
-- diff/-out/self-v3-noshare/expand_imports<==>+out/self/expand_imports --
diff old new
--- old
+++ new
@@ -1,10 +1,7 @@
import "tool/exec"

// Can be inlined.
-v: {
- x: 3
- y: x
-}
+v: V

// Do not simplify because of multiple usages of enclosing struct.
x: B.c
@@ -24,6 +21,12 @@
run: exec.Run
_hidden: int

+//cue:path: "mod.test/a/pkg".v.v
+let V = {
+ x: 3
+ y: x
+}
+
//cue:path: "mod.test/a/pkg".a.b
let B = {
c: {
@@ -42,7 +45,7 @@
let W = {
a: _hidden_567475F3
_hidden_567475F3: {
- a: 1
+ a: b
}
b: 1
x: {
-- diff/self/todo/p2 --
Investigate differences.
We assign p2, because the differences only appear with sharing off.
-- out/self/expand_imports --
import "tool/exec"

Expand Down
55 changes: 55 additions & 0 deletions internal/core/export/testdata/selfcontained/issue2247.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,61 @@ r: {out: k: l: string}.out
import "example.com/t"

f: t.p
-- out/self-v3-noshare/expand_imports --
f: P

//cue:path: "example.com/t".p
let P = {
c: [int]
d: [c][0]
// TODO: simplify these:
e: {
out: c
}.out
f: {
out: Q
}.out
g: {
out: Q
}.out
h: {
out: {
r: {
s: string
}
}
}.out
i: h.r
j: h.r.s
k: K
l: K.l
}

//cue:path: "example.com/t".q
let Q = {
x: [...int]
}

//cue:path: "example.com/t".r.k
let K = {
l: string
}
-- diff/-out/self-v3-noshare/expand_imports<==>+out/self/expand_imports --
diff old new
--- old
+++ new
@@ -1,4 +1,7 @@
-f: {
+f: P
+
+//cue:path: "example.com/t".p
+let P = {
c: [int]
d: [c][0]
// TODO: simplify these:
-- diff/self/todo/p2 --
Unnecessary let indirection.
We assign p2, because the differences only appear with sharing off.
-- out/self/expand_imports --
f: {
c: [int]
Expand Down

0 comments on commit 3f52195

Please sign in to comment.