-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 22730 - Promote imported files (-i) to root module before parsing...
... the declarations. DMD PR 13224 changed the parser s.t. unittests from non-root modules are skipped, i.e. not even parsed. The new behaviour didn't work as expected when combined with `-i` because it promoted imported files to root modules *after* the parser processed the entire file. This commit moves the existing checks s.t. they are applied immediatly after the module declaration was read by the parser.
- Loading branch information
1 parent
c1c6e2c
commit 1c31d85
Showing
5 changed files
with
88 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
unittest | ||
{ | ||
// This should trigger because this is a root module | ||
pragma(msg, "Compiling compiled_lib.unittests"); | ||
} | ||
|
||
void someFunction() | ||
{ | ||
// This should trigger because this is a root module | ||
pragma(msg, "Compiling compiled_lib.someFunction"); | ||
} |
13 changes: 13 additions & 0 deletions
13
test/compilable/imports/include_unittest/compiled_unittest_lib.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module lib.with_.unittests; | ||
|
||
void someFunction() | ||
{ | ||
// This should trigger because this is a root module | ||
pragma(msg, "Compiling lib.with_.unittests.someFunction"); | ||
} | ||
|
||
unittest | ||
{ | ||
// This should trigger because this is a root module | ||
pragma(msg, "Compiling lib.with_.unittests.unittest"); | ||
} |
15 changes: 15 additions & 0 deletions
15
test/compilable/imports/include_unittest/skipped_unittest_lib.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module lib.ignores.unittests; | ||
|
||
pragma(msg, "Found module with skipped unittests"); | ||
|
||
unittest | ||
{ | ||
// Shouldn't be parsed because we're in a non-root module | ||
static assert(false, "Semantic on unittest in non-root module!"); | ||
} | ||
|
||
void someFunction() | ||
{ | ||
// This shouldn't be evaluated, no semantic for the body in non-root modules | ||
static assert(false, "Semantic on function body in non-root module!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/+ | ||
https://issues.dlang.org/show_bug.cgi?id=22730 | ||
EXTRA_FILES: imports/include_unittest/compiled_lib.d import imports/include_unittest/skipped_unittest_lib.d import imports/include_unittest/compiled_unittest_lib.d | ||
REQUIRED_ARGS: -i=compiled_lib -i=lib.with_.unittests -unittest | ||
TEST_OUTPUT: | ||
--- | ||
Found module with skipped unittests | ||
Compiling compiled_lib.unittests | ||
Compiling compiled_lib.someFunction | ||
Compiling lib.with_.unittests.someFunction | ||
Compiling lib.with_.unittests.unittest | ||
--- | ||
+/ | ||
|
||
import imports.include_unittest.compiled_lib; // Matches the first -i pattern, no module decl. | ||
import imports.include_unittest.skipped_unittest_lib; // Matches neither -i pattern | ||
import imports.include_unittest.compiled_unittest_lib; // Matches the second -i pattern, has module decl. |