-
-
Notifications
You must be signed in to change notification settings - Fork 685
Small improvements to unit_tester_runner + run.d #9348
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
base: master
Are you sure you want to change the base?
Changes from all commits
90ce29e
c23f497
61effc9
306a5aa
a31a60c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,8 @@ import std.exception : enforce; | |
| import std.file : dirEntries, exists, SpanMode, mkdirRecurse, write; | ||
| import std.format : format; | ||
| import std.getopt : getopt; | ||
| import std.path : absolutePath, buildPath, dirSeparator, stripExtension, | ||
| setExtension; | ||
| import std.path : absolutePath, buildPath, dirSeparator, relativePath, | ||
| setExtension, stripExtension; | ||
| import std.process : environment, spawnProcess, spawnShell, wait; | ||
| import std.range : empty; | ||
| import std.stdio; | ||
|
|
@@ -19,6 +19,7 @@ import tools.paths; | |
|
|
||
| enum unitTestDir = testPath("unit"); | ||
| enum strtoldObjPath = resultsDir.buildPath("strtold.obj"); | ||
| enum dmdSrcDir = projectRootDir.buildPath("src"); | ||
|
|
||
| string[] testFiles(Range)(Range givenFiles) | ||
| { | ||
|
|
@@ -34,10 +35,9 @@ string[] testFiles(Range)(Range givenFiles) | |
| auto moduleNames(const string[] testFiles) | ||
| { | ||
| return testFiles | ||
| .map!(e => e[unitTestDir.length + 1 .. $]) | ||
| .map!stripExtension | ||
| .array | ||
| .map!(e => e.substitute(dirSeparator, ".")); | ||
| .map!(e => e.relativePath(unitTestDir) | ||
| .stripExtension | ||
| .substitute(dirSeparator, ".")); | ||
| } | ||
|
|
||
| void writeRunnerFile(Range)(Range moduleNames, string path, string filter) | ||
|
|
@@ -236,7 +236,7 @@ void writeCmdfile(string path, string runnerPath, string outputPath, | |
| "-unittest", | ||
| "-J" ~ buildOutputPath, | ||
| "-J" ~ projectRootDir.buildPath("res"), | ||
| "-I" ~ projectRootDir.buildPath("src"), | ||
| "-I" ~ dmdSrcDir, | ||
| "-I" ~ unitTestDir, | ||
| "-i", | ||
| "-g", | ||
|
|
@@ -289,10 +289,10 @@ void buildStrtold() | |
| "/EHsc", | ||
| "/TP", | ||
| "/c", | ||
| projectRootDir.buildPath("src", "dmd", "backend", "strtold.c"), | ||
| dmdSrcDir.buildPath("dmd", "backend", "strtold.c"), | ||
| "/Fo" ~ strtoldObjPath, | ||
| "/I", | ||
| projectRootDir.buildPath("src", "dmd", "root") | ||
| dmdSrcDir.buildPath("dmd", "root") | ||
| ].join(" "); | ||
|
|
||
| enforce(spawnShell(cmd).wait() == 0, "Failed to execute command: " ~ cmd); | ||
|
|
@@ -321,6 +321,9 @@ int main(string[] args) | |
| if (missingTestFiles(givenFiles)) | ||
| return 1; | ||
|
|
||
| const nrOfFiles = givenFiles.length ? givenFiles.length.to!string : "all"; | ||
| stderr.writefln("[unit] Starting to build %s test files", nrOfFiles); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why stderr? |
||
|
|
||
| enum runnerPath = resultsDir.buildPath("runner.d"); | ||
| const testFiles = givenFiles.testFiles; | ||
|
|
||
|
|
@@ -336,5 +339,6 @@ int main(string[] args) | |
| buildStrtold(); | ||
| execute(dmdPath, "@" ~ cmdfilePath); | ||
|
|
||
| stderr.writefln("[unit] Starting to run %s test files", nrOfFiles); | ||
| return spawnProcess(outputPath).wait(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably also prepend the output with a prefix here as it currently looks like this:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn’t that what your change is doing?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope. The log is already from this change. We probably need to create our own while (!pid.tryWait.terminated) {
// if pipe has new data, read it from the buffer, split by line and append `[unit]`
sleep(1.msecs);
}
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'm not following.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Though for the user to know where the message came from imho it probably would be better to at least do sth. like: For this we need to either add the prefix in the actual runner or e.g. read line-wise as discussed above from the stdout pipe of the spawned process.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok, now I get it. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should not document it since the
-uflag exists as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but it's documented in the
README.md:I guess as long as we're consistent I'm fine either way. Other thoughts.
Btw currently there's no easy way in to run just the integration tests (i.e. compilable, runnable, fail_compilation). Maybe it's worth adding
testsas a shortcut?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we can remove that as well. It's a bit inconsistent to have
unit_testsand the-uflag.Perhaps.