From 2f8d787b5f691bd55584fb74556d408301ddb788 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Thu, 31 Dec 2015 10:44:30 -0800 Subject: [PATCH] buck: run tests Compile each test in its own java_test() target so they can run in parallel, reducing total time spent testing on large machines. $ buck test --all [-] PROCESSING BUCK FILES...FINISHED 0.3s [100%] [-] BUILDING...FINISHED 2.9s [100%] (351/383 JOBS, 351 UPDATED, 0.0% CACHE MISS) [-] TESTING...FINISHED 98.1s (3360 PASS/15 SKIP/0 FAIL) Change-Id: I8d6541268315089299f933ed23d785b1b3431133 --- .buckconfig | 2 +- lib/BUCK | 27 ++++++++++ org.eclipse.jgit.pgm.test/BUCK | 37 +++++++++++++ org.eclipse.jgit.pgm/BUCK | 1 + org.eclipse.jgit.test/BUCK | 94 ++++++++++++++++++++++++++++++++++ 5 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 org.eclipse.jgit.pgm.test/BUCK create mode 100644 org.eclipse.jgit.test/BUCK diff --git a/.buckconfig b/.buckconfig index ef82fa07f..b2e07accc 100644 --- a/.buckconfig +++ b/.buckconfig @@ -2,7 +2,7 @@ includes = //tools/default.defs [java] - src_roots = src, resources + src_roots = src, resources, tst [project] ignore = .git diff --git a/lib/BUCK b/lib/BUCK index f33cadbbe..524612bde 100644 --- a/lib/BUCK +++ b/lib/BUCK @@ -79,6 +79,15 @@ maven_jar( version = '1.6', ) +maven_jar( + name = 'tukaani-xz', + bin_sha1 = '66db21c8484120cb6a51b5b3ea47b6f383942bec', + src_sha1 = '6396220725701d767c553902c41120d7bf38e9f5', + group = 'org.tukaani', + artifact = 'xz', + version = '1.3', +) + maven_jar( name = 'args4j', bin_sha1 = '139441471327b9cc6d56436cb2a31e60eb6ed2ba', @@ -96,3 +105,21 @@ maven_jar( artifact = 'junit', version = '4.11', ) + +maven_jar( + name = 'hamcrest-library', + bin_sha1 = '4785a3c21320980282f9f33d0d1264a69040538f', + src_sha1 = '047a7ee46628ab7133129cd7cef1e92657bc275e', + group = 'org.hamcrest', + artifact = 'hamcrest-library', + version = '1.3', +) + +maven_jar( + name = 'hamcrest-core', + bin_sha1 = '42a25dc3219429f0e5d060061f71acb49bf010a0', + src_sha1 = '1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b', + group = 'org.hamcrest', + artifact = 'hamcrest-core', + version = '1.3', +) diff --git a/org.eclipse.jgit.pgm.test/BUCK b/org.eclipse.jgit.pgm.test/BUCK new file mode 100644 index 000000000..dae9cd924 --- /dev/null +++ b/org.eclipse.jgit.pgm.test/BUCK @@ -0,0 +1,37 @@ +TESTS = glob(['tst/**/*.java']) + +for t in TESTS: + n = t[len('tst/'):len(t)-len('.java')].replace('/', '.') + java_test( + name = n, + labels = ['pgm'], + srcs = [t], + deps = [ + ':helpers', + '//org.eclipse.jgit:jgit', + '//org.eclipse.jgit.archive:jgit-archive', + '//org.eclipse.jgit.junit:junit', + '//org.eclipse.jgit.pgm:pgm', + '//lib:hamcrest-core', + '//lib:hamcrest-library', + '//lib:javaewah', + '//lib:junit', + '//lib:slf4j-api', + '//lib:slf4j-simple', + '//lib:commons-compress', + '//lib:tukaani-xz', + ], + source_under_test = ['//org.eclipse.jgit.pgm:pgm'], + ) + +java_library( + name = 'helpers', + srcs = glob(['src/**/*.java']), + deps = [ + '//org.eclipse.jgit:jgit', + '//org.eclipse.jgit.pgm:pgm', + '//org.eclipse.jgit.junit:junit', + '//lib:args4j', + '//lib:junit', + ], +) diff --git a/org.eclipse.jgit.pgm/BUCK b/org.eclipse.jgit.pgm/BUCK index 64237c32e..d99c39d03 100644 --- a/org.eclipse.jgit.pgm/BUCK +++ b/org.eclipse.jgit.pgm/BUCK @@ -40,5 +40,6 @@ java_binary( deps = [ ':pgm', '//lib:slf4j-simple', + '//lib:tukaani-xz', ], ) diff --git a/org.eclipse.jgit.test/BUCK b/org.eclipse.jgit.test/BUCK new file mode 100644 index 000000000..9a9d9efd0 --- /dev/null +++ b/org.eclipse.jgit.test/BUCK @@ -0,0 +1,94 @@ +PKG = 'tst/org/eclipse/jgit/' +HELPERS = glob(['src/**/*.java']) + [PKG + c for c in [ + 'api/AbstractRemoteCommandTest.java', + 'diff/AbstractDiffTestCase.java', + 'internal/storage/file/GcTestCase.java', + 'internal/storage/file/PackIndexTestCase.java', + 'internal/storage/file/XInputStream.java', + 'nls/GermanTranslatedBundle.java', + 'nls/MissingPropertyBundle.java', + 'nls/NoPropertiesBundle.java', + 'nls/NonTranslatedBundle.java', + 'revwalk/RevQueueTestCase.java', + 'revwalk/RevWalkTestCase.java', + 'transport/SpiTransport.java', + 'treewalk/FileTreeIteratorWithTimeControl.java', + 'treewalk/filter/AlwaysCloneTreeFilter.java', + 'test/resources/SampleDataRepositoryTestCase.java', + 'util/CPUTimeStopWatch.java', + 'util/io/Strings.java', +]] + +DATA = [ + PKG + 'lib/empty.gitindex.dat', + PKG + 'lib/sorttest.gitindex.dat', +] + +TESTS = glob( + ['tst/**/*.java'], + excludes = HELPERS + DATA, +) + +DEPS = { + PKG + 'nls/RootLocaleTest.java': [ + '//org.eclipse.jgit.pgm:pgm', + '//org.eclipse.jgit.ui:ui', + ], +} + +for src in TESTS: + name = src[len('tst/'):len(src)-len('.java')].replace('/', '.') + labels = [] + if name.startswith('org.eclipse.jgit.'): + l = name[len('org.eclipse.jgit.'):] + if l.startswith('internal.storage.'): + l = l[len('internal.storage.'):] + i = l.find('.') + if i > 0: + labels.append(l[:i]) + else: + labels.append(i) + if 'lib' not in labels: + labels.append('lib') + + java_test( + name = name, + labels = labels, + srcs = [src], + deps = [ + ':helpers', + ':tst_rsrc', + '//org.eclipse.jgit:jgit', + '//org.eclipse.jgit.junit:junit', + '//lib:hamcrest-core', + '//lib:hamcrest-library', + '//lib:javaewah', + '//lib:junit', + '//lib:slf4j-api', + '//lib:slf4j-simple', + ] + DEPS.get(src, []), + source_under_test = ['//org.eclipse.jgit:jgit'], + ) + +java_library( + name = 'helpers', + srcs = HELPERS, + resources = DATA, + deps = [ + '//org.eclipse.jgit:jgit', + '//org.eclipse.jgit.junit:junit', + '//lib:junit', + ], +) + +prebuilt_jar( + name = 'tst_rsrc', + binary_jar = ':tst_rsrc_jar', +) + +genrule( + name = 'tst_rsrc_jar', + cmd = 'cd $SRCDIR/tst-rsrc ; zip -qr $OUT .', + srcs = glob(['tst-rsrc/**']), + out = 'tst_rsrc.jar', +)