Skip to content

Commit 7f28f12

Browse files
committed
Add test for include conversion.
1 parent 1a3f8ee commit 7f28f12

File tree

9 files changed

+39
-0
lines changed

9 files changed

+39
-0
lines changed

dub.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"name": "test",
2828
"mainSourceFile": "test.d",
2929
"targetName": "test",
30+
"lflags-posix": ["-lz"],
3031
"excludedSourceFiles": ["dstep/*", "clang/*"]
3132
}
3233
],
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Feature: Include Conversion
2+
3+
Scenario: Convert includes
4+
Then I test the file "includes" with filter "dummy_includes/transform.*" and prefix "transformed."
5+

features/step_definitions/common.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@
5050
step %{the files "#{file}.d" and "test_files/#{path}/#{file}.d" should be equal}
5151
end
5252

53+
Then /^I test the file "([^"]*)" with filter "([^"]*)" and prefix "([^"]*)"$/ do |file, filter, prefix|
54+
step %{a test file named "#{file}"}
55+
step %{an expected file named "#{file}"}
56+
step %{I successfully convert the test file "#{file}" in "" with the flags "--import-filter #{filter} --import-prefix #{prefix}"}
57+
step %{the files "#{file}.d" and "test_files/#{file}.d" should be equal}
58+
end
59+
5360
if OSX
5461
Then /^I test the Objective\-C file "([^"]*)" in "([^"]*)"$/ do |file, path|
5562
step %{a test file named "#{file}" in "#{path}"}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Directory dummy_includes
2+
========================
3+
Clang gets angry about non-existent includes,
4+
so to test include transformation, we have dummy
5+
files to be included here.
6+
7+
(Other test files cannot be used because they need
8+
to be free to contain name conflicts.)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct Ignored{};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct Transform{};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct TransformAlso{};

test_files/includes.d

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import transformed.transform;
2+
import transformed.transform_also;
3+
4+
extern (C):
5+

test_files/includes.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "dummy_includes/transform.h"
2+
#include "dummy_includes/ignored.h"
3+
#include "dummy_includes/transform_also.h"
4+
5+
// Dstep only pays attention to includes whose types are used so we
6+
// use a type from each here.
7+
struct Transform transform;
8+
struct Ignored ignored;
9+
struct TransformAlso transform_also;
10+

0 commit comments

Comments
 (0)