Skip to content

Commit

Permalink
fix: cross-platform compat
Browse files Browse the repository at this point in the history
  • Loading branch information
jac3km4 committed Jul 26, 2024
1 parent eb4d607 commit 0c27ac2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ rust-2018-idioms = "deny"
rust-2021-compatibility = "deny"

[workspace.lints.clippy]
all = "deny"
all = { level = "deny", priority = -1 }
match_same_arms = "deny"
semicolon_if_nothing_returned = "deny"
single_match_else = "deny"
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/typechecker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a> TypeChecker<'a> {
}
} else {
let mut checked = Vec::with_capacity(exprs.len());
for expr in exprs.iter() {
for expr in exprs {
let val = match expected {
Some(TypeId::Array(elem)) => self.check_and_convert(expr, elem, scope)?,
_ => self.check(expr, None, scope)?,
Expand Down
11 changes: 10 additions & 1 deletion scc/lib-tests/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#[cfg(windows)]
use std::ffi::CString;
use std::{fs, mem};
#[cfg(windows)]
use std::fs;
use std::mem;

#[cfg(windows)]
use assert_fs::prelude::*;
#[cfg(windows)]
use minidl::*;
use scc_lib_tests::*;

#[cfg(windows)]
#[test]
fn api_functions_are_stable() {
// this test just ensures that the API types haven't changed
Expand Down Expand Up @@ -68,6 +74,7 @@ fn api_types_are_stable() {
assert_eq!(SccSourceRefType_SCC_SOURCE_REF_TYPE_ENUM, 4);
}

#[cfg(windows)]
#[test]
fn compiles_successfully() {
let temp = assert_fs::TempDir::new().unwrap();
Expand Down Expand Up @@ -152,6 +159,7 @@ fn compiles_successfully() {
temp.close().unwrap();
}

#[cfg(windows)]
#[test]
fn receives_an_error() {
let temp = assert_fs::TempDir::new().unwrap();
Expand Down Expand Up @@ -196,6 +204,7 @@ fn receives_an_error() {
temp.close().unwrap();
}

#[cfg(windows)]
fn load_api() -> SccApi {
let lib = Library::load("scc_lib.dll").unwrap();
unsafe {
Expand Down
1 change: 1 addition & 0 deletions scc/lib/include/scc.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SCC_H
#define SCC_H

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

Expand Down
1 change: 1 addition & 0 deletions scc/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use flexi_logger::{Age, Cleanup, Criterion, Duplicate, FileSpec, LogSpecBuilder,
use hashbrown::{HashMap, HashSet};
use hints::UserHints;
use log::LevelFilter;
#[cfg(windows)]
use normpath::PathExt;
use redscript::ast::Span;
use redscript::bundle::{ConstantPool, ScriptBundle};
Expand Down
11 changes: 9 additions & 2 deletions scc/lib/tests/compile.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use std::fs;
use std::fs::{File, OpenOptions};
#[cfg(windows)]
use std::fs::{self, File, OpenOptions};
#[cfg(windows)]
use std::path::Path;
use std::process::Command;

use assert_cmd::prelude::*;
#[cfg(windows)]
use assert_fs::prelude::*;
use predicates::prelude::*;
#[cfg(windows)]
use scc_lib::timestamp::*;

#[test]
Expand All @@ -25,6 +28,7 @@ fn help() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(windows)]
#[test]
fn bundle_result() -> Result<(), Box<dyn std::error::Error>> {
let temp = assert_fs::TempDir::new()?;
Expand All @@ -50,6 +54,7 @@ fn bundle_result() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(windows)]
#[test]
fn timestamp_migration() -> Result<(), Box<dyn std::error::Error>> {
let temp = assert_fs::TempDir::new()?;
Expand Down Expand Up @@ -85,6 +90,7 @@ fn timestamp_migration() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(windows)]
#[test]
fn custom_output_clean() -> Result<(), Box<dyn std::error::Error>> {
let temp = assert_fs::TempDir::new()?;
Expand Down Expand Up @@ -114,6 +120,7 @@ fn custom_output_clean() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

#[cfg(windows)]
#[test]
fn custom_output_with_restore() -> Result<(), Box<dyn std::error::Error>> {
let temp = assert_fs::TempDir::new()?;
Expand Down

0 comments on commit 0c27ac2

Please sign in to comment.