Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output selection tests #15447

Merged
merged 2 commits into from
Sep 23, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"language": "Solidity",
"sources": {
"": {"content": "contract D {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"*": {"content": "contract D {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"C": {"content": "contract D {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"}
},
"settings": {
"outputSelection": {
"": {"D": ["userdoc"]}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"contracts": {
"": {
"D": {
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
}
}
},
"sources": {
"": {
"id": 0
},
"*": {
"id": 1
},
"C": {
"id": 2
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"language": "Solidity",
"sources": {
"": {"content": "contract D {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"*": {"content": "contract D {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"C": {"content": "contract D {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"}
},
"settings": {
"outputSelection": {
"*": {"D": ["userdoc"]}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"contracts": {
"": {
"D": {
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
}
},
"*": {
"D": {
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
}
},
"C": {
"D": {
"userdoc": {
"kind": "user",
"methods": {},
"version": 1
}
}
}
},
"sources": {
"": {
"id": 0
},
"*": {
"id": 1
},
"C": {
"id": 2
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"language": "Solidity",
"sources": {
"*": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"C": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"D": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"}
},
"settings": {
"outputSelection": {
// Outputs from duplicate keys are not combined. Last value wins.
"*": {
"*": ["userdoc"], // Ignored
"*": ["devdoc"] // Ignored
},
"C": {
"*": ["storageLayout"], // Ignored
"*": ["transientStorageLayout"] // Ignored
},
"C": {
"A": ["evm.bytecode.linkReferences"], // Ignored
"A": ["evm.bytecode.object"]
},
"*": {
"A": ["evm.deployedBytecode.immutableReferences"], // Ignored
"A": ["abi"]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"contracts": {
"*": {
"A": {
"abi": []
}
},
"C": {
"A": {
"abi": [],
"evm": {
"bytecode": {
"object": "<BYTECODE REMOVED>"
}
}
}
},
"D": {
"A": {
"abi": []
}
}
},
"sources": {
"*": {
"id": 0
},
"C": {
"id": 1
},
"D": {
"id": 2
}
}
}
9 changes: 9 additions & 0 deletions test/cmdlineTests/standard_output_selection_empty/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"language": "Solidity",
"sources": {
"C": {"content": "contract A {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"}
},
"settings": {
"outputSelection": {}
}
}
7 changes: 7 additions & 0 deletions test/cmdlineTests/standard_output_selection_empty/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sources": {
"C": {
"id": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"language": "Solidity",
"sources": {
"": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"*": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"C": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"D": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"}
},
"settings": {
"outputSelection": {
// FIXME: Behavior of "" is inconsistent. Sometimes it matches everything, sometimes only empty name.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"" seems broken. I'm going to report it as an issue. I think we should make it not work as a wildcard. Changing it is technically breaking though. Change the other way is not.

"": {
"": ["metadata"], // No matches
"*": ["transientStorageLayout"], // All sources, all contracts
"A": ["abi"] // source "", contract A
},
"*": {
"": ["evm.deployedBytecode.immutableReferences"], // No matches
"*": ["evm.bytecode.object"], // All sources, all contracts
"A": ["evm.bytecode.linkReferences"] // All sources, contract A
},
"C": {
"": ["userdoc"], // No matches
"*": ["devdoc"], // All contracts in source "C"
"A": ["storageLayout"] // source "C", contract A
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"contracts": {
"": {
"A": {
"abi": [],
"evm": {
"bytecode": {
"linkReferences": {},
"object": "<BYTECODE REMOVED>"
}
},
"transientStorageLayout": {
"storage": [],
"types": null
}
},
"B": {
"evm": {
"bytecode": {
"object": "<BYTECODE REMOVED>"
}
},
"transientStorageLayout": {
"storage": [],
"types": null
}
}
},
"*": {
"A": {
"evm": {
"bytecode": {
"linkReferences": {},
"object": "<BYTECODE REMOVED>"
}
}
},
"B": {
"evm": {
"bytecode": {
"object": "<BYTECODE REMOVED>"
}
}
}
},
"C": {
"A": {
"devdoc": {
"kind": "dev",
"methods": {},
"version": 1
},
"evm": {
"bytecode": {
"linkReferences": {},
"object": "<BYTECODE REMOVED>"
}
},
"storageLayout": {
"storage": [],
"types": null
}
},
"B": {
"devdoc": {
"kind": "dev",
"methods": {},
"version": 1
},
"evm": {
"bytecode": {
"object": "<BYTECODE REMOVED>"
}
}
}
},
"D": {
"A": {
"evm": {
"bytecode": {
"linkReferences": {},
"object": "<BYTECODE REMOVED>"
}
}
},
"B": {
"evm": {
"bytecode": {
"object": "<BYTECODE REMOVED>"
}
}
}
}
},
"sources": {
"": {
"id": 0
},
"*": {
"id": 1
},
"C": {
"id": 2
},
"D": {
"id": 3
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"language": "Solidity",
"sources": {
"C": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"},
"D": {"content": "contract A {}\ncontract B {}\n//SPDX-License-Identifier: GPL-3.0\npragma solidity *;"}
},
"settings": {
"optimizer": {"enabled": true},
"debug": {"debugInfo": []},
"outputSelection": {
// This test uses outputs that require all stages of the pipeline to run, possibly via
// multiple paths, to make sure the later stages handle more complex output selection correctly.
// Currently there are only distinct paths (IR, optimized IR and bytecode generation).
"*": {
"*": ["evm.bytecode.object"],
"A": ["irOptimized"]
},
"C": {
"A": ["ir"]
}
}
}
}
Loading