Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Drop Phobos dependency for compiler tests #16587

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/fail18243.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
EXTRA_FILES: imports/a18243.d
EXTRA_FILES: imports/a18243.d imports/b18243.d
TEST_OUTPUT:
---
fail_compilation/fail18243.d(15): Error: none of the overloads of `isNaN` are callable using argument types `!()(float)`
Expand Down
4 changes: 2 additions & 2 deletions compiler/test/fail_compilation/imports/a18243.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module a18243;
module imports.a18243;

import std.math : isNaN;
import imports.b18243 : isNaN;

public bool isNaN() { return false; }
3 changes: 3 additions & 0 deletions compiler/test/fail_compilation/imports/b18243.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module imports.b18243;

bool isNaN(T)(T x) { return false; }
3 changes: 1 addition & 2 deletions compiler/test/fail_compilation/issue11070.d
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*
TEST_OUTPUT:
---
fail_compilation/issue11070.d(16): Error: undefined identifier `x`
fail_compilation/issue11070.d(15): Error: undefined identifier `x`
---
*/

int get() { return 1; }

void test() {
import std.stdio : writeln;
switch (auto x = get()) {
default:
auto z = x;
Expand Down
4 changes: 1 addition & 3 deletions compiler/test/fail_compilation/operator_undefined.d
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/*
TEST_OUTPUT:
---
fail_compilation/operator_undefined.d(19): Error: operator `-` is not defined for `toJson(2)` of type `Json`
fail_compilation/operator_undefined.d(17): Error: operator `-` is not defined for `toJson(2)` of type `Json`
---
*/

import std.stdio;

struct Json
{
//int opUnary(string op : "-")();
Expand Down
28 changes: 14 additions & 14 deletions compiler/test/run.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import std.algorithm, std.conv, std.datetime, std.exception, std.file, std.forma
import tools.paths;

const scriptDir = __FILE_FULL_PATH__.dirName.buildNormalizedPath;
immutable testDirs = ["runnable", "runnable_cxx", "dshell", "compilable", "fail_compilation"];
immutable testDirs = ["runnable", "runnable_cxx", /*"dshell",*/ "compilable", "fail_compilation"];
shared bool verbose; // output verbose logging
shared bool force; // always run all tests (ignores timestamp checking)
shared string hostDMD; // path to host DMD binary (used for building the tools)
Expand Down Expand Up @@ -55,7 +55,7 @@ enum TestTool testRunnerUnittests = { name: "d_do_test-ut",
extraArgs: testRunner.extraArgs ~ ["-g", "-unittest"],
runAfterBuild: true };
enum TestTool jsonSanitizer = { name: "sanitize_json" };
enum TestTool dshellPrebuilt = { name: "dshell_prebuilt", linksWithTests: true };
//enum TestTool dshellPrebuilt = { name: "dshell_prebuilt", linksWithTests: true };

immutable struct TestTool
{
Expand Down Expand Up @@ -153,7 +153,7 @@ Options:
return spawnProcess(unitTestRunnerCommand ~ args, env, Config.none, scriptDir).wait();
}

ensureToolsExists(env, unitTestRunner, testRunner, testRunnerUnittests, jsonSanitizer, dshellPrebuilt);
ensureToolsExists(env, unitTestRunner, testRunner, testRunnerUnittests, jsonSanitizer/*, dshellPrebuilt*/);

if (args == ["tools"])
return 0;
Expand Down Expand Up @@ -539,27 +539,24 @@ string[string] getEnvironment()
env["DMD"] = dmdPath;
env.setDefault("DMD_TEST_COVERAGE", "0");

const generatedSuffix = "generated/%s/%s/%s".format(os, build, model);
const druntimePath = environment.get("DRUNTIME_PATH", projectRootDir.buildPath("druntime"));
const druntimeLibDir = generatedDir.buildPath(os, build, model);

version(Windows)
{
env.setDefault("ARGS", "-inline -release -g -O");
env["OBJ"] = ".obj";
env["DSEP"] = `\\`;
env["SEP"] = `\`;
auto druntimePath = environment.get("DRUNTIME_PATH", testPath(`..\..\druntime`));
auto phobosPath = environment.get("PHOBOS_PATH", testPath(`..\..\..\phobos`));
env["DFLAGS"] = `-I"%s\import" -I"%s"`.format(druntimePath, phobosPath);
env["LIB"] = phobosPath ~ ";" ~ environment.get("LIB");
env["DFLAGS"] = `-conf= -I"%s\import" -defaultlib=druntime.lib`.format(druntimePath);
env["LIB"] = druntimeLibDir ~ ";" ~ environment.get("LIB");
}
else
{
env.setDefault("ARGS", "-inline -release -g -O -fPIC");
env["OBJ"] = ".o";
env["DSEP"] = "/";
env["SEP"] = "/";
auto druntimePath = environment.get("DRUNTIME_PATH", testPath(`../../druntime`));
auto phobosPath = environment.get("PHOBOS_PATH", testPath(`../../../phobos`));

// default to PIC, use PIC=1/0 to en-/disable PIC.
// Note that shared libraries and C files are always compiled with PIC.
Expand All @@ -568,11 +565,14 @@ string[string] getEnvironment()
pic = false;

env["PIC_FLAG"] = pic ? "-fPIC" : "";
env["DFLAGS"] = "-I%s/import -I%s".format(druntimePath, phobosPath)
~ " -L-L%s/%s".format(phobosPath, generatedSuffix);
bool isShared = environment.get("SHARED") != "0" && os.among("linux", "freebsd") > 0;

const isShared = environment.get("SHARED") != "0" && os.among("linux", "freebsd") > 0;
const defaultLib = os == "osx" ? "druntime" : "libdruntime." ~ (isShared ? "so" : "a");

env["DFLAGS"] = "-conf= -I%s/import -defaultlib=%s".format(druntimePath, defaultLib)
~ " -L-L" ~ druntimeLibDir;
if (isShared)
env["DFLAGS"] = env["DFLAGS"] ~ " -defaultlib=libphobos2.so -L-rpath=%s/%s".format(phobosPath, generatedSuffix);
env["DFLAGS"] = env["DFLAGS"] ~ " -L-rpath=" ~ druntimeLibDir;

if (pic)
env["REQUIRED_ARGS"] = environment.get("REQUIRED_ARGS") ~ " " ~ env["PIC_FLAG"];
Expand Down
1 change: 0 additions & 1 deletion compiler/test/runnable/arrayop.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// RUNNABLE_PHOBOS_TEST
import std.math;

extern(C) int printf(const char*, ...);

Expand Down
1 change: 0 additions & 1 deletion compiler/test/runnable/dhry.d
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ Deprecation caused by https://issues.dlang.org/show_bug.cgi?id=20645
import core.stdc.stdio;
import core.stdc.string;
import core.stdc.stdlib;
import std.string;


/* Compiler and system dependent definitions: */
Expand Down
4 changes: 2 additions & 2 deletions compiler/test/runnable/extra-files/importc_main.d
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

import std.stdio;
import core.stdc.stdio;
import importc_test;

int main()
{
auto rc = someCodeInC(3, 4);
writeln("Result of someCodeInC(3,4) = ", rc );
printf("Result of someCodeInC(3,4) = %d\n", rc);
assert( rc == 7, "Wrong result");
return 0;
}
1 change: 0 additions & 1 deletion compiler/test/runnable/extra-files/importc_main2.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import std.stdio;
import importc_test;

int main()
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/runnable/test18076.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

output_file=${OUTPUT_BASE}.log

echo 'import std.stdio; void main() { writeln("Success"); }' | \
echo 'import core.stdc.stdio; void main() { puts("Success"); }' | \
$DMD -m${MODEL} -run - > ${output_file}
grep -q 'Success' ${output_file}

Expand Down
4 changes: 1 addition & 3 deletions compiler/test/runnable/test19.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// REQUIRED_ARGS: -unittest

import std.algorithm: cmp;

extern(C) int printf(const char*, ...);

/* ================================ */
Expand Down Expand Up @@ -269,7 +267,7 @@ void test13()

s1 = s1.dup;
s2 = tolower13(s1);
assert(cmp(s2, "fol") == 0);
assert(s2 == "fol");
assert(s2 == s1);
}

Expand Down
8 changes: 4 additions & 4 deletions compiler/test/runnable/test8544.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// EXECUTE_ARGS: foo bar doo
// PERMUTE_ARGS:
import core.stdc.stdio;
import std.conv;
import core.stdc.string : strlen;
import core.runtime;

void main(string[] args)
Expand All @@ -12,6 +11,7 @@ void main(string[] args)
assert(dArgs.length && cArgs.argc); // ensure we've passed some args
assert(dArgs.length == cArgs.argc);

assert(dArgs[1] == to!string(cArgs.argv[1]));
assert(args[1] == to!string(cArgs.argv[1]));
const cArg = cArgs.argv[1][0 .. strlen(cArgs.argv[1])];
assert(dArgs[1] == cArg);
assert(args[1] == cArg);
}
2 changes: 1 addition & 1 deletion compiler/test/runnable/test9287.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

echo 'import std.stdio; void main() { writeln("Success"); }' | \
echo 'import core.stdc.stdio; void main() { puts("Success"); }' | \
$DMD -m${MODEL} -of${OUTPUT_BASE}${EXE} -

${OUTPUT_BASE}${EXE}
Expand Down
Loading