доделал копирование папок для тестов. не было учтено наличие подверсий.
This commit is contained in:
2023-11-27 21:59:45 +03:00
parent f8146f8267
commit e6f9b9103b
5 changed files with 26 additions and 23 deletions

View File

@@ -108,7 +108,8 @@ public class Utils {
int di = fn.lastIndexOf(".");
return (di >= 0) ? fn.substring(di + 1).toLowerCase() : "";
}
public static String getExtensionByName(String fn) {;
public static String getExtensionByName(String fn) {
;
int di = fn.lastIndexOf(".");
return (di >= 0) ? fn.substring(di + 1).toLowerCase() : "";
}
@@ -1136,15 +1137,7 @@ public class Utils {
}
//--
public static boolean isVersion(File directory) throws Exception {
File[] files = directory.listFiles(File::isDirectory);
if (files!=null){
for (File file: files){
File data = new File(file, Constants.data);
if (data.exists())
return true;
}
}
return false;
return new File(directory, Constants.data).exists();
}
}

View File

@@ -62,7 +62,7 @@ public class Visualiser extends Component {
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
@Override
public void GetVersionInfo() {
version = 1039;
version = 1040;
String pattern = "MMM dd yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
date_text = df.format(getClassBuildTime());

View File

@@ -88,7 +88,18 @@ public class Test extends riDBObject {
File tempArchive = getTempArchive();
//- создать бд.
FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(dir, tempProject);
File[] files = dir.listFiles();
if (files == null)
throw new PassException("Не удалось получить список файлов папки " + Utils.Brackets(dir));
//--
//предполагается, что тут уже нет вложенных подпапок кроме версий. поэтому копируем только файлы.
for (File file : files) {
if (file.isFile()) {
System.out.println(file.getAbsolutePath());
File dst = new File(tempProject, file.getName());
FileUtils.copyFile(file, dst);
}
}
//---
Utils.ClearProjectData(tempProject);
//--
@@ -134,8 +145,7 @@ public class Test extends riDBObject {
public String getFilesForTable() {
return files.replace("\n", ";");
}
public LinkedHashMap<LanguageName, Vector<ProjectFile>> getPrograms(){
public LinkedHashMap<LanguageName, Vector<ProjectFile>> getPrograms() {
LinkedHashMap<LanguageName, Vector<ProjectFile>> res = new LinkedHashMap<>();
//--
res.put(LanguageName.fortran, new Vector<>());
@@ -143,7 +153,7 @@ public class Test extends riDBObject {
res.put(LanguageName.cpp, new Vector<>());
//--
String[] files_names = files.split("\n");
for (String file_name: files_names){
for (String file_name : files_names) {
ProjectFile file = new ProjectFile(new File(file_name));
//--
if (!file.state.equals(FileState.Excluded) &&
@@ -153,5 +163,4 @@ public class Test extends riDBObject {
}
return res;
}
}

View File

@@ -81,7 +81,10 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
Log.Writeln_("Имя файла " + Utils.Brackets(file.getName()) + " содержит запрещённые символы " + Constants.all_forbidden_characters_string + ", или кириллицу.");
bad++;
}
if (file.isDirectory() && !file.getName().equalsIgnoreCase(Constants.data) && Utils.isVersion(file)) {
if (file.isDirectory() &&
!file.getName().equalsIgnoreCase(Constants.data) &&
!Utils.isVersion(file)
) {
subdirs++;
}
if (file.isFile()) {
@@ -140,7 +143,7 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
File tempProject = target.packCode(dir, true); //создание копии папки, и архивация.
//-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!!
ShowMessage2("Синтаксический анализ и определение размерности");
if (group.language.equals(LanguageName.fortran)&&!Sapfor.getMinMaxDim(Sapfor.getTempCopy(Current.getSapfor().getFile()), tempProject, target))
if (group.language.equals(LanguageName.fortran) && !Sapfor.getMinMaxDim(Sapfor.getTempCopy(Current.getSapfor().getFile()), tempProject, target))
Log.Writeln_("Не удалось определить размерность теста " + Utils.Brackets(tempProject.getName()));
}
@Override