Skip to content

Commit a4d44cd

Browse files
committed
edits
1 parent 3352348 commit a4d44cd

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ jobs:
4444
with:
4545
python-version: '3.x'
4646

47-
- name: Install Python dependencies
48-
run: pip install tomli
49-
5047
- name: Configure
5148
run: |
5249
mkdir build && cd build

tests/lit/lit/formats/Cpp2RustTest.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
import re
1010
import shutil
1111
import random
12-
import tomli
1312

1413

1514
def read_rust_version():
1615
toolchain_path = os.path.join(
17-
os.path.dirname(__file__), "../../../../libcc2rs/rust-toolchain.toml"
16+
os.path.dirname(__file__), "../../../../cmake/rust-toolchain.cmake"
1817
)
19-
with open(toolchain_path, "rb") as f:
20-
return tomli.load(f)["toolchain"]["channel"]
18+
with open(toolchain_path, "r") as f:
19+
for line in f:
20+
m = re.match(r'set\s*\(\s*RUST_VERSION\s+"([^"]+)', line)
21+
if m:
22+
return m.group(1)
23+
raise Exception("could not find rust version in " + toolchain_path)
2124

2225

2326
def shared_target_dir():
@@ -170,15 +173,12 @@ def fail(str, code=fail_code):
170173
pkg_name = "test_" + re.sub(r"[^a-zA-Z0-9_]", "_", os.path.basename(tmp_dir))
171174

172175
# Check if we can compile the rust file
173-
with open(tmp_dir + "/rust-toolchain.toml", "w") as f:
174-
f.write(f'[toolchain]\nchannel = "{self.rust_version}"\n')
175176
with open(tmp_dir + "/Cargo.toml", "w") as f:
176177
f.write(f"""
177178
[package]
178179
name = "{pkg_name}"
179180
version = "0.1.0"
180181
edition = "2021"
181-
rust-version = "{self.rust_version}"
182182
183183
[[bin]]
184184
name = "{pkg_name}"
@@ -189,7 +189,7 @@ def fail(str, code=fail_code):
189189
libcc2rs = {{ path = "../../../libcc2rs" }}
190190
""")
191191

192-
cmd = ["cargo", "build", "--release", "--quiet"]
192+
cmd = ["cargo", "+" + self.rust_version, "build", "--release", "--quiet"]
193193
_, err, returncode = lit.util.executeCommand(cmd, tmp_dir, env=cargo_env())
194194
if should_not_compile:
195195
if returncode != 0:

0 commit comments

Comments
 (0)