Skip to content

Commit 9f6b98f

Browse files
committed
CI fixes.
Fix Lua 5.1 tests. Remove the no-lua-oslib build variant.
1 parent 18feb31 commit 9f6b98f

File tree

3 files changed

+28
-57
lines changed

3 files changed

+28
-57
lines changed

.circleci/config.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,6 @@ jobs:
3737
- target/debug/build
3838
- target/debug/deps
3939
key: cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }}
40-
build-no-oslib:
41-
docker:
42-
- image: cimg/rust:1.75.0
43-
steps:
44-
- checkout
45-
- run:
46-
name: Version information
47-
command: rustc --version; cargo --version; rustup --version
48-
- run:
49-
name: Calculate dependencies
50-
command: cargo generate-lockfile
51-
- restore_cache:
52-
keys:
53-
- cargo-cache-no-oslib-{{ arch }}-{{ checksum "Cargo.lock" }}
54-
- run:
55-
name: Build all targets
56-
command: cargo build --features=lua-no-oslib --all --all-targets
57-
- run:
58-
name: Run all tests
59-
command: cargo test --features=lua-no-oslib --all
60-
- save_cache:
61-
paths:
62-
- /usr/local/cargo/registry
63-
- target/debug/.fingerprint
64-
- target/debug/build
65-
- target/debug/deps
66-
key: cargo-cache-no-oslib-{{ arch }}-{{ checksum "Cargo.lock" }}
6740
build-lua53:
6841
docker:
6942
- image: cimg/rust:1.75.0
@@ -214,4 +187,3 @@ workflows:
214187
- "build-lua51"
215188
- "build-luajit"
216189
- "build-windows"
217-
- "build-no-oslib"

tests/conversion.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,14 @@ use rlua::{Integer, Lua, Result, RluaCompat, String, Table, ToLuaCompat, Value};
22

33
fn valid_float(verify: Result<Value>, expected: f64) {
44
let verify_unwrap = verify.unwrap();
5-
assert_eq!(verify_unwrap.type_name(), "number");
5+
assert!(verify_unwrap.type_name() == "number" || verify_unwrap.type_name() == "integer");
66
match verify_unwrap {
77
Value::Number(value) => assert_eq!(value, expected),
8+
Value::Integer(value) => assert_eq!(value as f64, expected),
89
_ => panic!("unexpected type"),
910
};
1011
}
1112

12-
#[cfg(rlua_lua51)]
13-
fn valid_int(verify: Result<Value>, expected: Integer) {
14-
let verify_unwrap = verify.unwrap();
15-
assert_eq!(verify_unwrap.type_name(), "number");
16-
match verify_unwrap {
17-
Value::Number(value) => assert_eq!(value as Integer, expected),
18-
_ => panic!("unexpected type"),
19-
};
20-
}
21-
22-
#[cfg(not(rlua_lua51))]
2313
fn valid_int(verify: Result<Value>, expected: Integer) {
2414
let verify_unwrap = verify.unwrap();
2515
assert_eq!(verify_unwrap.type_name(), "integer");

tests/tests.rs

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -809,16 +809,6 @@ fn test_loadstring_wrappers() {
809809
.exec()
810810
.unwrap();
811811
assert_eq!(globals.get::<_, u32>("x").unwrap(), 1);
812-
lua.load(
813-
r#"
814-
assert(type(binchunk) == "string")
815-
chunk = loadstring(binchunk)
816-
assert(chunk == nil)
817-
"#,
818-
)
819-
.exec()
820-
.unwrap();
821-
assert_eq!(globals.get::<_, u32>("x").unwrap(), 1);
822812
lua.load(
823813
r#"
824814
local s = "x = x + 4"
@@ -1052,15 +1042,24 @@ fn test_pcall_xpcall() {
10521042
assert!(r);
10531043
assert_eq!(e, "foo");
10541044

1045+
#[cfg(not(rlua_lua51))]
10551046
let (r, e) = lua
1056-
.load("xpcall(function(p) return p end, print, 'foo')")
1047+
.load("xpcall(function(p) return p end, function(e) print(e) return e end, 'foo')")
10571048
.eval::<(bool, String)>()
10581049
.unwrap();
10591050
assert!(r);
10601051
assert_eq!(e, "foo");
10611052

1053+
#[cfg(rlua_lua51)]
1054+
let (r, e) = lua
1055+
.load("xpcall(function(p) return 'foo' end, function(e) print(e) return e end)")
1056+
.eval::<(bool, String)>()
1057+
.unwrap();
1058+
assert!(r);
1059+
assert_eq!(e, "foo");
10621060
// Make sure that the return values are correct on errors, and that error handling works
10631061

1062+
#[cfg(not(rlua_lua51))]
10641063
lua.load(
10651064
r#"
10661065
pcall_error = nil
@@ -1073,16 +1072,26 @@ fn test_pcall_xpcall() {
10731072
.exec()
10741073
.unwrap();
10751074

1075+
#[cfg(rlua_lua51)]
1076+
lua.load(
1077+
r#"
1078+
pcall_error = nil
1079+
pcall_status, pcall_error = pcall(error, "testerror")
1080+
1081+
xpcall_error = nil
1082+
xpcall_status, _ = xpcall(function() error("testerror") end, function(err) xpcall_error = err end)
1083+
"#,
1084+
)
1085+
.exec()
1086+
.unwrap();
10761087
assert_eq!(globals.get::<_, bool>("pcall_status").unwrap(), false);
1077-
assert_eq!(
1078-
globals.get::<_, String>("pcall_error").unwrap(),
1079-
"testerror"
1088+
assert!(
1089+
globals.get::<_, String>("pcall_error").unwrap().to_str().unwrap().ends_with("testerror")
10801090
);
10811091

10821092
assert_eq!(globals.get::<_, bool>("xpcall_statusr").unwrap(), false);
1083-
assert_eq!(
1084-
globals.get::<_, String>("xpcall_error").unwrap(),
1085-
"testerror"
1093+
assert!(
1094+
globals.get::<_, String>("xpcall_error").unwrap().to_str().unwrap().ends_with("testerror")
10861095
);
10871096

10881097
// Make sure that weird xpcall error recursion at least doesn't cause unsafety or panics.

0 commit comments

Comments
 (0)