void () { String mSrcRoot = PathUtil.getParentPath(createFile("m/src/A.java", "class A{}")); String mTestRoot = PathUtil.getParentPath(createFile("m/test/Test.java", "class Test{}")); String tSrcRoot = PathUtil.getParentPath(createFile("t/T.java", "class T{}")); JpsModule m = addModule("m", mSrcRoot); m.addSourceRoot(JpsPathUtil.pathToUrl(mTestRoot), JavaSourceRootType.TEST_SOURCE); JpsModule t = addModule("t", tSrcRoot); JpsModuleRootModificationUtil.addDependency(t, m); JpsModuleRootModificationUtil.addDependency(m, t, JpsJavaDependencyScope.TEST, false); CompileScope scope = CompileScopeTestBuilder.rebuild().allModules().build(); ProjectDescriptor descriptor = createProjectDescriptor(BuildLoggingManager.DEFAULT); try { BuildTargetIndex targetIndex = descriptor.getBuildTargetIndex(); CompileContext context = CompileContextImpl.createContextForTests(scope, descriptor); List<BuildTargetChunk> chunks = targetIndex.getSortedTargetChunks(context); for (BuildTargetChunk chunk : chunks) { assertTrue("Circular dependency between build targets " + chunk.getTargets(), chunk.getTargets().size() == 1); } assertEmpty(targetIndex.getDependencies(new ModuleBuildTarget(t, JavaModuleBuildTargetType.TEST), context)); } finally { descriptor.release(); } }