Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to debug VMs #135

Open
Josef37 opened this issue Oct 7, 2022 · 1 comment
Open

How to debug VMs #135

Josef37 opened this issue Oct 7, 2022 · 1 comment

Comments

@Josef37
Copy link

Josef37 commented Oct 7, 2022

I've been looking into #121 yesterday and tried to set up some tests to verify wrong/right behavior.

Therefore I had to create a few mocks in roomsSpec.js, but couldn't find out what these values should be.

My idea was to debug the script when its running to get some useful mocks, but I can't get my IDE (VSCode) to debug those...

I've seen there is a config option editor.enableInspector so I figured you have set this up once.
Can you help me set up debugging?


PS: That's where I'm currently at in terms of mocking values

let globals = {};

beforeEach(() => {
  const runtimeData = {
    staticTerrainData: require("../../helpers/mocks/rooms").terrain,
  };
  const register = {
    wrapFn: fn => fn,
    rooms: { E2S7: {} },
    _useNewPathFinder: true,
  };

  rooms.make(runtimeData, {}, register, globals);
  rooms.makePos(register);

  for (var i in runtimeData.rooms) {
    register.rooms[i] = new globals.Room(i);
  }
});

But calling RoomPosition.findClosestByPath still results in the following issue, since globals.PathFinder is not set.

Message:
    TypeError: Cannot read property 'search' of undefined
  Stack:
        at <Jasmine>
        at _findClosestByPath2 (/Users/josef/screeps/screeps-modules/engine/src/game/rooms.js:360:34)
        at RoomPosition.findClosestByPath (/Users/josef/screeps/screeps-modules/engine/src/game/rooms.js:1446:20)
        at UserContext.fit (/Users/josef/screeps/screeps-modules/engine/spec/engine/game/roomsSpec.js:70:28)
        at <Jasmine>
        at runCallback (timers.js:705:18)
@richard-hajek
Copy link

Did you manage to get the enableInspector to work? Did it work out of the box for you, to at least inspect the values in the VM?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants