Conversation
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
Confirm submission IAW CLA. |
# Drop in the test data | ||
fusiontestdir = os.path.join(testdir, 'fusion/testdata') | ||
shutil.rmtree(fusiontestdir, ignore_errors=True) | ||
testdatasrc = Dir('../../../fusion/testdata').abspath |
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.
Maybe use src-base dir:
testdatasrc = Dir('#fusion/testdata').abspath
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.
Done
fusiontestdir = os.path.join(testdir, 'fusion/testdata') | ||
shutil.rmtree(fusiontestdir, ignore_errors=True) | ||
testdatasrc = Dir('../../../fusion/testdata').abspath | ||
shutil.copytree(testdatasrc, fusiontestdir) |
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.
Can use env.rsync_cmd % (testdatasrc, fusiontestdir). It is being used in other SConscript, but shutil is LGTM.
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.
Done. I actually prefer this method because it makes sure that it's executed at the correct build stage, unlike shutil which is executed immediately.
@andreisel I've implemented your suggested changes |
@@ -16,6 +16,7 @@ | |||
|
|||
Import('env') | |||
import os | |||
import shutil |
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.
This import is no longer needed.
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.
Done
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.
Remove the unused import.
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.
Tested on Ubuntu 14.04 and RHEL 7. All tests passed.
Looks good.
It worked for me, if I ran I thought the point of using Optionally, it might be nice to get a warning if you try running <src/common/tests/RunAllTests.pl>, rather than from a build directory. |
env.copyfile(os.path.join(env.exportdirs['bin'],'tests'), | ||
'RunAllTests.pl') | ||
# Drop in the test data | ||
env.Command( |
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.
Chris,
maybe put copying of script into the command as well.
So, we will have the command that manages everything we need to run tests.
could be something like this:
# put this somewhere on the top of file. I am expecting it should be a path in bin../..
current_dir = Dir('.').abspath
...
testdir = os.path.join(env.exportdirs['bin'],'tests')
# Copy the test data and the script that run all tests.
test_target = '%s/.install_for_test' % current_dir
env.Command(
test_target, testdir,
[env.copyfile(testdir, 'RunAllTests.pl'),
env.rsync_cmd % (Dir('#fusion/testdata').abspath, '%s/tests/fusion/' % Dir(env.exportdirs['bin']).abspath),
Touch('$TARGET')])
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.
@andreisel I don't really understand why this is necessary. The command to copy the RunAllTests.pl file works fine the way it is. And I think moving it underneath the env.Command call just makes it a little more confusing in my opinion.
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.
This may be because I don't really like the syntax for the env.Command in the first place. The problem is made somewhat worse because scons doesn't have thorough documentation for it. Also, I don't know if env.copyfile will return a "Command" that the env.Command function can use. I think it just does the copy instead, but I could be wrong. Scons is a bit complex still in my mind. :)
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.
Yeah, scons syntax is confusing.
My suggestion is combining all test setup actions into one command. So if anything else is required for test, it will be added to the list in the env.Command().
Why do we need to use/return anything from env.copyfile() in env.Command().
Source in env.Command() seems allow to set some dependencies:
Suggested above:
- specifies to run set of commands in the list [..] for target "install_for_test";
- specifies dependency on testdir: $SOURCE=testdir;
- creates .install_for_test file (TARGET) showing that the target "install_for_test" has been successful.
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.
@andreisel I tried implementing your suggestion. It turns out that the Command builder expects a list of strings, so it tries to execute the return value from env.copyfile as a string. This ends up running the tests as a part of the build, which is not the intended behavior. I think leaving it as two separate steps is the most scons-ish way of doing this.
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.
SG. Thanks.
@tst-ppenev I added a check to detect when the script is run outside of the expected directory and print an error. Take another look. |
env.copyfile(os.path.join(env.exportdirs['bin'],'tests'), | ||
'RunAllTests.pl') | ||
# Drop in the test data | ||
env.Command( |
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.
SG. Thanks.
@tst-lsavoie: I'm rebuilding. I was thinking the script could |
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.
@tst-lsavoie: I'm OK with your change. I added a couple of minor proposed improvements. Let me know if you accept them, or not. Otherwise, I'm ready to approve.
# This script should be run from NATIVE-*-x86_64/bin/tests | ||
my $workingDir = abs_path(cwd()); | ||
my $scriptDir = dirname(abs_path($0)); | ||
my $notInBuildDir = (index($scriptDir, "NATIVE") == -1); |
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.
Minor: Since Perl is famous for regular expressions, or regular expressions are famous because of Perl, you could use something like:
my $notInBuildDir = $scriptDir !~ /NATIVE-[a-zA-Z0-9_-]*\/bin\/tests$/;
This should work in more cases than (index($scriptDir, "NATIVE") == -1)
.
my $workingDir = abs_path(cwd()); | ||
my $scriptDir = dirname(abs_path($0)); | ||
my $notInBuildDir = (index($scriptDir, "NATIVE") == -1); | ||
if ($workingDir ne $scriptDir || $notInBuildDir) { |
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.
Minor: Instead of testing $workingDir ne $scriptDir
you could also do:
chdir($scriptDir);
That way the script would work from anywhere, as long as it's called from a build directory.
In total it would be something like:
# This script should be run from NATIVE-*-x86_64/bin/tests
my $scriptDir = dirname(abs_path($0));
chdir($scriptDir);
if ($scriptDir !~ /NATIVE-[a-zA-Z0-9_-]*\/bin\/tests$/) {
# . . .
}
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.
I agree with this. It would be more user friendly in my opinion to just cd into the proper directory.
@tst-ppenev I tried it with the chdir command and I still got test failures. Rather than try to debug it, I'm just leaving it as a warning. I did add the regex, though. |
@tst-lsavoie: You also need to replace the use of the |
@tst-ppenev I'm still getting failures. If I run from src it works, but if I run from earth_enterprise (one directory above src) it fails. |
@tst-ppenev figured it out and made the suggested changes. Take another look. |
Uses Command/rsync_cmd to match other SConscripts
Running the unit tests from outside the NATIVE-REL-x86_64 (or similar) directory causes failures. This change prints an error if the tests are run outside the expected directory. Adds a regex check to ensure that tests are running from the correct directory. This is more robust than the previous substring check. Changes to the directory containing the test script before running the tests.
Fixes #15
This is a follow up to this PR: #70