Skip to content

Commit

Permalink
Merge pull request #1438 from jqnatividad/remove-luau-jit-option
Browse files Browse the repository at this point in the history
`luau`: remove `--jit` option
  • Loading branch information
jqnatividad authored Nov 24, 2023
2 parents 7994322 + fcce670 commit e84329c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 99 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ log = "0.4"
mimalloc = { version = "0.1", default-features = false, optional = true }
mlua = { version = "0.9", features = [
"luau",
"luau-jit",
"serialize",
], optional = true }
num_cpus = "1"
Expand Down
6 changes: 1 addition & 5 deletions src/cmd/luau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ Luau options:
can "require" lua/luau library files from.
See https://www.lua.org/pil/8.1.html
[default: ?;?.luau;?.lua]
--no-jit Don't use Luau's JIT compiler.
--max-errors <count> The maximum number of errors to tolerate before aborting.
Set to zero to disable error limit.
[default: 100]
Expand Down Expand Up @@ -259,7 +258,6 @@ struct Args {
flag_begin: Option<String>,
flag_end: Option<String>,
flag_luau_path: String,
flag_no_jit: bool,
flag_output: Option<String>,
flag_no_headers: bool,
flag_delimiter: Option<Delimiter>,
Expand Down Expand Up @@ -522,8 +520,6 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
// set default Luau compiler
luau.set_compiler(luau_compiler.clone());

luau.enable_jit(!args.flag_no_jit);

let globals = luau.globals();

// check the QSV_CKAN_API environment variable
Expand Down Expand Up @@ -2068,7 +2064,7 @@ fn setup_helpers(
//
// returns: Luau table of header names excluding the first header.
// Luau runtime error if the CSV could not be loaded, or
// if called from the MAIN or END scripts, or
// if called from the MAIN or END scripts, or
// if the lookup table is empty.
//
let qsv_register_lookup = luau.create_function(move |luau, (lookup_name, mut lookup_table_uri, cache_age_secs): (String, String, i64)| {
Expand Down
89 changes: 0 additions & 89 deletions tests/test_luau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,95 +320,6 @@ END {
wrk.assert_success(&mut cmd);
}

#[test]
fn luau_aggregation_with_embedded_begin_end_using_file_no_jit() {
let wrk = Workdir::new("luau_embedded_begin_end");
wrk.create(
"data.csv",
vec![
svec!["letter", "Amount"],
svec!["a", "13"],
svec!["b", "24"],
svec!["c", "72"],
svec!["d", "7"],
],
);

wrk.create_from_string(
"testbeginend.luau",
r#"
BEGIN {
-- this is the BEGIN block, which is executed once at the beginning
-- where we typically initialize variables, setup functions
-- and load additional Lua libraries as required
running_total = 0;
grand_total = 0;
amount_array = {};
adjusted_array = {};
function margin(x: number, y: number ): number
return x * y;
end
function sum(numbers_array: table): number
local sum: number = 0;
for _, v in ipairs(numbers_array) do
sum = sum + v;
end
return sum;
end
}!
-- this is the MAIN script loop, which is executed for each row
-- note how we use the _IDX special variable to get the row index
amount_array[_IDX] = Amount;
running_total = running_total + Amount;
adjusted_array[_IDX] = Amount + margin(Amount, 0.25);
-- running_total is the value we "map" to the "Running Total" column of each row
return running_total;
END {
-- and this is the END block, which is executed once at the end
grand_total = running_total;
min_amount = math.min(unpack(amount_array));
max_amount = math.max(unpack(amount_array));
adjusted_total = sum(adjusted_array);
-- note how we use the _ROWCOUNT special variable to get the number of rows
-- the value returned from the END script is sent to stderr
return (`Min/Max: {min_amount}/{max_amount} Grand total of {_ROWCOUNT} rows: {grand_total} adjusted: {adjusted_total}`);
}!
"#,
);

let mut cmd = wrk.command("luau");
cmd.arg("map")
.arg("Running Total")
.arg("file:testbeginend.luau")
.arg("--no-jit")
.arg("data.csv");

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = vec![
svec!["letter", "Amount", "Running Total"],
svec!["a", "13", "13"],
svec!["b", "24", "37"],
svec!["c", "72", "109"],
svec!["d", "7", "116"],
];
assert_eq!(got, expected);

let end = wrk.output_stderr(&mut cmd);
let expected_end = "Min/Max: 7/72 Grand total of 4 rows: 116 adjusted: 145\n".to_string();
assert_eq!(end, expected_end);

wrk.assert_success(&mut cmd);
}

#[test]
fn luau_register_lookup_table() {
let wrk = Workdir::new("luau_register_lookup_table");
Expand Down

0 comments on commit e84329c

Please sign in to comment.