Skip to content

Commit ebbc6ce

Browse files
authored
Merge pull request #99 from rage/refresh-fixer
Refresh fixer
2 parents 69e2b04 + 69d8e91 commit ebbc6ce

File tree

6 files changed

+13
-82
lines changed

6 files changed

+13
-82
lines changed

tmc-langs-framework/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ zip = "0.5"
1818
schemars = "0.8"
1919
once_cell = "1"
2020
nom = "6"
21+
funty = "=1.1.0" # temporary workaround, remove later
2122
subprocess = "0.2"
2223
tempfile = "3"
2324
anyhow = "1"

tmc-langs-framework/src/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ pub trait LanguagePlugin {
433433
for entry in WalkDir::new(exercise_file_path) {
434434
let entry = entry?;
435435
if entry.path().is_file() {
436-
log::debug!("parsing points from {}", entry.path().display());
436+
log::trace!("parsing points from {}", entry.path().display());
437437
let file_contents = file_util::read_file_to_string(entry.path())?;
438438

439439
let etc_parser = combinator::value(Parse::Other, bytes::complete::take(1usize));

tmc-langs-util/src/task_executor.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ mod tar_helper;
77
mod tmc_zip;
88

99
pub use self::course_refresher::{refresh_course, ModeBits, RefreshData, RefreshExercise};
10-
pub use self::submission_packaging::{OutputFormat, TmcParams};
10+
pub use self::submission_packaging::{prepare_submission, OutputFormat, TmcParams};
11+
pub use self::submission_processing::prepare_solution;
1112

1213
use crate::error::UtilError;
1314
use crate::{ExerciseDesc, ExercisePackagingConfiguration, RunResult, StyleValidationResult};
@@ -28,12 +29,6 @@ use tmc_langs_python3::Python3Plugin;
2829
use tmc_langs_r::RPlugin;
2930
use walkdir::WalkDir;
3031

31-
/// See `submission_processing::prepare_solution`.
32-
pub fn prepare_solution(exercise_path: &Path, dest_root: &Path) -> Result<(), UtilError> {
33-
submission_processing::prepare_solution(exercise_path, dest_root)?;
34-
Ok(())
35-
}
36-
3732
/// See `submission_processing::prepare_stub`.
3833
pub fn prepare_stub(exercise_path: &Path, dest_path: &Path) -> Result<(), UtilError> {
3934
submission_processing::prepare_stub(&exercise_path, dest_path)?;
@@ -45,28 +40,6 @@ pub fn prepare_stub(exercise_path: &Path, dest_path: &Path) -> Result<(), UtilEr
4540
Ok(())
4641
}
4742

48-
/// Takes a submission zip and turns it into an archive suitable for
49-
/// further processing by among other things resetting the test files
50-
pub fn prepare_submission(
51-
zip_path: &Path,
52-
target_path: &Path,
53-
toplevel_dir_name: Option<String>,
54-
tmc_params: TmcParams,
55-
clone_path: &Path,
56-
stub_zip_path: Option<&Path>,
57-
output_format: OutputFormat,
58-
) -> Result<(), UtilError> {
59-
submission_packaging::prepare_submission(
60-
zip_path,
61-
target_path,
62-
toplevel_dir_name,
63-
tmc_params,
64-
clone_path,
65-
stub_zip_path,
66-
output_format,
67-
)
68-
}
69-
7043
/// See `LanguagePlugin::check_code_style`.
7144
pub fn run_check_code_style(
7245
path: &Path,

tmc-langs-util/src/task_executor/course_refresher.rs

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::{
88
use md5::Context;
99
use serde::{Deserialize, Serialize};
1010
use serde_yaml::Mapping;
11-
use std::io::Write;
1211
use std::path::{Path, PathBuf};
12+
use std::{io::Write, time::Duration};
1313
use tmc_langs_framework::{command::TmcCommand, file_util, subprocess::Redirection};
1414
use walkdir::WalkDir;
1515

@@ -200,7 +200,10 @@ fn initialize_new_cache_clone(
200200
log::info!("initializing repository at {}", new_clone_path.display());
201201

202202
if old_clone_path.join(".git").exists() {
203-
log::info!("trying to copy clone from previous cache");
203+
log::info!(
204+
"trying to copy clone from previous cache at {}",
205+
old_clone_path.display()
206+
);
204207

205208
// closure to collect any error that occurs during the process
206209
let copy_and_update_repository = || -> Result<(), UtilError> {
@@ -214,7 +217,7 @@ fn initialize_new_cache_clone(
214217
.stdout(Redirection::Pipe)
215218
.stderr(Redirection::Pipe)
216219
})
217-
.output_checked()
220+
.output_with_timeout_checked(Duration::from_secs(60 * 2))
218221
};
219222

220223
run_git(&["remote", "set-url", "origin", course_source_url])?;
@@ -249,7 +252,7 @@ fn initialize_new_cache_clone(
249252
.stdout(Redirection::Pipe)
250253
.stderr(Redirection::Pipe)
251254
})
252-
.output_checked()?;
255+
.output_with_timeout_checked(Duration::from_secs(60 * 2))?;
253256
Ok(())
254257
}
255258

@@ -440,52 +443,6 @@ mod test {
440443
target
441444
}
442445

443-
/*
444-
#[test]
445-
#[ignore = "uses git"]
446-
fn updates_repository() {
447-
init();
448-
449-
let cache = tempfile::TempDir::new().unwrap();
450-
file_util::create_dir_all(cache.path().join("clone")).unwrap();
451-
let run_git = |args: &[&str], cwd: &Path| {
452-
TmcCommand::new("git")
453-
.with(|e| {
454-
e.args(args)
455-
.cwd(cwd)
456-
.stdout(Redirection::Pipe)
457-
.stderr(Redirection::Pipe)
458-
})
459-
.output_checked()
460-
.unwrap()
461-
};
462-
run_git(&["init"], &cache.path().join("clone"));
463-
assert!(cache.path().join("clone/.git").exists());
464-
465-
let clone = tempfile::TempDir::new().unwrap();
466-
run_git(&["init"], &clone.path());
467-
run_git(&["remote", "add", "origin", ""], &clone.path());
468-
469-
update_or_clone_repository(clone.path(), Path::new(GIT_REPO), "master", cache.path())
470-
.unwrap();
471-
assert!(clone.path().join("texts").exists());
472-
}
473-
474-
#[test]
475-
#[ignore = "uses git"]
476-
fn clones_repository() {
477-
init();
478-
479-
let clone = tempfile::TempDir::new().unwrap();
480-
assert!(!clone.path().join(".git").exists());
481-
let old_cache_path = Path::new("nonexistent");
482-
483-
update_or_clone_repository(clone.path(), Path::new(GIT_REPO), "master", old_cache_path)
484-
.unwrap();
485-
assert!(clone.path().join("texts").exists());
486-
}
487-
*/
488-
489446
#[test]
490447
fn checks_directory_names() {
491448
init();

tmc-langs-util/src/task_executor/submission_packaging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub fn prepare_submission(
366366
let tmc_project_yml = TmcProjectYml::from(clone_path)?;
367367
for extra_student_file in tmc_project_yml.extra_student_files {
368368
// todo secure path
369-
let source = received_dir.join(&extra_student_file);
369+
let source = project_root.join(&extra_student_file);
370370
if source.exists() {
371371
let target = dest.join(&extra_student_file);
372372
file_util::copy(source, target)?;

tmc-langs-util/src/task_executor/submission_processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn copy_file(
116116
}
117117
}
118118
// writes all lines
119-
log::debug!(
119+
log::trace!(
120120
"filtered file {} to {}",
121121
file.display(),
122122
dest_path.display()

0 commit comments

Comments
 (0)