Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions packages/cli/tests/checkin/cyclic_dependencies/object.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,11 @@ tg.directory({
},
"module": "ts",
},
{
"kind": "file",
"contents": tg.blob("import * as foo from \"../foo\";"),
"dependencies": {
"../foo": {
"item": {
"index": 3,
"kind": "directory",
},
"options": {
"path": "../foo",
},
},
},
"module": "ts",
},
{
"kind": "directory",
"entries": {
"tangram.ts": {
"index": 1,
"index": 0,
"kind": "file",
},
},
Expand All @@ -46,13 +30,29 @@ tg.directory({
"kind": "directory",
"entries": {
"tangram.ts": {
"index": 0,
"index": 3,
"kind": "file",
},
},
},
{
"kind": "file",
"contents": tg.blob("import * as foo from \"../foo\";"),
"dependencies": {
"../foo": {
"item": {
"index": 1,
"kind": "directory",
},
"options": {
"path": "../foo",
},
},
},
"module": "ts",
},
],
}),
"index": 3,
"index": 1,
"kind": "directory",
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,13 @@ tg.directory({
"a": {
"graph": tg.graph({
"nodes": [
{
"kind": "directory",
"entries": {
"mod.tg.ts": {
"index": 1,
"kind": "file",
},
"tangram.ts": tg.file({
"contents": tg.blob(""),
"module": "ts",
}),
},
},
{
"kind": "file",
"contents": tg.blob("import * as a from \".\";"),
"dependencies": {
".": {
"item": {
"index": 0,
"index": 1,
"kind": "directory",
},
"options": {
Expand All @@ -31,9 +18,22 @@ tg.directory({
},
"module": "ts",
},
{
"kind": "directory",
"entries": {
"mod.tg.ts": {
"index": 0,
"kind": "file",
},
"tangram.ts": tg.file({
"contents": tg.blob(""),
"module": "ts",
}),
},
},
],
}),
"index": 0,
"index": 1,
"kind": "directory",
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,79 @@ tg.directory({
"nodes": [
{
"kind": "file",
"contents": tg.blob("import * as root from \"./tangram.ts\";"),
"contents": tg.blob("import * as foo from \"./foo.tg.ts\";"),
"dependencies": {
"./tangram.ts": {
"./foo.tg.ts": {
"item": {
"index": 1,
"kind": "file",
},
"options": {
"path": "tangram.ts",
"path": "foo.tg.ts",
},
},
},
"module": "ts",
},
{
"kind": "file",
"contents": tg.blob("import * as foo from \"./foo.tg.ts\";"),
"contents": tg.blob("import * as root from \"./tangram.ts\";"),
"dependencies": {
"./foo.tg.ts": {
"./tangram.ts": {
"item": {
"index": 0,
"kind": "file",
},
"options": {
"path": "foo.tg.ts",
"path": "tangram.ts",
},
},
},
"module": "ts",
},
],
}),
"index": 0,
"index": 1,
"kind": "file",
},
"tangram.ts": {
"graph": tg.graph({
"nodes": [
{
"kind": "file",
"contents": tg.blob("import * as root from \"./tangram.ts\";"),
"contents": tg.blob("import * as foo from \"./foo.tg.ts\";"),
"dependencies": {
"./tangram.ts": {
"./foo.tg.ts": {
"item": {
"index": 1,
"kind": "file",
},
"options": {
"path": "tangram.ts",
"path": "foo.tg.ts",
},
},
},
"module": "ts",
},
{
"kind": "file",
"contents": tg.blob("import * as foo from \"./foo.tg.ts\";"),
"contents": tg.blob("import * as root from \"./tangram.ts\";"),
"dependencies": {
"./foo.tg.ts": {
"./tangram.ts": {
"item": {
"index": 0,
"kind": "file",
},
"options": {
"path": "foo.tg.ts",
"path": "tangram.ts",
},
},
},
"module": "ts",
},
],
}),
"index": 1,
"index": 0,
"kind": "file",
},
})
35 changes: 35 additions & 0 deletions packages/cli/tests/checkin/repeated_checkin_with_cycles.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use ../../test.nu *

# Graph IDs must be identical regardless of entry point for cyclic imports.
#
# Two issues were identified:
#
# 1. External pointers (references to nodes outside the SCC) used ephemeral
# checkin graph indices, causing initial labels to differ by entry point.
# Fix: Resolve external pointers to object IDs in checkin_graph_node_initial_label.
#
# 2. Symmetric nodes (identical content and structure) produce identical WL labels.
# Fix: Use node paths as a tiebreaker in the sort.

let server = spawn

# Minimal 3-node star cycle: hub imports a and b, both a and b import hub.
# Nodes a and b have identical content and structure, producing identical WL labels.
let path = artifact {
a.tg.ts: 'import "./hub.tg.ts"; export default {};'
b.tg.ts: 'import "./hub.tg.ts"; export default {};'
hub.tg.ts: 'import "./a.tg.ts"; import "./b.tg.ts"; export default {};'
}

# Check in from hub first.
let hub_id = tg checkin ($path | path join 'hub.tg.ts')
let hub_obj = tg get $hub_id
let graph_from_hub = $hub_obj | parse --regex '"graph":(gph_[a-z0-9]+)' | get capture0 | first

# Check in from a.
let a_id = tg checkin ($path | path join 'a.tg.ts')
let a_obj = tg get $a_id
let graph_from_a = $a_obj | parse --regex '"graph":(gph_[a-z0-9]+)' | get capture0 | first

# The graph IDs should be identical regardless of entry point.
assert equal $graph_from_hub $graph_from_a
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"kind": "directory"
},
"options": {
"id": "dir_01p23dxncarc4nhkjpyy3tjbj7fmekx9fwty3gyzkt1as9t4vphg60",
"id": "dir_01bh601syfs5twxg1h0d8ar0avybnk2k91ggcqh7ptq01n78av2p90",
"tag": "a/1.1.0"
}
},
Expand All @@ -28,7 +28,7 @@
"kind": "directory"
},
"options": {
"id": "dir_01zp51yz7v92dwny4m5jvr3vkf33086z9vpjmhc0sk7rkt35pp8qg0",
"id": "dir_01jrxzb298n5pwk7q89bp3wv5q3yawmbwm1ynt2rgs8x3aedbfw0h0",
"tag": "b/1.0.0"
}
}
Expand Down Expand Up @@ -66,7 +66,7 @@
"kind": "directory"
},
"options": {
"id": "dir_01zp51yz7v92dwny4m5jvr3vkf33086z9vpjmhc0sk7rkt35pp8qg0",
"id": "dir_01jrxzb298n5pwk7q89bp3wv5q3yawmbwm1ynt2rgs8x3aedbfw0h0",
"tag": "b/1.0.0"
}
}
Expand Down Expand Up @@ -106,7 +106,7 @@
"kind": "directory"
},
"options": {
"id": "dir_01p23dxncarc4nhkjpyy3tjbj7fmekx9fwty3gyzkt1as9t4vphg60",
"id": "dir_01bh601syfs5twxg1h0d8ar0avybnk2k91ggcqh7ptq01n78av2p90",
"tag": "a/1.1.0"
}
}
Expand Down
Loading