summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-28 14:28:02 +0200
committerLaurenz <laurmaedje@gmail.com>2023-03-28 14:30:21 +0200
commite84df1a03690d24cb87d53fb4ed70af9c473c6fb (patch)
tree0266bfdab0a6942dd160d4d10d47b84afdec04eb
parenta0249d230961c9ccbcc37dea61357f0ea56961cc (diff)
Fix tests on Windows
Fixes #386.
-rw-r--r--cli/src/main.rs9
-rw-r--r--docs/src/general/changelog.md3
-rw-r--r--src/eval/mod.rs2
-rw-r--r--tests/src/tests.rs12
4 files changed, 11 insertions, 15 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index 0a2b94eb..eaa429c7 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -2,7 +2,7 @@ use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::fs::{self, File};
use std::hash::Hash;
-use std::io::{self, Read, Write};
+use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::process;
@@ -559,11 +559,8 @@ impl PathHash {
/// Read a file.
fn read(path: &Path) -> FileResult<Vec<u8>> {
let f = |e| FileError::from_io(e, path);
- let mut file = File::open(path).map_err(f)?;
- if file.metadata().map_err(f)?.is_file() {
- let mut data = vec![];
- file.read_to_end(&mut data).map_err(f)?;
- Ok(data)
+ if fs::metadata(&path).map_err(f)?.is_file() {
+ fs::read(&path).map_err(f)
} else {
Err(FileError::IsDirectory)
}
diff --git a/docs/src/general/changelog.md b/docs/src/general/changelog.md
index ab12344e..45de2dd6 100644
--- a/docs/src/general/changelog.md
+++ b/docs/src/general/changelog.md
@@ -5,6 +5,9 @@ description: |
---
# Changelog
+## Unreleased
+- Reduced maximum function call depth from 256 to 64.
+
## March 28, 2023
- **Breaking:** Enumerations now require a space after their marker, that is,
`[1.ok]` must now be written as `[1. ok]`
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index 8790bc18..e278d787 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -60,7 +60,7 @@ use crate::util::PathExt;
use crate::World;
const MAX_ITERATIONS: usize = 10_000;
-const MAX_CALL_DEPTH: usize = 256;
+const MAX_CALL_DEPTH: usize = 64;
/// Evaluate a source file and return the resulting module.
#[comemo::memoize]
diff --git a/tests/src/tests.rs b/tests/src/tests.rs
index 12f1ecdc..66eb532f 100644
--- a/tests/src/tests.rs
+++ b/tests/src/tests.rs
@@ -2,8 +2,7 @@ use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::env;
use std::ffi::OsStr;
-use std::fs::{self, File};
-use std::io::Read;
+use std::fs;
use std::ops::Range;
use std::path::{Path, PathBuf};
@@ -325,11 +324,8 @@ fn read(path: &Path) -> FileResult<Vec<u8>> {
.unwrap_or_else(|_| path.into());
let f = |e| FileError::from_io(e, &suffix);
- let mut file = File::open(&path).map_err(f)?;
- if file.metadata().map_err(f)?.is_file() {
- let mut data = vec![];
- file.read_to_end(&mut data).map_err(f)?;
- Ok(data)
+ if fs::metadata(&path).map_err(f)?.is_file() {
+ fs::read(&path).map_err(f)
} else {
Err(FileError::IsDirectory)
}
@@ -472,7 +468,7 @@ fn test_part(
let mut errors: Vec<_> = errors
.into_iter()
.filter(|error| error.span.source() == id)
- .map(|error| (error.range(world), error.message.to_string()))
+ .map(|error| (error.range(world), error.message.replace('\\', "/")))
.collect();
errors.sort_by_key(|error| error.0.start);