Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions jdk/test/tools/launcher/TestHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -103,10 +103,12 @@ public class TestHelper {
// make a note of the golden default locale
static final Locale DefaultLocale = Locale.getDefault();

static final String JAVA_FILE_EXT = ".java";
static final String CLASS_FILE_EXT = ".class";
static final String JAR_FILE_EXT = ".jar";
static final String EXE_FILE_EXT = ".exe";
static final String JAVA_FILE_EXT = ".java";
static final String CLASS_FILE_EXT = ".class";
static final String JAR_FILE_EXT = ".jar";
static final String EXE_FILE_EXT = ".exe";
static final String MAC_DSYM_EXT = ".dsym";
static final String NIX_DBGINFO_EXT = ".debuginfo";
static final String JLDEBUG_KEY = "_JAVA_LAUNCHER_DEBUG";
static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC";
static final String TEST_PREFIX = "###TestError###: ";
Expand Down Expand Up @@ -506,6 +508,43 @@ static boolean isEnglishLocale() {
return Locale.getDefault().getLanguage().equals("en");
}

static class ToolFilter implements FileFilter {
final List<String> exclude = new ArrayList<>();
protected ToolFilter(String... exclude) {
for (String x : exclude) {
String str = x + ((isWindows) ? EXE_FILE_EXT : "");
this.exclude.add(str.toLowerCase());
}
}

@Override
public boolean accept(File pathname) {
if (!pathname.isFile() || !pathname.canExecute()) {
return false;
}
String name = pathname.getName().toLowerCase();
if (isWindows) {
if (!name.endsWith(EXE_FILE_EXT)) {
return false;
}
} else if (isMacOSX) {
if (name.endsWith(MAC_DSYM_EXT)) {
return false;
}
} else {
if (name.endsWith(NIX_DBGINFO_EXT)) {
return false;
}
}
for (String x : exclude) {
if (name.endsWith(x)) {
return false;
}
}
return true;
}
}

/*
* A class to encapsulate the test results and stuff, with some ease
* of use methods to check the test results.
Expand Down
35 changes: 4 additions & 31 deletions jdk/test/tools/launcher/VersionCheck.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,11 +31,12 @@
*/

import java.io.File;
import java.io.FileFilter;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class VersionCheck extends TestHelper {

Expand Down Expand Up @@ -227,32 +228,4 @@ public static void main(String[] args) {
throw new AssertionError("Some tests failed");
}
}

static class ToolFilter implements FileFilter {
final Iterable<String> exclude ;
protected ToolFilter(String... exclude) {
List<String> tlist = new ArrayList<>();
this.exclude = tlist;
for (String x : exclude) {
String str = x + ((isWindows) ? EXE_FILE_EXT : "");
tlist.add(str.toLowerCase());
}
}
@Override
public boolean accept(File pathname) {
if (!pathname.isFile() || !pathname.canExecute()) {
return false;
}
String name = pathname.getName().toLowerCase();
if (isWindows && !name.endsWith(EXE_FILE_EXT)) {
return false;
}
for (String x : exclude) {
if (name.endsWith(x)) {
return false;
}
}
return true;
}
}
}