summaryrefslogtreecommitdiff
path: root/test cases/rewrite
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/rewrite')
-rw-r--r--test cases/rewrite/1 basic/addSrc.json38
-rw-r--r--test cases/rewrite/1 basic/addTgt.json2
-rw-r--r--test cases/rewrite/1 basic/expected_dag.txt160
-rw-r--r--test cases/rewrite/1 basic/info.json20
-rw-r--r--test cases/rewrite/1 basic/meson.build16
-rw-r--r--test cases/rewrite/1 basic/rmSrc.json40
-rw-r--r--test cases/rewrite/1 basic/rmTgt.json5
-rw-r--r--test cases/rewrite/7 tricky dataflow/addSrc.json72
-rw-r--r--test cases/rewrite/7 tricky dataflow/info.json32
-rw-r--r--test cases/rewrite/7 tricky dataflow/meson.build35
10 files changed, 354 insertions, 66 deletions
diff --git a/test cases/rewrite/1 basic/addSrc.json b/test cases/rewrite/1 basic/addSrc.json
index b8bc43916..52603f60b 100644
--- a/test cases/rewrite/1 basic/addSrc.json
+++ b/test cases/rewrite/1 basic/addSrc.json
@@ -43,6 +43,24 @@
},
{
"type": "target",
+ "target": "trivialprog10",
+ "operation": "src_add",
+ "sources": ["fileA.cpp", "fileB.cpp", "a1.cpp"]
+ },
+ {
+ "type": "target",
+ "target": "trivialprog11",
+ "operation": "src_add",
+ "sources": ["fileA.cpp", "a1.cpp"]
+ },
+ {
+ "type": "target",
+ "target": "trivialprog12",
+ "operation": "src_add",
+ "sources": ["fileA.cpp", "fileB.cpp", "a1.cpp"]
+ },
+ {
+ "type": "target",
"target": "trivialprog0",
"operation": "info"
},
@@ -90,5 +108,25 @@
"type": "target",
"target": "trivialprog9",
"operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog10",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog11",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog12",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "rightName",
+ "operation": "info"
}
]
diff --git a/test cases/rewrite/1 basic/addTgt.json b/test cases/rewrite/1 basic/addTgt.json
index 2f4e7e256..02d600a82 100644
--- a/test cases/rewrite/1 basic/addTgt.json
+++ b/test cases/rewrite/1 basic/addTgt.json
@@ -1,7 +1,7 @@
[
{
"type": "target",
- "target": "trivialprog10",
+ "target": "trivialprog13",
"operation": "target_add",
"sources": ["new1.cpp", "new2.cpp"],
"target_type": "shared_library"
diff --git a/test cases/rewrite/1 basic/expected_dag.txt b/test cases/rewrite/1 basic/expected_dag.txt
index abc04fc31..c5025b4ad 100644
--- a/test cases/rewrite/1 basic/expected_dag.txt
+++ b/test cases/rewrite/1 basic/expected_dag.txt
@@ -15,69 +15,115 @@ Data flowing to ArrayNode(6:7):
IdNode(6:8)
Data flowing to IdNode(6:8):
IdNode(5:7)
+Data flowing to ArithmeticNode(7:7):
+ ArrayNode(7:7)
+ ArrayNode(8:8)
+Data flowing to ArrayNode(7:7):
+ StringNode(7:8)
+ StringNode(7:20)
+Data flowing to ArrayNode(8:8):
+ StringNode(8:9)
+Data flowing to ArrayNode(9:7):
+ StringNode(9:8)
+ StringNode(9:20)
Data flowing to FunctionNode(10:7):
- StringNode(10:18)
- ArithmeticNode(10:34)
-Data flowing to ArithmeticNode(10:34):
- IdNode(10:34)
- IdNode(10:41)
-Data flowing to IdNode(10:34):
+ IdNode(10:13)
+Data flowing to IdNode(10:13):
+ ArrayNode(9:7)
+Data flowing to ArrayNode(11:7):
+ StringNode(11:8)
+ StringNode(11:20)
+Data flowing to IdNode(12:7):
+ ArrayNode(11:7)
+Data flowing to ArrayNode(13:7):
+ StringNode(13:8)
+ StringNode(13:21)
+Data flowing to FunctionNode(15:13):
+ StringNode(14:7)
+ StringNode(15:26)
+Data flowing to FunctionNode(20:7):
+ StringNode(20:18)
+ ArithmeticNode(20:34)
+Data flowing to ArithmeticNode(20:34):
+ IdNode(20:34)
+ IdNode(20:41)
+Data flowing to IdNode(20:34):
ArrayNode(3:7)
-Data flowing to IdNode(10:41):
+Data flowing to IdNode(20:41):
FunctionNode(4:7)
-Data flowing to FunctionNode(11:7):
- StringNode(11:18)
- IdNode(11:34)
-Data flowing to IdNode(11:34):
+Data flowing to FunctionNode(21:7):
+ StringNode(21:18)
+ IdNode(21:34)
+Data flowing to IdNode(21:34):
ArrayNode(3:7)
-Data flowing to FunctionNode(12:7):
- StringNode(12:18)
- ArrayNode(12:34)
-Data flowing to ArrayNode(12:34):
- IdNode(12:35)
-Data flowing to IdNode(12:35):
+Data flowing to FunctionNode(22:7):
+ StringNode(22:18)
+ ArrayNode(22:34)
+Data flowing to ArrayNode(22:34):
+ IdNode(22:35)
+Data flowing to IdNode(22:35):
FunctionNode(4:7)
-Data flowing to FunctionNode(13:7):
- StringNode(13:18)
- ArrayNode(13:34)
-Data flowing to ArrayNode(13:34):
- StringNode(13:35)
- StringNode(13:47)
-Data flowing to FunctionNode(14:7):
- StringNode(14:18)
- ArrayNode(14:34)
-Data flowing to ArrayNode(14:34):
- StringNode(14:35)
- ArrayNode(14:47)
-Data flowing to ArrayNode(14:47):
- StringNode(14:48)
-Data flowing to FunctionNode(15:7):
- StringNode(15:18)
- ArrayNode(15:34)
-Data flowing to ArrayNode(15:34):
- IdNode(15:35)
- StringNode(15:41)
-Data flowing to IdNode(15:35):
+Data flowing to FunctionNode(23:7):
+ StringNode(23:18)
+ ArrayNode(23:34)
+Data flowing to ArrayNode(23:34):
+ StringNode(23:35)
+ StringNode(23:47)
+Data flowing to FunctionNode(24:7):
+ StringNode(24:18)
+ ArrayNode(24:34)
+Data flowing to ArrayNode(24:34):
+ StringNode(24:35)
+ ArrayNode(24:47)
+Data flowing to ArrayNode(24:47):
+ StringNode(24:48)
+Data flowing to FunctionNode(25:7):
+ StringNode(25:18)
+ ArrayNode(25:34)
+Data flowing to ArrayNode(25:34):
+ IdNode(25:35)
+ StringNode(25:41)
+Data flowing to IdNode(25:35):
FunctionNode(4:7)
-Data flowing to FunctionNode(16:7):
- StringNode(16:18)
- StringNode(16:34)
- StringNode(16:46)
-Data flowing to FunctionNode(17:7):
- StringNode(17:18)
- StringNode(17:34)
- IdNode(17:47)
- StringNode(17:53)
-Data flowing to IdNode(17:47):
+Data flowing to FunctionNode(26:7):
+ StringNode(26:18)
+ StringNode(26:34)
+ StringNode(26:46)
+Data flowing to FunctionNode(27:7):
+ StringNode(27:18)
+ StringNode(27:34)
+ FunctionNode(27:47)
+ StringNode(27:69)
+Data flowing to FunctionNode(27:47):
ArrayNode(3:7)
-Data flowing to FunctionNode(18:7):
- StringNode(18:18)
- IdNode(18:34)
-Data flowing to IdNode(18:34):
+ StringNode(27:60)
+Data flowing to FunctionNode(28:7):
+ StringNode(28:18)
+ IdNode(28:34)
+Data flowing to IdNode(28:34):
IdNode(5:7)
-Data flowing to FunctionNode(19:0):
- StringNode(19:11)
- IdNode(19:27)
-Data flowing to IdNode(19:27):
+Data flowing to FunctionNode(29:0):
+ StringNode(29:11)
+ IdNode(29:27)
+Data flowing to IdNode(29:27):
ArrayNode(6:7)
-
+Data flowing to FunctionNode(30:0):
+ StringNode(30:11)
+ IdNode(30:28)
+Data flowing to IdNode(30:28):
+ ArithmeticNode(7:7)
+Data flowing to FunctionNode(31:0):
+ StringNode(31:11)
+ IdNode(31:28)
+Data flowing to IdNode(31:28):
+ FunctionNode(10:7)
+Data flowing to FunctionNode(32:0):
+ StringNode(32:11)
+ IdNode(32:28)
+Data flowing to IdNode(32:28):
+ IdNode(12:7)
+Data flowing to FunctionNode(33:0):
+ IdNode(33:11)
+ StringNode(33:23)
+Data flowing to IdNode(33:11):
+ FunctionNode(15:13)
diff --git a/test cases/rewrite/1 basic/info.json b/test cases/rewrite/1 basic/info.json
index 0f1a3bd8c..9977f5a87 100644
--- a/test cases/rewrite/1 basic/info.json
+++ b/test cases/rewrite/1 basic/info.json
@@ -53,5 +53,25 @@
"type": "target",
"target": "trivialprog10",
"operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog11",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog12",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog13",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "rightName",
+ "operation": "info"
}
]
diff --git a/test cases/rewrite/1 basic/meson.build b/test cases/rewrite/1 basic/meson.build
index 0f87c4520..5fe952769 100644
--- a/test cases/rewrite/1 basic/meson.build
+++ b/test cases/rewrite/1 basic/meson.build
@@ -4,6 +4,16 @@ src1 = ['main.cpp', 'fileA.cpp']
src2 = files(['fileB.cpp', 'fileC.cpp'])
src3 = src1
src4 = [src3]
+src5 = ['main.cpp', 'fileA.cpp']
+src5 += ['fileB.cpp']
+src6 = ['main.cpp', 'fileA.cpp']
+src6 = files(src6)
+src7 = ['main.cpp', 'fileA.cpp']
+src8 = src7
+src7 = ['fileB.cpp', 'fileC.cpp']
+name = 'rightName'
+trickyName = get_variable('name')
+name = 'wrongName'
# Magic comment
@@ -14,6 +24,10 @@ exe3 = executable('trivialprog3', ['main.cpp', 'fileA.cpp'])
exe4 = executable('trivialprog4', ['main.cpp', ['fileA.cpp']])
exe5 = executable('trivialprog5', [src2, 'main.cpp'])
exe6 = executable('trivialprog6', 'main.cpp', 'fileA.cpp')
-exe7 = executable('trivialprog7', 'fileB.cpp', src1, 'fileC.cpp')
+exe7 = executable('trivialprog7', 'fileB.cpp', get_variable('src1'), 'fileC.cpp')
exe8 = executable('trivialprog8', src3)
executable('trivialprog9', src4)
+executable('trivialprog10', src5)
+executable('trivialprog11', src6)
+executable('trivialprog12', src8)
+executable(trickyName, 'main.cpp')
diff --git a/test cases/rewrite/1 basic/rmSrc.json b/test cases/rewrite/1 basic/rmSrc.json
index 2e7447c68..de56bbe1b 100644
--- a/test cases/rewrite/1 basic/rmSrc.json
+++ b/test cases/rewrite/1 basic/rmSrc.json
@@ -1,12 +1,6 @@
[
{
"type": "target",
- "target": "trivialprog1",
- "operation": "src_rm",
- "sources": ["fileA.cpp"]
- },
- {
- "type": "target",
"target": "trivialprog3",
"operation": "src_rm",
"sources": ["fileA.cpp"]
@@ -21,7 +15,7 @@
"type": "target",
"target": "trivialprog5",
"operation": "src_rm",
- "sources": ["fileB.cpp"]
+ "sources": ["main.cpp"]
},
{
"type": "target",
@@ -37,6 +31,18 @@
},
{
"type": "target",
+ "target": "trivialprog10",
+ "operation": "src_rm",
+ "sources": ["fileA.cpp", "fileB.cpp"]
+ },
+ {
+ "type": "target",
+ "target": "trivialprog11",
+ "operation": "src_rm",
+ "sources": ["fileA.cpp"]
+ },
+ {
+ "type": "target",
"target": "trivialprog0",
"operation": "info"
},
@@ -84,5 +90,25 @@
"type": "target",
"target": "trivialprog9",
"operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog10",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog11",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "trivialprog12",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "rightName",
+ "operation": "info"
}
]
diff --git a/test cases/rewrite/1 basic/rmTgt.json b/test cases/rewrite/1 basic/rmTgt.json
index dbaf02535..bc6dc302e 100644
--- a/test cases/rewrite/1 basic/rmTgt.json
+++ b/test cases/rewrite/1 basic/rmTgt.json
@@ -13,5 +13,10 @@
"type": "target",
"target": "trivialprog9",
"operation": "target_rm"
+ },
+ {
+ "type": "target",
+ "target": "rightName",
+ "operation": "target_rm"
}
]
diff --git a/test cases/rewrite/7 tricky dataflow/addSrc.json b/test cases/rewrite/7 tricky dataflow/addSrc.json
new file mode 100644
index 000000000..1b6aa485b
--- /dev/null
+++ b/test cases/rewrite/7 tricky dataflow/addSrc.json
@@ -0,0 +1,72 @@
+[
+ {
+ "type": "target",
+ "target": "tgt1",
+ "operation": "src_add",
+ "sources": [
+ "new.c"
+ ]
+ },
+ {
+ "type": "target",
+ "target": "tgt2",
+ "operation": "src_add",
+ "sources": [
+ "new.c"
+ ]
+ },
+ {
+ "type": "target",
+ "target": "tgt3",
+ "operation": "src_add",
+ "sources": [
+ "new.c"
+ ]
+ },
+ {
+ "type": "target",
+ "target": "tgt5",
+ "operation": "src_add",
+ "sources": [
+ "new.c"
+ ]
+ },
+ {
+ "type": "target",
+ "target": "tgt6",
+ "operation": "src_add",
+ "sources": [
+ "new.c"
+ ]
+ },
+ {
+ "type": "target",
+ "target": "tgt1",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt2",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt3",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt4",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt5",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt6",
+ "operation": "info"
+ }
+]
diff --git a/test cases/rewrite/7 tricky dataflow/info.json b/test cases/rewrite/7 tricky dataflow/info.json
new file mode 100644
index 000000000..5fc65dd8c
--- /dev/null
+++ b/test cases/rewrite/7 tricky dataflow/info.json
@@ -0,0 +1,32 @@
+[
+ {
+ "type": "target",
+ "target": "tgt1",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt2",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt3",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt4",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt5",
+ "operation": "info"
+ },
+ {
+ "type": "target",
+ "target": "tgt6",
+ "operation": "info"
+ }
+]
diff --git a/test cases/rewrite/7 tricky dataflow/meson.build b/test cases/rewrite/7 tricky dataflow/meson.build
new file mode 100644
index 000000000..4c183ed97
--- /dev/null
+++ b/test cases/rewrite/7 tricky dataflow/meson.build
@@ -0,0 +1,35 @@
+project('rewrite tricky dataflow', 'c')
+
+# Adding a file to `begin` will add this file to the sources of `tgt1`, but
+# not to any other target. But a buggy rewriter might think that adding a file
+# to `begin` will also add this file to `end` and will refuse to add a file to
+# `begin`.
+begin = ['foo.c']
+tgt1 = library('tgt1', begin)
+distraction = executable('distraction', link_with: tgt1)
+
+
+tgt2_srcs = ['foo.c']
+if meson.host_machine().system() == 'windows' # Some condition that cannot be known statically
+ tgt2_srcs += ['bar.c']
+endif
+executable('tgt2', tgt2_srcs)
+
+
+tgt34_srcs = ['foo.c']
+executable('tgt3', tgt34_srcs)
+if meson.host_machine().system() == 'windows'
+ tgt34_srcs += ['bar.c']
+endif
+executable('tgt4', tgt34_srcs)
+
+
+dont_add_here_5 = ['foo.c']
+ct = custom_target('ct', output: 'out.c', input: dont_add_here_5, command: ['placeholder', '@INPUT@', '@OUTPUT@'])
+executable('tgt5', ct)
+
+
+dont_add_here_6 = ['foo.c']
+gen = generator(find_program('cp'), output: '@BASENAME@_copy.c', arguments: ['@INPUT@', '@OUTPUT@'])
+generated = gen.process(dont_add_here_6)
+executable('tgt6', generated)