-
-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle broken resource mapping files (by throwing exceptions).
Testing Done: Ran new tests locally. CI is green: https://travis-ci.org/pantsbuild/pants/builds/57559852 Reviewed at https://rbcommons.com/s/twitter/r/2038/
- Loading branch information
1 parent
14886c5
commit 35069b8
Showing
8 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...g-broken-long/META-INF/compiler/resource-mappings/org.pantsbuild.example.ExampleProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resources by class name: | ||
1 items | ||
org.pantsbuild.example.Morx -> /home/user/project/.pants.d/compile/jvm/java/classes/org/pantsbuild/example/resource1.txt | ||
#comment | ||
org.pantsbuild.example.Fleem -> /home/user/project/.pants.d/compile/jvm/java/classes/org/pantsbuild/example/resource1.txt | ||
#comment |
4 changes: 4 additions & 0 deletions
4
...roken-mangled/META-INF/compiler/resource-mappings/org.pantsbuild.example.ExampleProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resources by class name: | ||
2 items | ||
org.pantsbuild.example.Morx -> /home/user/project/.pants.d/compile/jvm/java/classes/org/pantsbuild/example/resource1.txt | ||
org.pantsbuild.example.Fleem NO CARRIER |
6 changes: 6 additions & 0 deletions
6
...missing-items/META-INF/compiler/resource-mappings/org.pantsbuild.example.ExampleProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resources by class name: | ||
nonsense | ||
org.pantsbuild.example.Morx -> /home/user/project/.pants.d/compile/jvm/java/classes/org/pantsbuild/example/resource1.txt | ||
#comment | ||
org.pantsbuild.example.Fleem -> /home/user/project/.pants.d/compile/jvm/java/classes/org/pantsbuild/example/resource1.txt | ||
#comment |
4 changes: 4 additions & 0 deletions
4
...-broken-short/META-INF/compiler/resource-mappings/org.pantsbuild.example.ExampleProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resources by class name: | ||
2 items | ||
org.pantsbuild.example.Morx -> /home/user/project/.pants.d/compile/jvm/java/classes/org/pantsbuild/example/resource1.txt | ||
#comment |
6 changes: 6 additions & 0 deletions
6
...ource_mapping/META-INF/compiler/resource-mappings/org.pantsbuild.example.ExampleProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resources by class name: | ||
2 items | ||
org.pantsbuild.example.Morx -> /home/user/project/.pants.d/compile/jvm/java/classes/org/pantsbuild/example/resource1.txt | ||
#comment | ||
org.pantsbuild.example.Fleem -> /home/user/project/.pants.d/compile/jvm/java/classes/org/pantsbuild/example/resource1.txt | ||
#comment |
48 changes: 48 additions & 0 deletions
48
tests/python/pants_test/backend/jvm/tasks/jvm_compile/test_resource_mapping.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# coding=utf-8 | ||
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
import os | ||
|
||
from pants.backend.jvm.tasks.jvm_compile.resource_mapping import ResourceMapping | ||
from pants_test.base_test import BaseTest | ||
|
||
|
||
class ResourceMappingTest(BaseTest): | ||
def test_resource_mapping_ok(self): | ||
rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping' | ||
resource_mapping = ResourceMapping(rel_dir) | ||
|
||
self.assertEquals(2, len(resource_mapping.mappings)) | ||
|
||
def test_resource_mapping_short(self): | ||
rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping-broken-short' | ||
resource_mapping = ResourceMapping(rel_dir) | ||
|
||
with self.assertRaises(ResourceMapping.TruncatedFileException): | ||
resource_mapping.mappings | ||
|
||
def test_resource_mapping_long(self): | ||
rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping-broken-long' | ||
resource_mapping = ResourceMapping(rel_dir) | ||
|
||
with self.assertRaises(ResourceMapping.TooLongFileException): | ||
resource_mapping.mappings | ||
|
||
def test_resource_mapping_mangled(self): | ||
rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping-broken-mangled' | ||
resource_mapping = ResourceMapping(rel_dir) | ||
|
||
with self.assertRaises(ResourceMapping.UnparseableLineException): | ||
resource_mapping.mappings | ||
|
||
|
||
def test_resource_mapping_noitems(self): | ||
rel_dir = 'tests/python/pants_test/backend/jvm/tasks/jvm_compile/test-data/resource_mapping-broken-missing-items' | ||
resource_mapping = ResourceMapping(rel_dir) | ||
|
||
with self.assertRaises(ResourceMapping.MissingItemsLineException): | ||
resource_mapping.mappings |