@@ -0,0 +1,2876 @@
+// Copyright 2018 The Bazel Authors. All rights reserved.%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//    http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0Apackage com.google.devtools.build.lib.analysis;%0A%0Aimport static org.junit.Assert.fail;%0A%0Aimport com.google.devtools.build.lib.analysis.util.AnalysisTestCase;%0Aimport com.google.devtools.build.lib.clock.BlazeClock;%0Aimport com.google.devtools.build.lib.vfs.Dirent;%0Aimport com.google.devtools.build.lib.vfs.FileSystem;%0Aimport com.google.devtools.build.lib.vfs.Path;%0Aimport com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;%0Aimport java.io.IOException;%0Aimport java.util.Collection;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0A%0A/**%0A * Tests verifying appropriate propagation of %7B@link InterruptedException%7D during filesystem%0A * operations.%0A */%0A@RunWith(JUnit4.class)%0Apublic class InterruptedExceptionTest extends AnalysisTestCase %7B%0A%0A  private final Thread mainThread = Thread.currentThread();%0A%0A  @Override%0A  protected FileSystem createFileSystem() %7B%0A    return new InMemoryFileSystem(BlazeClock.instance()) %7B%0A      @Override%0A      protected Collection%3CDirent%3E readdir(Path path, boolean followSymlinks) throws IOException %7B%0A        if (path.toString().contains(%22causes_interrupt%22)) %7B%0A          mainThread.interrupt();%0A        %7D%0A        return super.readdir(path, followSymlinks);%0A      %7D%0A    %7D;%0A  %7D%0A%0A  @Test%0A  public void testGlobInterruptedException() throws Exception %7B%0A    scratch.file(%22a/BUILD%22, %22sh_library(name = 'a', srcs = glob(%5B'**/*'%5D))%22);%0A    scratch.file(%22a/b/foo.sh%22, %22testfile%22);%0A    scratch.file(%22a/causes_interrupt/bar.sh%22, %22testfile%22);%0A    reporter.removeHandler(failFastHandler);%0A%0A    try %7B%0A      update(%22//a:a%22);%0A      fail(%22Expected interrupted exception%22);%0A    %7D catch (InterruptedException expected) %7B%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void testSkylarkGlobInterruptedException() throws Exception %7B%0A    scratch.file(%22a/gen.bzl%22,%0A        %22def gen():%22,%0A        %22  native.filegroup(name = 'a', srcs = native.glob(%5B'**/*'%5D))%22);%0A    scratch.file(%22a/BUILD%22,%0A        %22load('//a:gen.bzl', 'gen')%22,%0A        %22gen()%22);%0A%0A    scratch.file(%22a/b/foo.sh%22, %22testfile%22);%0A    scratch.file(%22a/causes_interrupt/bar.sh%22, %22testfile%22);%0A    reporter.removeHandler(failFastHandler);%0A%0A    try %7B%0A      update(%22//a:a%22);%0A      fail(%22Expected interrupted exception%22);%0A    %7D catch (InterruptedException expected) %7B%0A    %7D%0A  %7D%0A%7D%0A

Create tests verifying appropriate propagation of InterruptedException during filesystem operations.