Skip to content

Commit

Permalink
Add test for include conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitten-O committed Nov 2, 2015
1 parent 1a3f8ee commit 7f28f12
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"name": "test",
"mainSourceFile": "test.d",
"targetName": "test",
"lflags-posix": ["-lz"],
"excludedSourceFiles": ["dstep/*", "clang/*"]
}
],
Expand Down
5 changes: 5 additions & 0 deletions features/include_conversion.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Include Conversion

Scenario: Convert includes
Then I test the file "includes" with filter "dummy_includes/transform.*" and prefix "transformed."

7 changes: 7 additions & 0 deletions features/step_definitions/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
step %{the files "#{file}.d" and "test_files/#{path}/#{file}.d" should be equal}
end

Then /^I test the file "([^"]*)" with filter "([^"]*)" and prefix "([^"]*)"$/ do |file, filter, prefix|
step %{a test file named "#{file}"}
step %{an expected file named "#{file}"}
step %{I successfully convert the test file "#{file}" in "" with the flags "--import-filter #{filter} --import-prefix #{prefix}"}
step %{the files "#{file}.d" and "test_files/#{file}.d" should be equal}
end

if OSX
Then /^I test the Objective\-C file "([^"]*)" in "([^"]*)"$/ do |file, path|
step %{a test file named "#{file}" in "#{path}"}
Expand Down
8 changes: 8 additions & 0 deletions test_files/dummy_includes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Directory dummy_includes
========================
Clang gets angry about non-existent includes,
so to test include transformation, we have dummy
files to be included here.

(Other test files cannot be used because they need
to be free to contain name conflicts.)
1 change: 1 addition & 0 deletions test_files/dummy_includes/ignored.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
struct Ignored{};
1 change: 1 addition & 0 deletions test_files/dummy_includes/transform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
struct Transform{};
1 change: 1 addition & 0 deletions test_files/dummy_includes/transform_also.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
struct TransformAlso{};
5 changes: 5 additions & 0 deletions test_files/includes.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import transformed.transform;
import transformed.transform_also;

extern (C):

10 changes: 10 additions & 0 deletions test_files/includes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "dummy_includes/transform.h"
#include "dummy_includes/ignored.h"
#include "dummy_includes/transform_also.h"

// Dstep only pays attention to includes whose types are used so we
// use a type from each here.
struct Transform transform;
struct Ignored ignored;
struct TransformAlso transform_also;

0 comments on commit 7f28f12

Please sign in to comment.