

def test_compile_stale_platform_settings(self):
    with temporary_dir(root_dir=os.path.abspath('.')) as tmpdir:
        with open(os.path.join(tmpdir, 'BUILD'), 'w') as f:
            f.write(dedent("\n        java_library(name='diamond',\n          sources=['Diamond.java'],\n        )\n        "))
        with open(os.path.join(tmpdir, 'Diamond.java'), 'w') as f:
            f.write(dedent('\n          public class Diamond<T> {\n            public static void main(String[] args) {\n              // The diamond operator <> for generics was introduced in jdk7.\n              Diamond<String> shinyDiamond = new Diamond<>();\n            }\n          }\n        '))
        platforms = {
            'java6': {
                'source': '6',
            },
            'java7': {
                'source': '7',
            },
        }
        with self.temporary_workdir() as workdir:

            def compile_diamond(platform):
                return self.run_pants_with_workdir(((['--jvm-platform-platforms={}'.format(platforms), '--jvm-platform-default-platform={}'.format(platform), '-ldebug', 'compile'] + self.get_pants_compile_args()) + ['{}:diamond'.format(tmpdir)]), workdir=workdir)
            self.assert_failure(compile_diamond('java6'), 'Diamond.java was compiled successfully with java6 starting from a fresh workdir, but that should not be possible.')
            self.assert_success(compile_diamond('java7'), 'Diamond.java failed to compile in java7, which it should be able to.')
            self.assert_failure(compile_diamond('java6'), 'Diamond.java erroneously compiled in java6, which means that either compilation was skipped due to bad fingerprinting/caching, or the compiler failed to clean up the previous class from the java7 compile.')

dataset/ETHPy150Open pantsbuild/pants/tests/python/pants_test/backend/jvm/tasks/jvm_compile/java/jvm_platform_integration_mixin.py JvmPlatformIntegrationMixin.test_compile_stale_platform_settings/original