forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce5e8b9
commit 1ce81f5
Showing
4 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// we include a file that gets modified in the test before the 1st and 2nd compilation | ||
#include "D20190123T230907.h" |
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,6 @@ | ||
#include "fun1.h" | ||
|
||
int foo(){ | ||
int a = MYVAR; | ||
return a; | ||
} |
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,3 @@ | ||
#include <stdio.h> | ||
|
||
int foo(); |
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,36 @@ | ||
discard """ | ||
disabled: true | ||
""" | ||
|
||
# issue #10441 | ||
|
||
when defined(case_D20190123T230907): # child process | ||
{.compile: ("fun2.c").} | ||
proc foo(): cint {.importc, header:"fun1.h".} | ||
echo foo() | ||
else: | ||
# main process | ||
import os, osproc, strformat, strutils | ||
import compiler/unittest_light | ||
import stdtest/specialpaths | ||
|
||
proc main() = | ||
const nim = getCurrentCompilerExe() | ||
const input = currentSourcePath() | ||
const headerGen = buildDir / "D20190123T230907.h" | ||
defer: removeFile headerGen | ||
#[ | ||
* the command line doesn't change across 2 subsequent invocations | ||
* we pass --forceBuild:off just to make sure it's not overridden in config file | ||
* the only thing that changes across the 2 `nim` invocations is `headerGen`, included by `fun2.c` | ||
]# | ||
let cmd = fmt"{nim} c --forceBuild:off -r --passC:-I{buildDir.quoteShell} -d:case_D20190123T230907 {input}" | ||
for a in [123, 124]: | ||
writeFile headerGen, fmt""" | ||
#define MYVAR {a} | ||
""" | ||
var (output, exitCode) = execCmdEx(cmd, options = {}) | ||
doAssert exitCode == 0 | ||
output.stripLineEnd | ||
assertEquals output, $a | ||
main() |