Tools cleanup

Add a python test, clean up some error messages, and trim
env vars that don't need to be passed to build/staging scripts.
This commit is contained in:
Chris Masone
2015-12-15 11:18:00 -08:00
parent 2e451bea37
commit a47edc8431
5 changed files with 12 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/python
import os, os.path, subprocess, sys
import os, os.path, subprocess
import noms.symlink as symlink

View File

@@ -29,8 +29,10 @@ def Main(projectName, stagingFunction):
args = parser.parse_args()
projectStagingDir = os.path.join(args.stagingDir, projectName)
# check if project dir is in staging dir
normalized = os.path.realpath(projectStagingDir)
if not _isSubDir(projectStagingDir, args.stagingDir):
raise Exception(projectStagingDir + ' must be a subdir of ' + args.stagingDir)
os.makedirs(normalized)
stagingFunction(normalized)

View File

@@ -24,6 +24,11 @@ class TestStaging(unittest.TestCase):
self.assertFalse(staging._isSubDir(self.nested, otherNested))
def test_DotDotNotReallyNested(self):
notReallyNested = os.path.join(self.tempdir, 'foo', os.pardir, 'bar')
self.assertFalse(staging._isSubDir(self.nested, notReallyNested))
def test_LinkNotReallyNested(self):
otherNested = tempfile.mkdtemp(dir=self.tempdir)
linkName = os.path.join(self.nested, 'link')

View File

@@ -43,11 +43,8 @@ func main() {
}
pythonPath := filepath.Join(goPath, nomsCheckoutPath, "tools")
env := runner.Env{
"GOPATH": goPath,
"PYTHONPATH": pythonPath,
"NOMS_SERVER": nomsServer,
"NOMS_CHECKOUT_PATH": filepath.Join(workspace, nomsCheckoutPath),
"ATTIC_CHECKOUT_PATH": filepath.Join(workspace, atticCheckoutPath),
"PYTHONPATH": pythonPath,
"NOMS_SERVER": nomsServer,
}
if !runner.Serial(os.Stdout, os.Stderr, env, ".", buildScript) {

View File

@@ -52,7 +52,7 @@ func Serial(stdout, stderr io.Writer, env Env, dir, filename string, args ...str
runErr := runEnvDir(stdout, stderr, env, filepath.Dir(path), "python", scriptAndArgs...)
if runErr != nil {
success = false
fmt.Fprintf(stderr, "Running %s failed with %v", path, runErr)
fmt.Fprintf(stderr, "Running %s failed with %v\n", path, runErr)
}
}
return nil