From 1db85407aafc75ac0e24d96e323f7c62490a82e4 Mon Sep 17 00:00:00 2001 From: Nan Zhang Date: Mon, 18 Dec 2017 13:20:23 -0800 Subject: Remove timestamp based filelist file for tracking Python dependencies Each Python module will generate a zip file containing source & data files. The Python binary will collect all its dependencies and use merge_zips to merge each zip file to create a final .par file. Test: m -j checkbuild && real examples: Bug: b/70568913 Change-Id: I9ff232d461d33e1c06026e7dcb5b124bf02c3ce5 --- python/python_test.go | 68 ++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 42 deletions(-) (limited to 'python/python_test.go') diff --git a/python/python_test.go b/python/python_test.go index 176c6eca0..67b19827c 100644 --- a/python/python_test.go +++ b/python/python_test.go @@ -29,12 +29,11 @@ import ( ) type pyModule struct { - name string - actualVersion string - pyRunfiles []string - depsPyRunfiles []string - parSpec string - depsParSpecs []string + name string + actualVersion string + pyRunfiles []string + srcsZip string + depsSrcsZips []string } var ( @@ -313,14 +312,10 @@ var ( "runfiles/e/default_py3.py", "runfiles/e/file4.py", }, - depsPyRunfiles: []string{ - "runfiles/a/b/file1.py", - "runfiles/c/d/file2.py", - }, - parSpec: "-P runfiles/e -C dir/ -l @prefix@/.intermediates/dir/bin/PY3/dir_.list", - depsParSpecs: []string{ - "-P runfiles/a/b -C dir/ -l @prefix@/.intermediates/dir/lib5/PY3/dir_.list", - "-P runfiles/c/d -C dir/ -l @prefix@/.intermediates/dir/lib6/PY3/dir_.list", + srcsZip: "@prefix@/.intermediates/dir/bin/PY3/bin.zip", + depsSrcsZips: []string{ + "@prefix@/.intermediates/dir/lib5/PY3/lib5.zip", + "@prefix@/.intermediates/dir/lib6/PY3/lib6.zip", }, }, }, @@ -356,8 +351,9 @@ func TestPythonModule(t *testing.T) { testErrs = append(testErrs, expectModule(t, ctx, buildDir, e.name, e.actualVersion, - e.pyRunfiles, e.depsPyRunfiles, - e.parSpec, e.depsParSpecs)...) + e.srcsZip, + e.pyRunfiles, + e.depsSrcsZips)...) } } fail(t, testErrs) @@ -388,9 +384,8 @@ func expectErrors(t *testing.T, actErrs []error, expErrs []string) (testErrs []e return } -func expectModule(t *testing.T, ctx *android.TestContext, buildDir, name, variant string, - expPyRunfiles, expDepsPyRunfiles []string, - expParSpec string, expDepsParSpecs []string) (testErrs []error) { +func expectModule(t *testing.T, ctx *android.TestContext, buildDir, name, variant, expectedSrcsZip string, + expectedPyRunfiles, expectedDepsSrcsZips []string) (testErrs []error) { module := ctx.ModuleForTests(name, variant) base, baseOk := module.Module().(*Module) @@ -398,47 +393,36 @@ func expectModule(t *testing.T, ctx *android.TestContext, buildDir, name, varian t.Fatalf("%s is not Python module!", name) } - actPyRunfiles := []string{} + actualPyRunfiles := []string{} for _, path := range base.srcsPathMappings { - actPyRunfiles = append(actPyRunfiles, path.dest) + actualPyRunfiles = append(actualPyRunfiles, path.dest) } - if !reflect.DeepEqual(actPyRunfiles, expPyRunfiles) { + if !reflect.DeepEqual(actualPyRunfiles, expectedPyRunfiles) { testErrs = append(testErrs, errors.New(fmt.Sprintf( `binary "%s" variant "%s" has unexpected pyRunfiles: %q!`, base.Name(), base.properties.Actual_version, - actPyRunfiles))) + actualPyRunfiles))) } - if !reflect.DeepEqual(base.depsPyRunfiles, expDepsPyRunfiles) { + if base.srcsZip.String() != strings.Replace(expectedSrcsZip, "@prefix@", buildDir, 1) { testErrs = append(testErrs, errors.New(fmt.Sprintf( - `binary "%s" variant "%s" has unexpected depsPyRunfiles: %q!`, + `binary "%s" variant "%s" has unexpected srcsZip: %q!`, base.Name(), base.properties.Actual_version, - base.depsPyRunfiles))) + base.srcsZip))) } - if base.parSpec.soongParArgs() != strings.Replace(expParSpec, "@prefix@", buildDir, 1) { - testErrs = append(testErrs, errors.New(fmt.Sprintf( - `binary "%s" variant "%s" has unexpected parSpec: %q!`, - base.Name(), - base.properties.Actual_version, - base.parSpec.soongParArgs()))) + for i, _ := range expectedDepsSrcsZips { + expectedDepsSrcsZips[i] = strings.Replace(expectedDepsSrcsZips[i], "@prefix@", buildDir, 1) } - - actDepsParSpecs := []string{} - for i, p := range base.depsParSpecs { - actDepsParSpecs = append(actDepsParSpecs, p.soongParArgs()) - expDepsParSpecs[i] = strings.Replace(expDepsParSpecs[i], "@prefix@", buildDir, 1) - } - - if !reflect.DeepEqual(actDepsParSpecs, expDepsParSpecs) { + if !reflect.DeepEqual(base.depsSrcsZips.Strings(), expectedDepsSrcsZips) { testErrs = append(testErrs, errors.New(fmt.Sprintf( - `binary "%s" variant "%s" has unexpected depsParSpecs: %q!`, + `binary "%s" variant "%s" has unexpected depsSrcsZips: %q!`, base.Name(), base.properties.Actual_version, - actDepsParSpecs))) + base.depsSrcsZips))) } return -- cgit v1.2.3